nginx-ui.init 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: nginx-ui
  4. # Required-Start: $network $remote_fs $local_fs
  5. # Required-Stop: $network $remote_fs $local_fs
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Start or stop the Nginx UI
  9. ### END INIT INFO
  10. NAME="nginx-ui"
  11. DAEMON="/usr/bin/$NAME"
  12. PIDFILE="/var/run/$NAME.pid"
  13. CONFIG="/usr/local/etc/nginx-ui/app.ini"
  14. [ -x "$DAEMON" ] || exit 0
  15. start() {
  16. echo "Starting $NAME..."
  17. # BusyBox compatible syntax
  18. start-stop-daemon -S -b -p $PIDFILE -m -x $DAEMON -- $CONFIG
  19. echo "$NAME started"
  20. }
  21. stop() {
  22. echo "Stopping $NAME..."
  23. # BusyBox compatible syntax
  24. start-stop-daemon -K -p $PIDFILE -R 10
  25. rm -f $PIDFILE
  26. echo "$NAME stopped"
  27. }
  28. status() {
  29. if [ -f $PIDFILE ]; then
  30. PID=$(cat $PIDFILE)
  31. if kill -0 $PID > /dev/null 2>&1; then
  32. echo "$NAME is running (PID: $PID)"
  33. exit 0
  34. else
  35. echo "$NAME is not running (stale PID file)"
  36. exit 1
  37. fi
  38. else
  39. echo "$NAME is not running"
  40. exit 3
  41. fi
  42. }
  43. case "$1" in
  44. start)
  45. start
  46. ;;
  47. stop)
  48. stop
  49. ;;
  50. restart)
  51. stop
  52. start
  53. ;;
  54. status)
  55. status
  56. ;;
  57. *)
  58. echo "Usage: $0 {start|stop|restart|status}"
  59. exit 1
  60. ;;
  61. esac
  62. exit 0