Project

General

Profile

InitScriptDebian » History » Revision 2

Revision 1 (Anonymous, 2011-04-11 19:07) → Revision 2/3 (Anonymous, 2011-04-12 13:03)

h1. Init.d with LSB tags 

 <pre> 
 #! /bin/sh 
 ### BEGIN INIT INFO 
 # Provides:            lighttpd2 lighttpd 
 # Required-Start:      $all 
 # Required-Stop:       $all 
 # Default-Start:       2 3 4 5 
 # Default-Stop:        0 1 6 
 # Short-Description: Lighttpd2 init script 
 # Description:         Starts lighttpd2 web server 
 ### END INIT INFO 

 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 
 NAME=lighttpd2 
 DESC=lighttpd2 
 PIDFILE=/var/run/$NAME.pid 
 DAEMON=/usr/sbin/lighttpd2/lighttpd2 
 DAEMON_OPTS="--config /etc/lighttpd2/angel.conf" 

 test -x $DAEMON || exit 0 

 set -e 

 case "$1" in 
     start) 
         echo -n "Starting $DESC: " 
         start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS 
         echo "$NAME." 
         ;; 
     stop) 
         echo -n "Stopping $DESC: " 
         start-stop-daemon --stop --quiet --oknodo --exec $DAEMON 
         echo "$NAME." 
         rm -f $PIDFILE 
         ;; 

     restart|force-reload) 
     # 
     #     If the "reload" option is implemented, move the "force-reload" 
     #     option to the "reload" entry above. If not, "force-reload" is 
     #     just the same as "restart". 
     # 
         echo -n "Restarting $DESC: " 
         start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --retry 30 --exec $DAEMON 
         rm -f $PIDFILE 
         sleep 1 
         start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS 
         echo "$NAME." 
         ;; 
     *) 
         N=/etc/init.d/$NAME 
     # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 
         echo "Usage: $N {start|stop|restart|force-reload}" >&2 
         exit 1 
         ;; 
 esac 

 exit 0 
 </pre>