]> git.pld-linux.org Git - packages/hylafax.git/blob - hylafax-init
missing patch
[packages/hylafax.git] / hylafax-init
1 #! /bin/sh
2 #
3 #  hylafax, v 1.2 2001/01/10 Christian Zoffoli <czoffoli@linux-mandrake.com>
4 #
5 # chkconfig: 12345 97 05
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
13 SPOOL=/var/spool/fax
14
15 # Source networking configuration.
16 . /etc/sysconfig/network
17
18 # Check that networking is up.
19 [ ${NETWORKING} = "no" ] && exit 0
20
21 # Source function library.
22 . /etc/rc.d/init.d/functions
23
24 checkvar() {
25         if [ ! "$1" ]; then
26                 echo -n -e "HylaFAX ERROR (old setup.cache) please run faxsetup -server\n"
27                 exit 1
28         fi
29
30         if [ $1 = "yes" -o  $1 = "1" ]; then
31                 return 0
32         fi
33         return 1
34 }
35
36 check_config()  {
37         test -f $SPOOL/etc/setup.cache || {
38                 cat<<-EOF
39
40                 HylaFAX FATAL ERROR: $SPOOL/etc/setup.cache is missing!
41
42                 The file $SPOOL/etc/setup.cache is not present.
43                 This probably means the machine has not been setup using the
44                 faxsetup(1M) command. Read the documentation on setting up
45                 HylaFAX before you startup a server system.
46
47                 EOF
48  
49                 return 1
50         }
51
52         # Loading Config
53         PATH_SAVE=$PATH
54         . $SPOOL/etc/setup.cache
55         PATH=$PATH_SAVE:$PATH
56
57         return 0
58 }
59
60 start() {
61         local RETVAL2=0
62
63         OPTS="-i hylafax"
64         if checkvar "$HFAXD_OLD_PROTOCOL"; then
65                 OPTS="$OPTS -o 4557"
66                 OUT=" OLD Protocol"
67         fi
68
69         if checkvar "$HFAXD_SNPP_SERVER"; then
70                 OPTS="$OPTS -s snpp"
71                 if [ "$OUT" ]; then
72                         OUT="$OUT - "
73                 fi
74                 OUT="$OUT SNPP"
75         fi
76
77         if [ "$OUT" ]; then
78                 OUT="( $OUT )"
79         fi
80
81         if checkvar "$FAXQ_SERVER"; then
82                 msg_starting "HylaFAX queue manager"
83                 daemon faxq
84                 RETVAL=$?
85         fi
86
87         if checkvar "$HFAXD_SERVER"; then
88                 msg="HylaFAX server"
89                 [ -n "$OUT" ] && msg="$msg $OUT"
90                 msg_starting "HylaFAX server"
91                 daemon hfaxd $OPTS
92                 RETVAL2=$?
93         fi
94
95         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/hylafax || RETVAL=1
96 }
97
98 stop() {
99         # stop can't return failure by LSB. so make these vars local
100         local RETVAL=0
101         local RETVAL2=0
102
103         msg_stopping "HylaFAX queue manager"
104         daemon /usr/sbin/faxquit
105         RETVAL=$?
106
107         msg_stopping "HylaFAX server"
108         killproc hfaxd
109         RETVAL2=$?
110
111         [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/hylafax
112 }
113
114 faxgettyreset() {
115         if pidofproc faxgetty > /dev/null; then
116                 msg_starting "FaxGetty restart process"
117                 killproc faxgetty
118                 msg_starting "FaxGetty restart process (init reload)"
119                 daemon init q
120         fi
121
122         return 0
123 }
124
125 restart() {
126         stop
127         start
128         faxgettyreset
129 }
130
131 hstatus() {
132         status hfaxd
133         RETVAL=$?
134         status faxq
135         return $(($RETVAL + $?))
136 }
137
138 check_config || exit 1
139
140 RETVAL=0
141 case "$1" in
142   start)
143         start
144         ;;
145   stop)
146         stop
147         ;;
148   restart|reload)
149         restart
150         ;;
151   status)
152         hstatus
153         exit $?
154         ;;
155   condrestart)
156         [ -f /var/lock/subsys/hylafax ] && restart
157         ;;
158   faxgettyreset)
159         faxgettyreset
160         ;;
161   *)
162         echo "Usage: $0 { start | stop | status | restart | condrestart | faxgettyreset }"
163         exit 1
164         ;;
165 esac
166
167 exit 0
This page took 0.105896 seconds and 4 git commands to generate.