mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
parent
db29f2e9c5
commit
5fdd85a302
4 changed files with 329 additions and 35 deletions
67
resources/services/nginx-ui.init
Normal file
67
resources/services/nginx-ui.init
Normal file
|
@ -0,0 +1,67 @@
|
|||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: nginx-ui
|
||||
# Required-Start: $network $remote_fs $local_fs
|
||||
# Required-Stop: $network $remote_fs $local_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start or stop the Nginx UI
|
||||
### END INIT INFO
|
||||
|
||||
NAME="nginx-ui"
|
||||
DAEMON="/usr/local/bin/$NAME"
|
||||
PIDFILE="/var/run/$NAME.pid"
|
||||
CONFIG="/usr/local/etc/nginx-ui/app.ini"
|
||||
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
start() {
|
||||
echo "Starting $NAME..."
|
||||
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- $CONFIG
|
||||
echo "$NAME started"
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "Stopping $NAME..."
|
||||
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
|
||||
rm -f $PIDFILE
|
||||
echo "$NAME stopped"
|
||||
}
|
||||
|
||||
status() {
|
||||
if [ -f $PIDFILE ]; then
|
||||
PID=$(cat $PIDFILE)
|
||||
if kill -0 $PID > /dev/null 2>&1; then
|
||||
echo "$NAME is running (PID: $PID)"
|
||||
exit 0
|
||||
else
|
||||
echo "$NAME is not running (stale PID file)"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "$NAME is not running"
|
||||
exit 3
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue