]>
Commit | Line | Data |
---|---|---|
ec4247b5 TO |
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 | if [ -f /etc/init.d/functions ] ; then | |
23 | . /etc/init.d/functions | |
24 | elif [ -f /etc/rc.d/init.d/functions ] ; then | |
25 | . /etc/rc.d/init.d/functions | |
26 | else | |
27 | exit 0 | |
28 | fi | |
29 | ||
30 | checkvar() { | |
31 | if [ ! $1 ]; then | |
32 | echo -n -e "HylaFAX ERROR (old setup.cache) please run faxsetup -server\n" | |
33 | exit 1 | |
34 | fi | |
35 | ||
36 | if [ $1 = "yes" -o $1 = "1" ]; then | |
37 | return 0 | |
38 | fi | |
39 | return 1 | |
40 | } | |
41 | ||
42 | check_config() { | |
43 | test -f $SPOOL/etc/setup.cache || { | |
44 | cat<<-EOF | |
45 | ||
46 | HylaFAX FATAL ERROR: $SPOOL/etc/setup.cache is missing! | |
47 | ||
48 | The file $SPOOL/etc/setup.cache is not present. | |
49 | This probably means the machine has not been setup using the | |
50 | faxsetup(1M) command. Read the documentation on setting up | |
51 | HylaFAX before you startup a server system. | |
52 | ||
53 | EOF | |
54 | ||
55 | return 1 | |
56 | } | |
57 | ||
58 | # Loading Config | |
59 | PATH_SAVE=$PATH | |
60 | . $SPOOL/etc/setup.cache | |
61 | PATH=$PATH_SAVE:$PATH | |
62 | ||
63 | return 0 | |
64 | } | |
65 | ||
66 | start() { | |
67 | local RETVAL=0 | |
68 | local RETVAL2=0 | |
69 | ||
70 | OPTS="-i hylafax" | |
71 | if checkvar $HFAXD_OLD_PROTOCOL | |
72 | then | |
73 | OPTS="$OPTS -o 4557" | |
74 | OUT=" OLD Protocol" | |
75 | fi | |
76 | ||
77 | if checkvar $HFAXD_SNPP_SERVER | |
78 | then | |
79 | OPTS="$OPTS -s snpp" | |
80 | if [ "$OUT" != "" ]; then | |
81 | OUT="$OUT - " | |
82 | fi | |
83 | OUT="$OUT SNPP" | |
84 | fi | |
85 | ||
86 | if [ $OUT ]; then | |
87 | OUT="( $OUT )" | |
88 | fi | |
89 | ||
90 | ||
91 | if checkvar $FAXQ_SERVER | |
92 | then | |
93 | echo -n "Starting HylaFAX queue manager: " | |
94 | daemon faxq | |
95 | RETVAL=$? | |
96 | echo | |
97 | else | |
98 | echo -n "HylaFAX queue manager not started. " | |
99 | fi | |
100 | ||
101 | if checkvar $HFAXD_SERVER | |
102 | then | |
103 | echo -n "Starting HylaFAX server: " | |
104 | echo -n $OUT | |
105 | daemon hfaxd $OPTS | |
106 | RETVAL2=$? | |
107 | echo | |
108 | else | |
109 | echo -n "HylaFAX server not started. " | |
110 | fi | |
111 | ||
112 | [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && touch /var/lock/subsys/hylafax || RETVAL=1 | |
113 | ||
114 | return $RETVAL | |
115 | } | |
116 | ||
117 | stop() { | |
118 | local RETVAL=0 | |
119 | local RETVAL2=0 | |
120 | ||
121 | echo -n "Shutting down HylaFAX queue manager: " | |
122 | /usr/sbin/faxquit >/dev/null 2>&1 | |
123 | RETVAL=$? | |
124 | echo | |
125 | ||
126 | echo -n "Shutting down HylaFAX server: " | |
127 | killproc hfaxd | |
128 | RETVAL2=$? | |
129 | echo | |
130 | ||
131 | [ $RETVAL -eq 0 -a $RETVAL2 -eq 0 ] && rm -f /var/lock/subsys/hylafax || RETVAL=1 | |
132 | return $RETVAL | |
133 | } | |
134 | ||
135 | faxgettyreset() { | |
136 | if pidofproc faxgetty > /dev/null | |
137 | then | |
138 | if killproc faxgetty | |
139 | then | |
140 | echo -n -e "Restarting FaxGetty...\n" | |
141 | fi | |
142 | init q | |
143 | fi | |
144 | ||
145 | return 0 | |
146 | } | |
147 | ||
148 | restart() { | |
149 | stop | |
150 | start | |
151 | ||
152 | faxgettyreset | |
153 | } | |
154 | ||
155 | status() { | |
156 | status hfaxd | |
157 | status faxq | |
158 | } | |
159 | ||
160 | ||
161 | check_config || exit 1 | |
162 | ||
163 | case "$1" in | |
164 | start) | |
165 | start | |
166 | ;; | |
167 | stop) | |
168 | stop | |
169 | ;; | |
170 | restart|reload) | |
171 | restart | |
172 | ;; | |
173 | status) | |
174 | status | |
175 | ;; | |
176 | condrestart) | |
177 | [ -f /var/lock/subsys/hylafax ] && restart | |
178 | ;; | |
179 | faxgettyreset) | |
180 | faxgettyreset | |
181 | ;; | |
182 | *) | |
183 | echo "Usage: $0 { start | stop | status | restart | condrestart | faxgettyreset }" | |
184 | exit 1 | |
185 | ;; | |
186 | esac | |
187 | ||
188 | exit 0 | |
189 | ||
190 |