Skip to content

Instantly share code, notes, and snippets.

@gomasaba
Created May 4, 2012 19:07
Show Gist options
  • Save gomasaba/2597067 to your computer and use it in GitHub Desktop.
Save gomasaba/2597067 to your computer and use it in GitHub Desktop.
nginx
#! /bin/sh
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/user/bin
NAME=nginx
DESC="nginx deamon"
DAEMON=/usr/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
#デーモンが見つからないときは終了
test -x $DAEMON || exit 0
d_start(){
$DAEMON || echo -n "already running $DEAMON"
}
d_stop(){
$DAEMON -s quit || echo -n "not running"
}
d_reload(){
$DAEMON -s reload || echo -n "could not reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration: "
d_reload
echo "."
;;
restart|force-reload)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 2
d_start
echo "."
;;
*)
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