Skip to content

Instantly share code, notes, and snippets.

@miki725
Last active October 4, 2015 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miki725/2597644 to your computer and use it in GitHub Desktop.
Save miki725/2597644 to your computer and use it in GitHub Desktop.
service script for nginx
#! /bin/sh
# Based on the following script
# Author: Ryan Norbauer's http://norbaurinc.com
# Modified: Geoffrey Grosenbach http://topfunky.com
# Modified: Clement NEDELCU
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
# If the daemon file is not found, terminate
test -x $DAEMON || exit 0
d_start() {
$DAEMON && echo "started" || echo "already running"
}
d_stop() {
$DAEMON -s quit && echo "stopped" || echo "not running"
}
d_reload() {
$DAEMON -s reload && echo "reloaded" || echo -n "could not reload"
}
case "$1" in
start)
echo "Starting $DESC:"
d_start
;;
stop)
echo "Stopping $DESC:"
d_stop
;;
reload)
echo "Reloading $DESC:"
d_reload
;;
restart)
echo "Restarting $DESC:"
d_stop
sleep 2
d_start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
exit 3
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment