znc/znc.init
2011-08-13 17:34:31 -05:00

91 lines
1.5 KiB
Bash

#!/bin/sh
#
# znc - Advanced IRC Bouncer INIT script for Fedora #
# chkconfig: 35 99 14
# description: An Advanced IRC bouncer INIT script for
# Fedora-CentOS Variants
# Source function library.
. /etc/rc.d/init.d/functions
exec=/usr/bin/znc
prog=znc
config=/home/znc/.znc
runas=znc
lockfile=/var/lock/subsys/$prog
start() {
[ -x $exec ] || exit 5
echo -n $"Starting $prog: "
# if not running, start it up here, usually something like "daemon $exec"
daemon --user $runas "$exec -d $config >/dev/null 2>&1"
# If you're reckless with your system, comment the line above and
# uncomment this one below... I just don't get it why
# daemon "$exec -r -d $config >/dev/null 2>&1"
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
killproc $prog -TERM
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
reload() {
echo -n $"Reloading $prog: "
# stop it here, often "killproc $prog"
killproc $prog -HUP
retval=$?
echo
}
restart() {
stop
start
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart|try-restart}"
exit 2
esac
exit $?