Guest User

Untitled

a guest
Aug 17th, 2012
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: nginx
  5. # Required-Start: $local_fs $remote_fs $network $syslog
  6. # Required-Stop: $local_fs $remote_fs $network $syslog
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: starts the nginx web server
  10. # Description: starts nginx using start-stop-daemon
  11. ### END INIT INFO
  12.  
  13. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  14. DAEMON=/usr/sbin/nginx
  15. NAME=nginx
  16. DESC=nginx
  17.  
  18. # Include nginx defaults if available
  19. if [ -f /etc/default/nginx ]; then
  20. . /etc/default/nginx
  21. fi
  22.  
  23. test -x $DAEMON || exit 0
  24.  
  25. set -e
  26.  
  27. . /lib/lsb/init-functions
  28.  
  29. test_nginx_config() {
  30. if $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1; then
  31. return 0
  32. else
  33. $DAEMON -t $DAEMON_OPTS
  34. return $?
  35. fi
  36. }
  37.  
  38. case "$1" in
  39. start)
  40. echo -n "Starting $DESC: "
  41. test_nginx_config
  42. # Check if the ULIMIT is set in /etc/default/nginx
  43. if [ -n "$ULIMIT" ]; then
  44. # Set the ulimits
  45. ulimit $ULIMIT
  46. fi
  47. start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
  48. --exec $DAEMON -- $DAEMON_OPTS || true
  49. echo "$NAME."
  50. ;;
  51.  
  52. stop)
  53. echo -n "Stopping $DESC: "
  54. start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
  55. --exec $DAEMON || true
  56. echo "$NAME."
  57. ;;
  58.  
  59. restart|force-reload)
  60. echo -n "Restarting $DESC: "
  61. start-stop-daemon --stop --quiet --pidfile \
  62. /var/run/$NAME.pid --exec $DAEMON || true
  63. sleep 1
  64. test_nginx_config
  65. start-stop-daemon --start --quiet --pidfile \
  66. /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
  67. echo "$NAME."
  68. ;;
  69.  
  70. reload)
  71. echo -n "Reloading $DESC configuration: "
  72. test_nginx_config
  73. start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
  74. --exec $DAEMON || true
  75. echo "$NAME."
  76. ;;
  77.  
  78. configtest|testconfig)
  79. echo -n "Testing $DESC configuration: "
  80. if test_nginx_config; then
  81. echo "$NAME."
  82. else
  83. exit $?
  84. fi
  85. ;;
  86.  
  87. status)
  88. status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
  89. ;;
  90. *)
  91. echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
  92. exit 1
  93. ;;
  94. esac
  95.  
  96. exit 0
RAW Paste Data