1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #!/bin/bash
- set -e
- SERVICE_NAME="slskd-permission-monitor"
- SERVICE_PATH="/etc/systemd/system/${SERVICE_NAME}.service"
- SCRIPT_PATH="/usr/local/bin/slskd-permission-monitor.sh"
- # Check if running as root
- if [ "$(id -u)" -ne 0 ]; then
- echo "This script must be run as root." >&2
- exit 1
- fi
- # Create the service file
- cat > "$SERVICE_PATH" <<EOF
- [Unit]
- Description=SLSKD Permissions Monitor
- After=network.target
- After=docker.service
- Wants=docker.service
- [Service]
- Type=simple
- ExecStart=$SCRIPT_PATH
- Restart=on-failure
- RestartSec=10s
- KillSignal=SIGINT
- TimeoutStopSec=20s
- StandardOutput=journal
- StandardError=journal
- # Security hardening (since we need to run as root)
- ProtectSystem=full
- PrivateTmp=true
- NoNewPrivileges=true
- [Install]
- WantedBy=multi-user.target
- EOF
- # Reload systemd, enable and start the service
- systemctl daemon-reexec
- systemctl daemon-reload
- systemctl enable --now "$SERVICE_NAME"
- echo "**Service '$SERVICE_NAME' installed and started successfully.**"
|