#!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-misc/hylafax/files/hylafax-4.2,v 1.1 2004/08/10 04:15:54 nerdboy Exp $ depend() { use net } checkconfig() { SPOOL=/var/spool/fax if [ ! -f $SPOOL/etc/setup.cache ] ; then eerror "No $SPOOL/etc/setup.cache file exists! Use faxsetup(8C) !" fi } start() { ebegin "Starting HylaFAX Servers." SPOOL=/var/spool/fax checkconfig || return 1 . $SPOOL/etc/setup.cache # Just in case these are not in setup.cache yet if [ -z "$HFAXD_SERVER" ]; then HFAXD_SERVER=yes fi if [ -z "$FAXQ_SERVER" ]; then FAXQ_SERVER=yes fi if [ -z "$HFAXD_OLD_PROTOCOL" ]; then HFAXD_OLD_PROTOCOL=no fi if [ -z "$HFAXD_SNPP_SERVER" ]; then HFAXD_SNPP_SERVER=no fi IS_ON=/etc/chkconfig # NB: chkconfig is IRIX- and Linux-specific FAXQ=$SBIN/faxq HFAXD=$LIBEXEC/hfaxd FAXQUIT=$SBIN/faxquit FAXPORT=hylafax # designated port for new protocol SNPPPORT=444 # official port for SNPP if test ! -x $IS_ON ; then IS_ON=true fi if $IS_ON verbose ; then ECHO=echo else # For a quiet startup and shutdown ECHO=: fi # # Figure out which brand of echo we have and define prompt # and printf shell functions accordingly. Note that we # assume that if the System V-style echo is not present, # then the BSD printf program is available. These functions # are defined here so that they can be tailored on a per-site, # etc. basis. # if [ `echo foo\\\c`@ = "foo@" ]; then # System V-style echo supports \r # and \c which is all that we need printf() { $ECHO "$*\\c" } elif [ "`echo -n foo`@" = "foo@" ]; then # BSD-style echo; use echo -n to get # a line without the trailing newline printf() { $ECHO -n "$*" } else # something else; do without printf() { $ECHO "$*" } fi # # # killall -SIGNAL process-name # # Emulate the necessary functionality of the # killall program # killall() { # NB: ps ax should give an error on System V, so we try it first! pid="`ps ax 2>/dev/null | $AWK \"\ /[\/ (]$2[ )]/ {print \\$1;} /[\/ ]$2\$/ {print \\$1;}\"`" test "$pid" || pid="`ps -e 2>/dev/null | $AWK \"/ $2[ ]*\$/ {print \\$1;}\"`" test "$pid" && kill $1 $pid; return } if $IS_ON fax && test -x $FAXQ; then if test $FAXQ_SERVER = yes ; then killall -15 faxq fi if test $HFAXD_SERVER = yes ; then killall -15 hfaxd fi printf "HylaFAX:" if test $FAXQ_SERVER = yes ; then $FAXQ; printf " faxq " fi if test $HFAXD_SERVER = yes ; then HFAXD_OPT="-i $FAXPORT" # HFAXD="$HFAXD -i $FAXPORT" HFAXMSG=" hfaxd" if [ $HFAXD_OLD_PROTOCOL = yes ]; then HFAXD_OPT="$HFAXD_OPT -o 4557" # HFAXD="$HFAXD -o 4557" HFAXMSG="$HFAXMSG (with old protocol" else HFAXMSG="$HFAXMSG (without old protocol" fi if [ $HFAXD_SNPP_SERVER = yes ]; then HFAXD_OPT="$HFAXD_OPT -s $SNPPPORT" # HFAXD="$HFAXD -s $SNPPPORT" HFAXMSG="$HFAXMSG & with SNPP support)" else HFAXMSG="$HFAXMSG & without SNPP support)" fi # $HFAXD ; printf "$HFAXMSG\n" echo $HFAXMSG echo $HFAXD $HFAXD_OPT /sbin/start-stop-daemon --start --quiet --exec $HFAXD -- $HFAXD_OPT fi if test $FAXQ_SERVER != yes -a $HFAXD_SERVER != yes ; then printf " not started (script disabled by configure)\n" fi $ECHO "." fi eend $? } stop() { ebegin "Stopping HylaFAX Servers." checkconfig || return 2 . $SPOOL/etc/setup.cache FAXQUIT=$SBIN/faxquit HFAXD=$LIBEXEC/hfaxd # $ECHO "Stopping HylaFAX Servers." $FAXQUIT >/dev/null 2>&1 /sbin/start-stop-daemon --stop --quiet --exec $HFAXD eend $? # killall -15 hfaxd }