#/bin/sh

. /lib/lsb/init-functions

DAEMON=/usr/sbin/nginx
PIDFILE=/var/run/nginx.pid

start() {
        log_info_msg "Starting Nginx Server..."
        $DAEMON
        evaluate_retval
}

stop() {
       log_info_msg "Stopping Nginx Server..."
       $DAEMON -s quit
       evaluate_retval
}

reload() {
      log_info_msg "Reloading Nginx Server..."
      $DAEMON -s reload
      evaluate_retval
}

status() {
      pid=`pidof $DAEMON`
      if [ "$pid" ]; then
         echo "Nginx running on PID $pid"
      else
         echo "Nginx is not running"
      fi
}

case $1 in
         start)
                 start
                 ;;
         stop)
                 stop
                 ;;
         restart)
                 stop
                 start
                 ;;
         status)
                 status
                 ;;
         force-reload)
                 reload
                 ;;
         *)
                 echo "Syntax: $0 <start|stop|restart|status|force-reload>"
                 ;;
esac
