-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·43 lines (32 loc) · 1.05 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
SERVICE_NAME="discord-update-helper.service"
SCRIPT_NAME="discord-update-helper.sh"
INSTALL_PATH="/usr/local/bin"
SERVICE_PATH="/etc/systemd/system"
if [[ ! -f "./$SCRIPT_NAME" ]]; then
echo "Error: $SCRIPT_NAME not found in the current directory."
exit 1
fi
# Copy the script to /usr/local/bin for global access
echo "Copying script to $INSTALL_PATH..."
sudo cp "./$SCRIPT_NAME" "$INSTALL_PATH/$SCRIPT_NAME"
sudo chmod +x "$INSTALL_PATH/$SCRIPT_NAME"
echo "Creating the systemd service file..."
sudo bash -c "cat > $SERVICE_PATH/$SERVICE_NAME" <<EOL
[Unit]
Description=Discord Update Helper
After=network-online.target
[Service]
Type=oneshot
ExecStart=$INSTALL_PATH/$SCRIPT_NAME
[Install]
WantedBy=multi-user.target
EOL
sudo chmod 644 "$SERVICE_PATH/$SERVICE_NAME"
# Reload systemd to recognize the new service
echo "Reloading systemd..."
sudo systemctl daemon-reload
echo "Enabling and starting the service..."
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
echo "Service $SERVICE_NAME installed and started successfully."