ngircd-tor/contrib/Debian/ngircd.init

108 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
#
# ngIRCd start and stop script for Debian-based systems
# Copyright 2008 Alexander Barton <alex@barton.de>
#
### BEGIN INIT INFO
# Provides: ircd
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Next Generation IRC Server
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/ngircd
NAME=ngIRCd
DESC="IRC daemon"
PARAMS=""
test -h "$0" && me=`readlink $0` || me="$0"
BASENAME=`basename $me`
test -r /etc/default/$BASENAME && . /etc/default/$BASENAME
test -x $DAEMON || exit 0
# LSB compatibility functions that become used if there is no local
# include file available.
log_daemon_msg() {
echo -n "$*"
}
log_end_msg() {
[ "$1" == "0" ] && echo "." || echo " failed!"
}
log_failure_msg() {
echo "$*"
}
# Include LSB functions, if available:
test -r /lib/lsb/init-functions && . /lib/lsb/init-functions
Check_Config()
{
# Make sure that the configuration of ngIRCd is valid:
$DAEMON --configtest >/dev/null 2>&1
if [ $? -ne 0 ]; then
log_failure_msg "Configuration of $NAME is not valid, won't (re)start!"
log_failure_msg "Run \"$DAEMON --configtest\" and fix it up ..."
exit 1
fi
# Make sure the PID file directory exists and is writable:
if [ ! -d /var/run/ircd ]; then
mkdir -p /var/run/ircd
fi
chown irc:irc /var/run/ircd
}
case "$1" in
start)
Check_Config
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start \
--quiet --exec $DAEMON -- $PARAMS
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
[ -r /var/run/ircd/ngircd.pid ] \
&& PIDFILE="--pidfile /var/run/ircd/ngircd.pid" \
|| PIDFILE=""
start-stop-daemon --stop \
--quiet --oknodo --exec $DAEMON $PIDFILE
log_end_msg $?
;;
reload|force-reload)
Check_Config
log_daemon_msg "Reloading $DESC" "$NAME"
start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
log_end_msg $?
;;
restart)
Check_Config
log_daemon_msg "Restarting $DESC" "$NAME"
[ -r /var/run/ircd/ngircd.pid ] \
&& PIDFILE="--pidfile /var/run/ircd/ngircd.pid" \
|| PIDFILE=""
start-stop-daemon --stop \
--quiet --oknodo --exec $DAEMON $PIDFILE
sleep 1
start-stop-daemon --start \
--quiet --exec $DAEMON -- $PARAMS
log_end_msg $?
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
# -eof-