1
0

Nginx-init-Ubuntu 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: nginx
  4. # Required-Start: $all
  5. # Required-Stop: $all
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: starts the nginx web server
  9. # Description: starts nginx using start-stop-daemon
  10. ### END INIT INFO
  11. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  12. DAEMON=/usr/local/nginx/sbin/nginx
  13. DAEMON_OPTS='-c /usr/local/nginx/conf/nginx.conf'
  14. NAME=nginx
  15. DESC=nginx
  16. test -x $DAEMON || exit 0
  17. # Include nginx defaults if available
  18. if [ -f /etc/default/nginx ] ; then
  19. . /etc/default/nginx
  20. fi
  21. set -e
  22. case "$1" in
  23. start)
  24. echo -n "Starting $DESC: "
  25. start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec $DAEMON -- $DAEMON_OPTS
  26. echo "$NAME."
  27. ;;
  28. stop)
  29. echo -n "Stopping $DESC: "
  30. start-stop-daemon --stop --quiet --pidfile /var/run/nginx.pid --exec $DAEMON
  31. echo "$NAME."
  32. ;;
  33. restart|force-reload)
  34. echo -n "Restarting $DESC: "
  35. start-stop-daemon --stop --quiet --pidfile /var/run/nginx.pid --exec $DAEMON
  36. sleep 1
  37. start-stop-daemon --start --quiet --pidfile /var/run/nginx.pid --exec $DAEMON -- $DAEMON_OPTS
  38. echo "$NAME."
  39. ;;
  40. reload)
  41. echo -n "Reloading $DESC configuration: "
  42. start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/nginx.pid \
  43. --exec $DAEMON
  44. echo "$NAME."
  45. ;;
  46. configtest)
  47. $DAEMON -t $DAEMON_OPTS
  48. ;;
  49. *)
  50. N=/etc/init.d/$NAME
  51. echo "Usage: $N {start|stop|restart|configtest|force-reload}" >&2
  52. exit 1
  53. ;;
  54. esac
  55. exit 0