Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 23rd, 2012  |  syntax: Bash  |  size: 1.76 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          nginx
  4. # Required-Start:    $remote_fs $syslog $named $network $time
  5. # Required-Stop:     $remote_fs $syslog $named $network
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: Start nginx at boot time
  9. # Description:       Enable service provided by nginx.
  10. ### END INIT INFO
  11. # $Id$
  12.  
  13. NGINXHOME=/usr/local/nginx
  14. NGINXPID=$NGINXHOME/logs/nginx.pid
  15.  
  16. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  17. DAEMON=$NGINXHOME/sbin/nginx
  18. NAME=nginx
  19. DESC=nginx
  20.  
  21. if [ ! -x $DAEMON ]
  22. then
  23.    echo "Couldn't find $DAEMON. Please set path to DAEMON."
  24.    exit 0
  25. fi
  26.  
  27. # Include nginx defaults if available
  28. if [ -f /etc/default/nginx ] ; then
  29.         . /etc/default/nginx
  30. fi
  31.  
  32. set -e
  33.  
  34. case "$1" in
  35.   start)
  36.         echo -n "Starting $DESC: "
  37.         start-stop-daemon --start --pidfile $NGINXPID \
  38.                 --exec $DAEMON -- $DAEMON_OPTS
  39.         echo "$NAME."
  40.         ;;
  41.   stop)
  42.         echo -n "Stopping $DESC: "
  43.         start-stop-daemon --stop --pidfile $NGINXPID \
  44.                 --exec $DAEMON
  45.         echo "$NAME."
  46.         ;;
  47.   restart|force-reload)
  48.         echo -n "Restarting $DESC: "
  49.         start-stop-daemon --stop --pidfile \
  50.                 $NGINXHOME/run/$NAME.pid --exec $DAEMON
  51.         sleep 1
  52.         start-stop-daemon --start --pidfile \
  53.                 $NGINXPID --exec $DAEMON -- $DAEMON_OPTS
  54.         echo "$NAME."
  55.         ;;
  56.   reload)
  57.       echo -n "Reloading $DESC configuration: "
  58.       start-stop-daemon --stop --signal HUP --pidfile $NGINXPID \
  59.           --exec $DAEMON
  60.       echo "$NAME."
  61.       ;;
  62.   *)
  63.         N=/etc/init.d/$NAME
  64.         echo "Usage: $N {start|stop|restart|force-reload}" >&2
  65.         exit 1
  66.         ;;
  67. esac
  68.  
  69. exit 0