]> git.pld-linux.org Git - packages/sanlock.git/blob - sanlock-init-pld.patch
af310a431e07d96c6e45f690d1603feeb18e5700
[packages/sanlock.git] / sanlock-init-pld.patch
1 --- sanlock-3.8.0/init.d/sanlock.orig   2020-02-08 22:16:26.415493120 +0100
2 +++ sanlock-3.8.0/init.d/sanlock        2020-02-08 22:25:28.369223771 +0100
3 @@ -32,95 +32,86 @@
4  [ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
5  
6  start() {
7 -       [ -x $exec ] || exit 5
8 -
9 -       if [ ! -d /run/$prog ]; then
10 -               install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /run/$prog
11 -               [ -x /sbin/restorecon ] && restorecon /run/$prog
12 +       # Check if the service is already running?
13 +       if [ -f /var/lock/subsys/sanlock ]; then
14 +               msg_already_running "sanlock"
15 +               return
16         fi
17  
18 -       echo -n $"Starting $prog: "
19 +       msg_starting "sanlock"
20         daemon $prog daemon $SANLOCKOPTS
21         retval=$?
22 -       echo
23         [ $retval -eq 0 ] && touch $lockfile
24         return $retval
25  }
26  
27  stop() {
28 +       if [ ! -f /var/lock/subsys/sanlock ]; then
29 +               msg_not_running "sanlock"
30 +               return
31 +       fi
32         PID=$(pidofproc -p $runfile $prog)
33  
34 -       echo -n $"Sending stop signal $prog ($PID): "
35         killproc -p $runfile $prog -TERM
36         retval=$?
37 -       echo
38  
39         if [ $retval -ne 0 ]; then
40                 return $retval
41         fi
42  
43 -       echo -n $"Waiting for $prog ($PID) to stop:"
44 +       show "Waiting for %s (%s) to stop:" "$prog" "$PID"
45 +       busy
46  
47         timeout=10
48         while checkpid $PID; do
49                 sleep 1
50                 timeout=$((timeout - 1))
51                 if [ "$timeout" -le 0 ]; then
52 -                       failure; echo
53 -                       return 1
54 +                       fail
55 +                       retval=1
56 +                       return $retval
57                 fi
58         done
59  
60 -       success; echo
61 +       ok
62         rm -f $lockfile
63         return $retval
64  }
65  
66 -restart() {
67 -       rh_status_q && stop
68 -       start
69 -}
70 -
71 -reload() {
72 -       restart
73 -}
74 -
75 -rh_status() {
76 -       status $prog
77 -}
78 -
79 -rh_status_q() {
80 -       rh_status >/dev/null 2>&1
81 +condrestart() {
82 +       if [ ! -f /var/lock/subsys/sanlock ]; then
83 +               msg_not_running "sanlock"
84 +               retval=$1
85 +               return $retval
86 +       fi
87 +       stop && start
88 +       retval=$?
89 +       return $retval
90  }
91  
92  case "$1" in
93         start)
94 -               rh_status_q && exit 0
95 -               $1
96 +               start
97                 ;;
98         stop)
99 -               rh_status_q || exit 0
100 -               $1
101 +               stop
102                 ;;
103         restart)
104 -               $1
105 +               stop
106 +               start
107                 ;;
108 -       reload)
109 -               rh_status_q || exit 7
110 -               $1
111 +       try-restart)
112 +               condrestart 0
113                 ;;
114         force-reload)
115 -               force_reload
116 +               condrestart 7
117                 ;;
118         status)
119 -               rh_status
120 -               ;;
121 -       condrestart|try-restart)
122 -               rh_status_q || exit 0
123 -               restart
124 +               status --pidfile $runfile sanlock
125 +               retval=$?
126                 ;;
127         *)
128 -               echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
129 -               exit 2
130 +               msg_usage "$0 {start|stop|status|restart||try-restart|force-reload}"
131 +               exit 3
132  esac
133 -exit $?
134 +exit $retval
135 --- sanlock-3.8.0/init.d/wdmd.orig      2020-02-08 22:16:26.418826435 +0100
136 +++ sanlock-3.8.0/init.d/wdmd   2020-02-08 22:32:56.383463337 +0100
137 @@ -42,114 +42,103 @@
138         retval=$?
139  
140         if [ $retval -ne 0 ]; then
141 -               echo -n $"Loading the softdog kernel module: "
142 +               show "Loading the softdog kernel module: "
143                 modprobe softdog && udevadm settle
144  
145                 watchdog_probe
146                 retval=$?
147                 if [ $retval -ne 0 ]; then
148 -                       failure; echo
149 +                       fail
150                         return 1
151                 fi
152 -               success; echo
153 +               ok
154         fi
155  }
156  
157  start() {
158 -       watchdog_check
159 -
160 -       [ -x $exec ] || exit 5
161 -
162 -       if [ ! -d /run/$prog ]; then
163 -               install -d -g $WDMDGROUP -m 775 /run/$prog
164 -               [ -x /sbin/restorecon ] && restorecon /run/$prog
165 +       # Check if the service is already running?
166 +       if [ -f $lockfile ]; then
167 +               msg_already_running "wdmd"
168 +               return
169         fi
170  
171 -       echo -n $"Starting $prog: "
172 +       watchdog_check
173 +
174 +       msg_starting "wdmd"
175         daemon $prog $WDMDOPTS
176         retval=$?
177 -       echo
178         [ $retval -eq 0 ] && touch $lockfile
179         return $retval
180  }
181  
182  stop() {
183 +       if [ ! -f $lockfile ]; then
184 +               msg_not_running "wdmd"
185 +               return
186 +       fi
187         PID=$(pidofproc -p $runfile $prog)
188  
189 -       echo -n $"Sending stop signal $prog ($PID): "
190         killproc -p $runfile $prog -TERM
191         retval=$?
192 -       echo
193  
194         if [ $retval -ne 0 ]; then
195                 return $retval
196         fi
197  
198 -       echo -n $"Waiting for $prog ($PID) to stop:"
199 +       show "Waiting for %s (%s) to stop:" "$prog" "$PID"
200  
201         timeout=10
202         while checkpid $PID; do
203                 sleep 1
204                 timeout=$((timeout - 1))
205                 if [ "$timeout" -le 0 ]; then
206 -                       failure; echo
207 -                       return 1
208 +                       fail
209 +                       retval=1
210 +                       return $retval
211                 fi
212         done
213  
214 -       success; echo
215 +       ok
216         rm -f $lockfile
217         return $retval
218  }
219  
220 -restart() {
221 -       rh_status_q && stop
222 +condrestart() {
223 +       if [ ! -f $lockfile ]; then
224 +               msg_not_running "wdmd"
225 +               retval=$1
226 +               return $retval
227 +       fi
228 +       stop
229         start
230  }
231  
232 -reload() {
233 -       restart
234 -}
235 -
236 -rh_status() {
237 -       status $prog
238 -}
239 -
240 -rh_status_q() {
241 -       rh_status >/dev/null 2>&1
242 -}
243 -
244  case "$1" in
245         start)
246 -               rh_status_q && exit 0
247                 $1
248                 ;;
249         stop)
250 -               rh_status_q || exit 0
251                 $1
252                 ;;
253         restart)
254 -               $1
255 -               ;;
256 -       reload)
257 -               rh_status_q || exit 7
258 -               $1
259 +               stop
260 +               start
261                 ;;
262         watchdog-check)
263                 watchdog_check
264                 ;;
265         force-reload)
266 -               force_reload
267 +               condrestart 7
268                 ;;
269         status)
270 -               rh_status
271 +               status --pidfile $runfile wdmd
272                 ;;
273         condrestart|try-restart)
274                 rh_status_q || exit 0
275 -               restart
276 +               condrestart 0
277                 ;;
278         *)
279 -               echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
280 -               exit 2
281 +               msg_usage "$0 {start|stop|status|restart|condrestart|try-restart|force-reload}"
282 +               exit 3
283  esac
284 -exit $?
285 +exit $retval
286 --- sanlock-3.8.0/init.d/fence_sanlockd.orig    2019-06-12 21:07:38.000000000 +0200
287 +++ sanlock-3.8.0/init.d/fence_sanlockd 2020-02-08 22:34:27.129638389 +0100
288 @@ -33,42 +33,35 @@
289  [ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
290  
291  start() {
292 -       [ -x $exec ] || exit 5
293 +       # Check if the service is already running?
294 +       if [ -f /var/lock/subsys/sanlock ]; then
295 +               msg_already_running "sanlock"
296 +               return
297 +       fi
298  
299         # start wdmd and sanlock daemons if they aren't running
300 +       /etc/rc.d/init.d/wdmd status >/dev/null 2>&1 || /etc/rc.d/init.d/wdmd start
301 +       /etc/rc.d/init.d/sanlock status >/dev/null 2>&1 || /etc/rc.d/init.d/sanlock start
302  
303 -       service wdmd status > /dev/null 2>&1 || service wdmd start
304 -
305 -       service sanlock status > /dev/null 2>&1 || service sanlock start
306 -
307 -       [ ! -d /run/$prog ] && install -d -m 775 /run/$prog
308 -
309 -       [ ! -d /run/$agent ] && install -d -m 775 /run/$agent
310 -
311 -       [ -n "$(which restorecon)" ] && \
312 -               [ -x "$(which restorecon)" ] && \
313 -               restorecon /run/$prog
314 -
315 -       [ -n "$(which restorecon)" ] && \
316 -               [ -x "$(which restorecon)" ] && \
317 -               restorecon /run/$agent
318 -
319 -       echo -n $"Starting $prog: "
320 +       msg_starting "$prog"
321         daemon $prog $FENCESANLOCKDOPTS
322         retval=$?
323 -       echo
324         [ $retval -eq 0 ] && touch $lockfile
325         return $retval
326  }
327  
328  stop() {
329 +       if [ ! -f /var/lock/subsys/$prog ]; then
330 +               msg_not_running "$prog"
331 +               return
332 +       fi
333         agent_ps="$(ps ax -o pid,args | grep fence_sanlock | grep -v grep | grep -v fence_sanlockd)"
334  
335         [ -n "$agent_ps" ] && {
336                 agent_pid="$(echo $agent_ps | awk '{print $1}')"
337 -               echo -n "cannot stop while $agent $agent_pid is running"
338 -               failure; echo
339 -               return 1
340 +               echo "Cannot stop while $agent $agent_pid is running" >&2
341 +               retval=1
342 +               return $retval
343         }
344  
345         # Ideally, we'd like a general way to check if anything
346 @@ -78,17 +71,17 @@
347         if [ -d /sys/kernel/dlm/ ]; then
348                 count="$(ls -A /sys/kernel/dlm/ | wc -l)"
349                 if [ $count -ne 0 ]; then
350 -                       echo -n "cannot stop while dlm lockspaces exist"
351 -                       failure; echo
352 -                       return 1
353 +                       echo "Cannot stop while dlm lockspaces exist" >&2
354 +                       retval=1
355 +                       return $retval
356                 fi
357         fi
358  
359         if [ -d /sys/kernel/config/dlm/cluster ]; then
360                 # this dir exists while dlm_controld is running
361 -               echo -n "cannot stop while dlm is running"
362 -               failure; echo
363 -               return 1
364 +               echo "Cannot stop while dlm is running" >&2
365 +               retval=1
366 +               return $retval
367         fi
368  
369         PID=$(pidofproc -p $runfile $prog)
370 @@ -96,10 +89,8 @@
371         # We have to use SIGHUP to mean stop because sanlock
372         # uses SIGTERM to mean that the lockspace failed.
373  
374 -       echo -n $"Sending stop signal $prog ($PID): "
375         killproc -p $runfile $prog -HUP
376         retval=$?
377 -       echo
378  
379         if [ $retval -ne 0 ]; then
380                 return $retval
381 @@ -113,75 +104,65 @@
382                 echo "" > $fifofile
383         fi
384  
385 -       echo -n $"Waiting for $prog ($PID) to stop:"
386 +       show "Waiting for %s (%s) to stop:" "$prog" "$PID"
387  
388         timeout=10
389         while checkpid $PID; do
390                 sleep 1
391                 timeout=$((timeout - 1))
392                 if [ "$timeout" -le 0 ]; then
393 -                       failure; echo
394 +                       fail
395                         return 1
396                 fi
397         done
398  
399 -       success; echo
400 +       ok
401         rm -f $lockfile
402  
403         # stop wdmd and sanlock daemons if they are running
404 -
405 -       service sanlock status > /dev/null 2>&1 && service sanlock stop
406 -
407 -       service wdmd status > /dev/null 2>&1 && service wdmd stop
408 +       /etc/rc.d/init.d/sanlock status >/dev/null 2>&1 && /etc/rc.d/init.d/sanlock stop
409 +       /etc/rc.d/init.d/wdmd status >/dev/null 2>&1 && /etc/rc.d/init.d/wdmd stop
410  
411         return $retval
412  }
413  
414 -restart() {
415 -       rh_status_q && stop
416 -       start
417 -}
418 -
419 -reload() {
420 -       restart
421 -}
422 -
423 -rh_status() {
424 -       status $prog
425 -}
426 -
427 -rh_status_q() {
428 -       rh_status >/dev/null 2>&1
429 +condrestart() {
430 +       if [ ! -f /var/lock/subsys/$prog ]; then
431 +               msg_not_running "$prog"
432 +               retval=$1
433 +               return $retval
434 +       fi
435 +       stop && start
436 +       retval=$?
437 +       return $retval
438  }
439 -
440
441  case "$1" in
442         start)
443 -               rh_status_q && exit 0
444 -               $1
445 +               start
446                 ;;
447         stop)
448 -               rh_status_q || exit 0
449 -               $1
450 +               stop
451                 ;;
452         restart)
453 -               $1
454 +               stop && start
455                 ;;
456         reload)
457                 rh_status_q || exit 7
458                 $1
459                 ;;
460         force-reload)
461 -               force_reload
462 +               condrestart 7
463                 ;;
464         status)
465 -               rh_status
466 +               status --pidfile $runfile $prog
467 +               retval=$?
468                 ;;
469         condrestart|try-restart)
470 -               rh_status_q || exit 0
471 -               restart
472 +               condrestart 0
473                 ;;
474         *)
475 -               echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
476 -               exit 2
477 +               msg_usage "$0 {start|stop|status|restart|condrestart|try-restart|force-reload}"
478 +               exit 3
479  esac
480  exit $?
This page took 0.080031 seconds and 2 git commands to generate.