Current File : /home/inlingua/public_html/decay_sym/root/var/softaculous/apps/nginx/nginx |
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts and stops nginx daemon
# Description: starts and stops nginx daemon
### END INIT INFO
prog=nginx
nginx=/usr/local/apps/nginx/sbin/nginx
conffile=/usr/local/apps/nginx/etc/nginx.conf
lockfile=/var/lock/subsys/nginx
pidfile=/var/run/nginx.pid
SLEEPMSEC=100000
RETVAL=0
start() {
echo -n "Starting $prog: "
if [ ! -f $pidfile ] ; then
#groupadd emps > /dev/null 2>&1
#useradd -r -g emps emps > /dev/null 2>&1
${nginx} -c ${conffile}
if [ $? = 0 ]; then
if [ -d /var/lock/subsys ] ; then
touch $lockfile
fi
echo "[ OK ]"
fi
else
echo "$prog already running"
fi
return 0
}
stop() {
echo -n "Stopping $prog: "
if [ -f $pidfile ] ; then
PID=`cat $pidfile`
kill $PID > /dev/null 2>&1
PID=0
if [ -f $lockfile ] ; then
rm -rf $lockfile
fi
sleep 1
rm -rf ${pidfile}
echo "[ OK ]"
else
echo "$prog stopped"
fi
return 0
}
configtest() {
if [ "$#" -ne 0 ] ; then
case "$1" in
-q)
FLAG=$1
;;
*)
;;
esac
shift
fi
${nginx} -t -c ${conffile} $FLAG
RETVAL=$?
return $RETVAL
}
status(){
if [ ! -f $pidfile ] ; then
echo "$prog stopped"
else
PID=`cat $pidfile`
echo "$prog (pid $PID) is running..."
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
configtest -q || exit $RETVAL
stop
start
;;
status)
status
;;
configtest)
configtest
;;
*)
echo "Usage: $0 {start|stop|restart|configtest|status}"
RETVAL=2
esac
exit $RETVAL