Skip to content

Commit 94349e1

Browse files
committed
feat: ask API key when installing service
1 parent 0b9921b commit 94349e1

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

install_service.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@ cp linux-edr.service /etc/systemd/system/
3838
# Create default config directory if it doesn't exist
3939
mkdir -p /etc/linux_edr
4040

41-
# Copy default config if it doesn't exist
42-
if [ ! -f /etc/linux_edr/config.ini ]; then
43-
echo "Installing default configuration..."
44-
cp linux_edr/config.ini /etc/linux_edr/
41+
# Copy default config and update with OpenAI API key
42+
echo "Installing configuration..."
43+
cp linux_edr/config.ini /etc/linux_edr/
44+
45+
# Prompt for OpenAI API key
46+
echo ""
47+
echo "Please enter your OpenAI API key (press Enter to skip):"
48+
read -r api_key
49+
50+
if [ ! -z "$api_key" ]; then
51+
# Update the config file with the API key
52+
echo "Setting OpenAI API key in config file..."
53+
sed -i "s/^api_key =.*/api_key = $api_key/" /etc/linux_edr/config.ini
54+
chmod 600 /etc/linux_edr/config.ini
4555
fi
4656

4757
# Reload systemd
@@ -54,4 +64,5 @@ echo ""
5464
echo "To check status:"
5565
echo " systemctl status linux-edr.service"
5666
echo ""
57-
echo "Configuration file is at /etc/linux_edr/config.ini"
67+
echo "Configuration file is at /etc/linux_edr/config.ini"
68+
echo "Note: The config file permissions are set to 600 to protect the API key"

0 commit comments

Comments
 (0)