#!/bin/sh # # cr Conference Room IRC Daemon # # chkconfig: 345 56 44 # # description: Conference Room is a IRC Daemon # # $Id$ # Source function library . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network SERVICES="cr ws sv" # Get service config - may override defaults [ -f /etc/sysconfig/cr ] && . /etc/sysconfig/cr # Check that networking is up. if is_yes "${NETWORKING}"; then if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then msg_network_down cr exit 1 fi else exit 0 fi start() { # Check if the service is already running? if [ ! -f /var/lock/subsys/cr ]; then msg_starting "Conference Room IRC Daemon"; busy start-stop-daemon --start \ --chdir /var/lib/cr \ --exec /usr/lib/cr/programs/launcher \ --chuid ircd \ -- /var/lib/cr $SERVICES RETVAL=$? if [ $RETVAL -eq 0 ]; then # write proper pidfile as it itself probably writes parent pid which is no longer there pidfile=/var/lib/cr/CRServices.pid pid=$(ps -o pid= -C ConfRoom | head -n1) [ "$pid" ] && echo "$pid" > $pidfile ok touch /var/lock/subsys/cr else fail fi else msg_already_running "Conference Room IRC Daemon" fi } stop() { if [ -f /var/lock/subsys/cr ]; then # Stop daemons. msg_stopping "Conference Room IRC Daemon" start-stop-daemon --stop --oknodo --pidfile /var/lib/cr/CRServices.pid && ok || fail rm -f /var/lock/subsys/cr else msg_not_running "Conference Room IRC Daemon" fi } condrestart() { if [ -f /var/lock/subsys/cr ]; then stop start else msg_not_running "Conference Room IRC Daemon" RETVAL=$1 fi } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) stop start ;; try-restart) condrestart 0 ;; force-reload) condrestart 7 ;; status) status --pidfile /var/lib/cr/CRServices.pid cr ConfRoom RETVAL=$? ;; *) msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" exit 3 esac exit $RETVAL