Last active
October 4, 2015 06:58
-
-
Save miki725/2597644 to your computer and use it in GitHub Desktop.
service script for nginx
This file contains 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
#! /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