Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-release > by-pkgid > 0d9b1828e17177ecdfb41a2fe989b3c9 > files > 4

hylafax-server-5.5.0-1.mga1.i586.rpm

#! /bin/sh
#
# 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. 
#
#
# Created by Christian Zoffoli <czoffoli@linux-mandrake.com>
# Version 1.3  2002-02-26
#


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
		gprintf "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.

		Please run /usr/sbin/faxsetup -server to configure your fax server
 
		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
		gprintf "Starting %s: " "HylaFAX queue manager"
		daemon faxq
		RETVAL=$?
		echo
	else
		gprintf "HylaFAX queue manager not started. "
	fi

	if checkvar $HFAXD_SERVER 
	then 
		gprintf "Starting %s: " "HylaFAX server"
		echo -n $OUT
		daemon hfaxd $OPTS
		RETVAL2=$?
		echo
	else
		gprintf "HylaFAX server not started. "
	fi

	[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/hylafax-server ||  RETVAL=1

        return $RETVAL
}

stop() {
	local RETVAL=0
	local RETVAL2=0

	gprintf "Stopping %s: " "HylaFAX queue manager" 
	/usr/sbin/faxquit >/dev/null 2>&1
	RETVAL=$?
	echo

	gprintf "Stopping %s: " "HylaFAX server"

	killproc hfaxd
	RETVAL2=$?
	echo
	
	[ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/hylafax-server || RETVAL=1
	return $RETVAL
}

faxgettyreset() {
	if pidofproc faxgetty > /dev/null
	then
		if killproc faxgetty
		then
			gprintf "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-server ] && restart
	;;
  faxgettyreset)
	faxgettyreset
	;;
  *)
	gprintf "Usage: %s { start | stop | status | restart | condrestart | faxgettyreset }\n" "$0"
	exit 1
	;;
esac

exit 0