hylafax.in
上传用户:weiyuanprp
上传日期:2020-05-20
资源大小:1169k
文件大小:5k
源码类别:

传真(Fax)编程

开发平台:

C/C++

  1. #! @SCRIPT_SH@
  2. # $Id: hylafax.in,v 1.6 2008/02/11 18:53:33 faxguy Exp $
  3. #
  4. # chkconfig: 2345 97 05
  5. #
  6. # description: HylaFAX(tm) is a sophisticated enterprise-strength fax
  7. #              package for class 1 and 2 fax modems on unix systems.
  8. #              This init script is the preferred way to start HylaFAX,
  9. #              but does not, by default, activate any modems. Consult
  10. #              the faxgetty(8) and faxmodem(8) man pages for more info.
  11. #
  12. # @WARNING@
  13. #
  14. # HylaFAX Facsimile Software
  15. #
  16. # Copyright (c) 1990-1996 Sam Leffler
  17. # Copyright (c) 1991-1996 Silicon Graphics, Inc.
  18. # HylaFAX is a trademark of Silicon Graphics
  19. # Permission to use, copy, modify, distribute, and sell this software and 
  20. # its documentation for any purpose is hereby granted without fee, provided
  21. # that (i) the above copyright notices and this permission notice appear in
  22. # all copies of the software and related documentation, and (ii) the names of
  23. # Sam Leffler and Silicon Graphics may not be used in any advertising or
  24. # publicity relating to the software without the specific, prior written
  25. # permission of Sam Leffler and Silicon Graphics.
  26. # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  27. # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  28. # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  29. # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  30. # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  31. # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  32. # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  33. # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  34. # OF THIS SOFTWARE.
  35. #
  36. # VERSION: @VERSION@
  37. # DATE: @DATE@
  38. # TARGET: @TARGET@
  39. #
  40. #
  41. # fax server control
  42. #
  43. # NB: This script assumes faxgetty processes are managed by init
  44. #
  45. SPOOL=@SPOOL@
  46. test -f $SPOOL/etc/setup.cache || {
  47.     cat<<EOF
  48. FATAL ERROR: $SPOOL/etc/setup.cache is missing!
  49. The file $SPOOL/etc/setup.cache is not present.  This
  50. probably means the machine has not been setup using the faxsetup(@MANNUM1_8@)
  51. command.  Read the documentation on setting up HylaFAX before you
  52. startup a server system.
  53. EOF
  54.     exit 1
  55. }
  56. . $SPOOL/etc/setup.cache
  57. # Just in case these are not in setup.cache yet
  58. if [ -z "$HFAXD_SERVER" ]; then
  59.     HFAXD_SERVER=@HFAXD_SERVER@
  60. fi
  61. if [ -z "$FAXQ_SERVER" ]; then
  62.     FAXQ_SERVER=@FAXQ_SERVER@
  63. fi
  64. if [ -z "$HFAXD_SNPP_SERVER" ]; then
  65.     HFAXD_SNPP_SERVER=@HFAXD_SNPP_SERVER@
  66. fi
  67. IS_ON=/etc/chkconfig # NB: chkconfig is IRIX- and Linux-specific
  68. FAXQ=$SBIN/faxq
  69. HFAXD=$LIBEXEC/hfaxd
  70. FAXQUIT=$SBIN/faxquit
  71. FAXPORT=hylafax # designated port for new protocol
  72. SNPPPORT=444 # official port for SNPP
  73. if test ! -x $IS_ON ; then
  74.     IS_ON=true
  75. fi
  76. if $IS_ON verbose ; then
  77.     ECHO=echo
  78. else # For a quiet startup and shutdown
  79.     ECHO=:
  80. fi
  81. #
  82. # Figure out which brand of echo we have and define prompt
  83. # and printf shell functions accordingly.  Note that we
  84. # assume that if the System V-style echo is not present,
  85. # then the BSD printf program is available.  These functions
  86. # are defined here so that they can be tailored on a per-site,
  87. # etc. basis.
  88. #
  89. if [ `echo foo\c`@ = "foo@" ]; then
  90.     # System V-style echo supports r
  91.     # and c which is all that we need
  92.     printf()
  93.     {
  94.        $ECHO "$*\c"
  95.     }
  96. elif [ "`echo -n foo`@" = "foo@" ]; then
  97.     # BSD-style echo; use echo -n to get
  98.     # a line without the trailing newline
  99.     printf()
  100.     {
  101.        $ECHO -n "$*"
  102.     }
  103. else
  104.     # something else; do without
  105.     printf()
  106.     {
  107. $ECHO "$*"
  108.     }
  109. fi
  110. #
  111. #
  112. # killall -SIGNAL process-name
  113. #
  114. # Emulate the necessary functionality of the
  115. # killall program
  116. #
  117. killall()
  118. {
  119. # NB: ps ax should give an error on System V, so we try it first!
  120. pid="`ps ax 2>/dev/null | $AWK "
  121. /[/ (]$2[ )]/ {print \$1;}
  122. /[/ ]$2$/ {print \$1;}"`"
  123. test "$pid" ||
  124.     pid="`ps -e 2>/dev/null | $AWK "/ $2[ ]*$/ {print \$1;}"`"
  125. test "$pid" && kill $1 $pid; return
  126. }
  127. do_start()
  128. {
  129. if $IS_ON fax && test -x $FAXQ; then
  130.     if test $FAXQ_SERVER = yes ; then
  131. killall -15 faxq
  132.     fi
  133.     if test $HFAXD_SERVER = yes ; then
  134. killall -15 hfaxd
  135.     fi
  136.     printf "HylaFAX:"
  137.             if test $FAXQ_SERVER = yes ; then
  138.         $FAXQ; printf " faxq"
  139.             fi
  140.             if test $HFAXD_SERVER = yes ; then
  141.         HFAXD="$HFAXD -i $FAXPORT"
  142. HFAXMSG=" hfaxd"
  143. if [ $HFAXD_SNPP_SERVER = yes ]; then
  144.          HFAXD="$HFAXD -s $SNPPPORT"
  145.     HFAXMSG="$HFAXMSG (with SNPP support)"
  146. else
  147.     HFAXMSG="$HFAXMSG (without SNPP support)"
  148. fi
  149. $HFAXD ; printf "$HFAXMSG"
  150.             fi
  151.     if test $FAXQ_SERVER != yes && test $HFAXD_SERVER != yes ; then
  152. printf " not started (script disabled by configure)"
  153.     fi
  154.     $ECHO "."
  155. fi
  156. }
  157. do_stop ()
  158. {
  159.     $ECHO "Stopping HylaFAX Servers."
  160.     $FAXQUIT >/dev/null 2>&1
  161.     killall -15 hfaxd
  162. }
  163. case $1 in
  164. 'start')
  165. do_start
  166. ;;
  167. 'stop')
  168. do_stop
  169. ;;
  170. 'restart')
  171. do_stop
  172. sleep 2 #wait some time...
  173. do_start
  174. ;;
  175. 'start_msg')
  176. $ECHO "Starting HylaFAX Servers."
  177. ;;
  178. 'stop_msg')
  179. $ECHO "Stopping HylaFAX Servers."
  180. ;;
  181. *)
  182. $ECHO "usage: hylafax {start|stop|restart|start_msg|stop_msg}"
  183. ;;
  184. esac