Skip to content

Commit c626abf

Browse files
authored
Integrate systemd service for PVESciptslocal
Added systemd service integration for PVESciptslocal.
1 parent 8bd7dc9 commit c626abf

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

install.sh

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
# ------------------------------------------------------------------------------
3-
# Installer for PVESciptslocal
3+
# Installer for PVESciptslocal with systemd integration
44
# ------------------------------------------------------------------------------
55

66
set -euo pipefail
@@ -79,11 +79,46 @@ msg_info "Building application..."
7979
npm run build
8080
msg_ok "Build completed."
8181

82-
# --- Start the application ---
83-
read -rp "Do you want to start the application now? (y/N): " START_APP
84-
if [[ "$START_APP" =~ ^[Yy]$ ]]; then
85-
msg_info "Starting application..."
86-
npm start
82+
# --- Create systemd service ---
83+
SERVICE_NAME="pvescriptslocal"
84+
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
85+
86+
msg_info "Creating systemd service at $SERVICE_FILE..."
87+
cat > "$SERVICE_FILE" <<EOF
88+
[Unit]
89+
Description=PVEScriptslocal Service
90+
After=network.target
91+
92+
[Service]
93+
WorkingDirectory=${INSTALL_DIR}
94+
ExecStart=/usr/bin/npm start
95+
Restart=always
96+
RestartSec=10
97+
Environment=NODE_ENV=production
98+
User=root
99+
100+
[Install]
101+
WantedBy=multi-user.target
102+
EOF
103+
104+
systemctl daemon-reexec
105+
msg_ok "Systemd service created and started."
106+
107+
# --- Enable/Start Service ---
108+
read -rp "Enable and start the service now? (y/N): " START_SERVICE
109+
if [[ "$START_SERVICE" =~ ^[Yy]$ ]]; then
110+
systemctl enable --now pvescriptslocal.service
111+
msg_ok "Service enabled and started. Check status with: systemctl status pvescriptslocal"
87112
else
88-
msg_info "You can start the app anytime by running: cd $INSTALL_DIR && npm start"
113+
msg_info "You can start it manually with: systemctl start pvescriptslocal"
89114
fi
115+
116+
echo
117+
echo "---------------------------------------------"
118+
echo " Service installed: $SERVICE_NAME"
119+
echo " Manage it with:"
120+
echo " systemctl start $SERVICE_NAME"
121+
echo " systemctl stop $SERVICE_NAME"
122+
echo " systemctl status $SERVICE_NAME"
123+
echo " App will be available at: http://<IP>:3000"
124+
echo "---------------------------------------------"

0 commit comments

Comments
 (0)