Created
July 26, 2011 15:59
-
-
Save dirkkelly/1107094 to your computer and use it in GitHub Desktop.
Nginx init.d Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/init.d/nginx | |
#!/bin/sh | |
# SOURCE http://snipplr.com/view/6125/ubuntudebian-nginx-initd-script/ | |
# Modified for Babushka use | |
PATH=/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=SETME | |
CONFIG_FILE=SETME | |
DAEMON_OPTS="-c $CONFIG_FILE" | |
NAME=nginx | |
DESC="nginx web server" | |
PIDFILE=/var/run/$NAME.pid | |
SCRIPTNAME=/etc/init.d/$NAME | |
#only run if binary can be found | |
test -x $DAEMON || exit 0 | |
set -e | |
#import init-functions | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
log_daemon_msg "Starting $DESC" $NAME | |
if ! start-stop-daemon --start --quiet\ | |
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then | |
log_end_msg 1 | |
else | |
log_end_msg 0 | |
fi | |
;; | |
stop) | |
log_daemon_msg "Stopping $DESC" $NAME | |
if start-stop-daemon --quiet --stop --oknodo --retry 30\ | |
--pidfile $PIDFILE --exec $DAEMON; then | |
rm -f $PIDFILE | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
;; | |
reload) | |
log_daemon_msg "Reloading $DESC configuration" $NAME | |
if start-stop-daemon --stop --signal 2 --oknodo --retry 30\ | |
--quiet --pidfile $PIDFILE --exec $DAEMON; then | |
if start-stop-daemon --start --quiet \ | |
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then | |
log_end_msg 0 | |
else | |
log_end_msg 1 | |
fi | |
else | |
log_end_msg 1 | |
fi | |
;; | |
restart|force-reload) | |
$0 stop | |
sleep 1 | |
$0 start | |
;; | |
*) | |
echo "Usage: $SCRIPTNAME {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