3 # ngIRCd start and stop script for Debian-based systems
4 # Copyright 2008-2010 Alexander Barton <alex@barton.de>
9 # Required-Start: $network $remote_fs
10 # Required-Stop: $network $remote_fs
11 # Should-Start: $syslog $named
12 # Should-Stop: $syslog
13 # Default-Start: 2 3 4 5
15 # Short-Description: Next Generation IRC Server
16 # Description: IRC daemon written from scratch
19 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
20 DAEMON=/usr/sbin/ngircd
27 test -x $DAEMON || exit 5
29 test -h "$0" && me=`readlink $0` || me="$0"
30 BASENAME=`basename $me`
32 test -r /etc/default/$BASENAME && . /etc/default/$BASENAME
34 # LSB compatibility functions that become used if there is no local
35 # include file available.
40 [ "$1" == "0" ] && echo "." || echo " failed!"
49 # Include LSB functions, if available:
50 test -r /lib/lsb/init-functions && . /lib/lsb/init-functions
52 PIDFILE=`$DAEMON $PARAMS -t | tr -d ' ' | grep "^PidFile=" | cut -d'=' -f2`
53 [ -n "$PIDFILE" ] || PIDFILE="/var/run/ircd/ngircd.pid"
59 # Make sure that the configuration of ngIRCd is valid:
60 $DAEMON $PARAMS --configtest >/dev/null 2>&1
61 [ $? -eq 0 ] && return 0
63 log_failure_msg "Configuration of $NAME is not valid, won't (re)start!"
64 log_failure_msg "Run \"$DAEMON --configtest\" and fix it up ..."
69 # Make sure the PID file directory exists and is writable:
70 user=`$DAEMON $PARAMS -t|tr -d ' '|grep "^ServerUID="|cut -d'=' -f2`
71 group=`$DAEMON $PARAMS -t|tr -d ' '|grep "^ServerGID="|cut -d'=' -f2`
72 piddir=`dirname "$PIDFILE"`
73 [ -d "$piddir" ] || mkdir -p "$piddir" 2>/dev/null
74 chown "$user:$group" "$piddir" 2>/dev/null
75 [ $? -eq 0 ] && return 0
77 log_failure_msg "Failed to prepare '$piddir' for user '$user'!"
84 log_warning_msg "$NAME seems to be already running, nothing to do."
87 start-stop-daemon --start \
88 --quiet --exec $DAEMON -- $PARAMS
97 log_warning_msg "$NAME seems not to be running, nothing to do."
106 && pidfile="--pidfile $PIDFILE" \
108 start-stop-daemon --stop \
109 --quiet --oknodo --exec $DAEMON $pidfile
110 for i in `seq 1 $DIETIME`; do
111 Do_Status || return 0
118 start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
124 && pidfile="--pidfile $PIDFILE" \
126 start-stop-daemon --stop \
127 --quiet --signal 0 --exec $DAEMON $pidfile >/dev/null
133 log_daemon_msg "Starting $DESC" "$NAME"
140 log_daemon_msg "Stopping $DESC" "$NAME"
145 log_daemon_msg "Reloading $DESC" "$NAME"
151 log_daemon_msg "Restarting $DESC" "$NAME"
159 log_daemon_msg "Checking for $DESC" "$NAME"
165 echo "Configuration of $DAEMON seems to be ok."; r=0
168 N=/etc/init.d/$NAME; r=2
169 echo "Usage: $N {start|stop|restart|reload|force-reload|status|test}" >&2