]> arthur.barton.de Git - ngircd-alex.git/blob - debian/ngircd.init
2736d18243336f409c60e4109d967d3dd4560317
[ngircd-alex.git] / debian / ngircd.init
1 #!/bin/sh
2 #
3 # ngIRCd start and stop script for Debian-based systems
4 #
5 # $Id: ngircd.init,v 1.2 2003/07/12 23:27:37 alex Exp $
6 #
7
8 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
9 DAEMON=/usr/sbin/ngircd
10 NAME=ngIRCd
11 DESC="IRC daemon"
12 PARAMS=""
13
14 test -x $DAEMON || exit 0
15
16 test -f /etc/default/ngircd && . /etc/default/ngircd
17
18 Check_Config()
19 {
20         $DAEMON --configtest >/dev/null 2>&1
21         if [ $? -ne 0 ]; then
22                 echo "Configuration of $NAME is not valide, won't (re)start!"
23                 echo "Please run \"$DAEMON --configtest\" manually and fix it up ..."
24                 exit 1
25         fi
26 }
27
28 Try_Start()
29 {
30         start-stop-daemon --start --quiet --exec $DAEMON -- $PARAMS
31         if [ $? -ne 0 ]; then
32                 echo "$NAME failed!"
33                 exit 1
34         fi
35         echo "$NAME."
36 }
37
38 case "$1" in
39   start)
40         Check_Config
41         echo -n "Starting $DESC: "
42         Try_Start
43         ;;
44   stop)
45         echo -n "Stopping $DESC: "
46         start-stop-daemon --stop --quiet --exec $DAEMON \
47           && echo "$NAME." \
48           || echo "(none running)"
49         ;;
50   reload|force-reload)
51         Check_Config
52         echo "Reloading $DESC configuration files."
53         start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
54         ;;
55   restart)
56         Check_Config
57         echo -n "Restarting $DESC: "
58         start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
59         sleep 1
60         Try_Start
61         ;;
62   *)
63         N=/etc/init.d/$NAME
64         echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
65         exit 1
66         ;;
67 esac
68
69 exit 0
70
71 # -eof-