]> arthur.barton.de Git - ngircd-alex.git/blob - contrib/Debian/ngircd.init
Added LSB compliant header.
[ngircd-alex.git] / contrib / Debian / ngircd.init
1 #!/bin/sh
2 #
3 # ngIRCd start and stop script for Debian-based systems
4 #
5 # $Id: ngircd.init,v 1.7 2006/12/26 14:43:46 alex Exp $
6 #
7
8 ### BEGIN INIT INFO
9 # Provides:             ircd
10 # Required-Start:       $local_fs
11 # Required-Stop:        $local_fs
12 # Should-Start:         $syslog $network
13 # Should-Stop:          $syslog $network
14 # Default-Start:        2 3 4 5
15 # Default-Stop:         0 1 6
16 # Short-Description:    Next Generation IRC Server
17 ### END INIT INFO
18
19 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
20 DAEMON=/usr/sbin/ngircd
21 NAME=ngIRCd
22 DESC="IRC daemon"
23 PARAMS=""
24
25 test -h "$0" && me=`readlink $0` || me="$0"
26 BASENAME=`basename $me`
27
28 test -f /etc/default/$BASENAME && . /etc/default/$BASENAME
29
30 test -x $DAEMON || exit 0
31
32 Check_Config()
33 {
34         $DAEMON --configtest >/dev/null 2>&1
35         if [ $? -ne 0 ]; then
36                 echo "Configuration of $NAME is not valide, won't (re)start!"
37                 echo "Please run \"$DAEMON --configtest\" manually and fix it up ..."
38                 exit 1
39         fi
40 }
41
42 Try_Start()
43 {
44         [ ! -d /var/run/ircd ] || chown irc:irc /var/run/ircd
45         start-stop-daemon --start --quiet --exec $DAEMON -- $PARAMS
46         if [ $? -ne 0 ]; then
47                 echo "$NAME failed!"
48                 exit 1
49         fi
50         echo "$NAME."
51 }
52
53 case "$1" in
54   start)
55         Check_Config
56         echo -n "Starting $DESC: "
57         Try_Start
58         ;;
59   stop)
60         echo -n "Stopping $DESC: "
61         start-stop-daemon --stop --quiet --pidfile /var/run/ircd/ngircd.pid --exec $DAEMON \
62           && echo "$NAME." \
63           || echo "(none running)"
64         ;;
65   reload|force-reload)
66         Check_Config
67         echo "Reloading $DESC configuration files."
68         start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
69         ;;
70   restart)
71         Check_Config
72         echo -n "Restarting $DESC: "
73         start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
74         sleep 1
75         Try_Start
76         ;;
77   *)
78         N=/etc/init.d/$NAME
79         echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
80         exit 1
81         ;;
82 esac
83
84 exit 0
85
86 # -eof-