Jelajahi Sumber

Add 'install-as-systemd.sh'

For y’all who use Systemd.
mitch donaberger 1 bulan lalu
induk
melakukan
4560e4b330
1 mengubah file dengan 47 tambahan dan 0 penghapusan
  1. 47 0
      install-as-systemd.sh

+ 47 - 0
install-as-systemd.sh

@@ -0,0 +1,47 @@
+#!/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.**"