Skip to content

Instantly share code, notes, and snippets.

@dmitryrck
Created December 28, 2011 18:26
Show Gist options
  • Save dmitryrck/1529020 to your computer and use it in GitHub Desktop.
Save dmitryrck/1529020 to your computer and use it in GitHub Desktop.
/etc/init.d/nginx
#!/bin/bash
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx
### END INIT INFO
DAEMON=/usr/local/nginx/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
$DAEMON
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
$DAEMON -s stop
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
$DAEMON -s stop
sleep 1
$DAEMON
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
$DAEMON -s reload
echo "$NAME."
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment