Advertisement
sdrinf

Untitled

Nov 7th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  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. test -x $DAEMON || exit 0
  19.  
  20. # Include nginx defaults if available
  21. if [ -f /etc/default/nginx ] ; then
  22. . /etc/default/nginx
  23. fi
  24.  
  25. set -e
  26.  
  27. . /lib/lsb/init-functions
  28.  
  29. test_nginx_config() {
  30. if nginx -t $DAEMON_OPTS
  31. then
  32. return 0
  33. else
  34. return $?
  35. fi
  36. }
  37.  
  38. case "$1" in
  39. start)
  40. echo -n "Starting $DESC: "
  41. test_nginx_config
  42. start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
  43. --exec $DAEMON -- $DAEMON_OPTS || true
  44. echo "$NAME."
  45. ;;
  46. stop)
  47. echo -n "Stopping $DESC: "
  48. start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
  49. --exec $DAEMON || true
  50. echo "$NAME."
  51. ;;
  52. restart|force-reload)
  53. echo -n "Restarting $DESC: "
  54. start-stop-daemon --stop --quiet --pidfile \
  55. /var/run/$NAME.pid --exec $DAEMON || true
  56. sleep 1
  57. test_nginx_config
  58. start-stop-daemon --start --quiet --pidfile \
  59. /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
  60. echo "$NAME."
  61. php /www/domain_check.php
  62. ;;
  63. reload)
  64. echo -n "Reloading $DESC configuration: "
  65. test_nginx_config
  66. start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
  67. --exec $DAEMON || true
  68. echo "$NAME."
  69. ;;
  70. configtest)
  71. echo -n "Testing $DESC configuration: "
  72. if test_nginx_config
  73. then
  74. echo "$NAME."
  75. else
  76. exit $?
  77. fi
  78. ;;
  79. status)
  80. status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
  81. ;;
  82. *)
  83. echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
  84. exit 1
  85. ;;
  86. esac
  87.  
  88. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement