#! /bin/sh # # hylafax, v 1.2 2001/01/10 Christian Zoffoli # # chkconfig: 12345 97 05 # description: HylaFAX(tm) is a sophisticated enterprise-strength fax \ # package for class 1 and 2 fax modems on unix systems. \ # This init script is the preferred way to start HylaFAX,\ # but does not, by default, activate any modems. Consult \ # the faxgetty(8) and faxmodem(8) man pages for more info. # SPOOL=/var/spool/fax # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 0 fi checkvar() { if [ ! $1 ]; then echo -n -e "HylaFAX ERROR (old setup.cache) please run faxsetup -server\n" exit 1 fi if [ $1 = "yes" -o $1 = "1" ]; then return 0 fi return 1 } check_config() { test -f $SPOOL/etc/setup.cache || { cat<<-EOF HylaFAX FATAL ERROR: $SPOOL/etc/setup.cache is missing! The file $SPOOL/etc/setup.cache is not present. This probably means the machine has not been setup using the faxsetup(1M) command. Read the documentation on setting up HylaFAX before you startup a server system. EOF return 1 } # Loading Config PATH_SAVE=$PATH . $SPOOL/etc/setup.cache PATH=$PATH_SAVE:$PATH return 0 } start() { local RETVAL=0 local RETVAL2=0 OPTS="-i hylafax" if checkvar $HFAXD_OLD_PROTOCOL then OPTS="$OPTS -o 4557" OUT=" OLD Protocol" fi if checkvar $HFAXD_SNPP_SERVER then OPTS="$OPTS -s snpp" if [ "$OUT" != "" ]; then OUT="$OUT - " fi OUT="$OUT SNPP" fi if [ $OUT ]; then OUT="( $OUT )" fi if checkvar $FAXQ_SERVER then echo -n "Starting HylaFAX queue manager: " daemon faxq RETVAL=$? echo else echo -n "HylaFAX queue manager not started. " fi if checkvar $HFAXD_SERVER then echo -n "Starting HylaFAX server: " echo -n $OUT daemon hfaxd $OPTS RETVAL2=$? echo else echo -n "HylaFAX server not started. " fi [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/hylafax || RETVAL=1 return $RETVAL } stop() { local RETVAL=0 local RETVAL2=0 echo -n "Shutting down HylaFAX queue manager: " /usr/sbin/faxquit >/dev/null 2>&1 RETVAL=$? echo echo -n "Shutting down HylaFAX server: " killproc hfaxd RETVAL2=$? echo [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/hylafax || RETVAL=1 return $RETVAL } faxgettyreset() { if pidofproc faxgetty > /dev/null then if killproc faxgetty then echo -n -e "Restarting FaxGetty...\n" fi init q fi return 0 } restart() { stop start faxgettyreset } status() { status hfaxd status faxq } check_config || exit 1 case "$1" in start) start ;; stop) stop ;; restart|reload) restart ;; status) status ;; condrestart) [ -f /var/lock/subsys/hylafax ] && restart ;; faxgettyreset) faxgettyreset ;; *) echo "Usage: $0 { start | stop | status | restart | condrestart | faxgettyreset }" exit 1 ;; esac exit 0