1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
#!/bin/sh
NAME="inspircd"
IRCD="/usr/sbin/inspircd"
IRCDPID="/var/run/inspircd.pid"
IRCDLOG="/var/log/inspircd.log"
IRCDCONF="/etc/inspircd/inspircd.conf"
IRCDARGS="--logfile $IRCDLOG --config $IRCDCONF"
USER="irc"
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
if [ -f "/etc/default/inspircd" ]; then
. /etc/default/inspircd
fi
. /lib/lsb/init-functions
if [ ! -x "$IRCD" ]; then exit 0; fi
if [ -f "$IRCDPID" ]; then
IRCDPIDN=`cat "$IRCDPID" 2> /dev/null`
fi
start_ircd()
{
[ -f "$IRCDPID" ] || ( touch "$IRCDPID" ; chown "$USER" "$IRCDPID" )
[ -f "$IRCDLOG" ] || ( touch "$IRCDLOG" ; chown "$USER:adm" "$IRCDLOG" ; chmod 0640 "$IRCDLOG" )
export LD_LIBRARY_PATH=/usr/lib/inspircd
start-stop-daemon --start --quiet --oknodo --chuid "$USER" --pidfile "$IRCDPID" --exec "$IRCD" -- $IRCDARGS start > /dev/null
}
stop_ircd()
{
start-stop-daemon --stop --quiet --pidfile "$IRCDPID" > /dev/null 2> /dev/null
rm -f "$IRCDPID"
return 0
}
reload_ircd()
{
if [ ! -z "$IRCDPIDN" ] && kill -0 $IRCDPIDN 2> /dev/null; then
kill -HUP $IRCDPIDN >/dev/null 2>&1 || return 1
return 0
else
echo "Error: IRCD is not running."
return 1
fi
}
case "$1" in
start)
if [ "$INSPIRCD_ENABLED" != "1" ]; then
echo -n "Please configure inspircd first and edit /etc/default/inspircd, otherwise inspircd won't start"
exit 0
fi
echo -n "Starting Inspircd... "
start_ircd && echo "done."
;;
stop)
echo -n "Stopping Inspircd... "
stop_ircd && echo "done."
;;
status)
status_of_proc "$IRCD" "$NAME" && exit 0 || exit $?
;;
force-reload|reload)
echo -n "Reloading Inspircd... "
reload_ircd && echo "done."
;;
restart)
$0 stop
sleep 2
$0 start
;;
cron)
start_ircd || echo "Inspircd not running, starting it"
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|cron}"
exit 1
esac
|