Project

General

Profile

Actions

Init.d with LSB tags

#! /bin/sh
### BEGIN INIT INFO
# Provides:          lighttpd2
# 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 --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 --oknodo --pidfile $PIDFILE --retry 30
        rm -f $PIDFILE
        sleep 1
        start-stop-daemon --start --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

Updated by over 12 years ago · 3 revisions