#!/bin/sh ### BEGIN INIT INFO # Provides: hylafax # Required-Start: $local_fs $network $remote_fs # Should-Start: iaxmodem # Required-Stop: $local_fs $network $remote_fs # Default-Start: # Default-Stop: 0 1 6 # Short-Description: HylaFAX fax server # 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. ### END INIT INFO # Source function library. . /etc/init.d/functions SPOOL=/var/spool/fax LOCKFILE="/var/lock/subsys/hylafax" 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: " start_daemon --lockfile "$LOCKFILE" 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 start_daemon --lockfile "$LOCKFILE" hfaxd $OPTS RETVAL2=$? echo else echo -n "HylaFAX server not started. " fi [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch "$LOCKFILE" || 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: " stop_daemon hfaxd RETVAL2=$? echo [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f "$LOCKFILE" || RETVAL=1 return $RETVAL } faxgettyreset() { if pidofproc faxgetty > /dev/null then if killall 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) restart ;; status) status ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; condrestart) if [ -e "$LOCKFILE" ]; then restart fi ;; faxgettyreset) faxgettyreset ;; *) echo "Usage: ${0##*/} {start|stop|reload|restart|condstop|condrestart|adjust|status}" RETVAL=1 esac exit $RETVAL