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
|
39
resources/services/nginx-ui.rc
Normal file
39
resources/services/nginx-ui.rc
Normal file
|
@ -0,0 +1,39 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name="nginx-ui"
|
||||
description="Nginx UI - Yet another WebUI for Nginx"
|
||||
supervisor=supervise-daemon
|
||||
command="/usr/local/bin/nginx-ui"
|
||||
command_args="-config /usr/local/etc/nginx-ui/app.ini"
|
||||
pidfile="/run/${RC_SVCNAME}.pid"
|
||||
command_user="root:root"
|
||||
|
||||
extra_commands="status"
|
||||
|
||||
depend() {
|
||||
need net
|
||||
after logger firewall
|
||||
use dns
|
||||
after nginx
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
checkpath --directory --owner $command_user --mode 0755 /run
|
||||
checkpath --directory --owner $command_user --mode 0755 /usr/local/etc/nginx-ui
|
||||
}
|
||||
|
||||
status() {
|
||||
if [ -f "${pidfile}" ]; then
|
||||
PID=$(cat "${pidfile}")
|
||||
if kill -0 $PID >/dev/null 2>&1; then
|
||||
einfo "${name} is running (PID: $PID)"
|
||||
return 0
|
||||
else
|
||||
ewarn "${name} is not running (stale PID file)"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
einfo "${name} is not running"
|
||||
return 3
|
||||
fi
|
||||
}
|
16
resources/services/nginx-ui.service
Normal file
16
resources/services/nginx-ui.service
Normal file
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=Yet another WebUI for Nginx
|
||||
Documentation=https://github.com/0xJacky/nginx-ui
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/nginx-ui --config /usr/local/etc/nginx-ui/app.ini
|
||||
RuntimeDirectory=nginx-ui
|
||||
WorkingDirectory=/var/run/nginx-ui
|
||||
Restart=on-failure
|
||||
TimeoutStopSec=5
|
||||
KillMode=mixed
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Add table
Add a link
Reference in a new issue