]> TLD Linux GIT Repositories - packages/lvm2.git/blob - lvm2-tld_init.patch
- rework clvmd a bit too
[packages/lvm2.git] / lvm2-tld_init.patch
1 diff -ur LVM2.2.02.132.orig/scripts/blk_availability_init_red_hat.in LVM2.2.02.132/scripts/blk_availability_init_red_hat.in
2 --- LVM2.2.02.132.orig/scripts/blk_availability_init_red_hat.in 2015-09-22 15:00:59.000000000 +0000
3 +++ LVM2.2.02.132/scripts/blk_availability_init_red_hat.in      2015-10-05 12:31:30.991042000 +0000
4 @@ -1,4 +1,4 @@
5 -#!/bin/bash
6 +#!/bin/sh
7  #
8  # Copyright (C) 2012 Red Hat, Inc. All rights reserved.
9  #
10 @@ -31,28 +31,26 @@
11  
12  . /etc/init.d/functions
13  
14 -sbindir=@sbindir@
15 -script=blkdeactivate
16 -options="-u -l wholevg"
17 +DAEMON="blkdeactivate"
18 +OPTIONS="-u -l wholevg"
19  
20  LOCK_FILE="/var/lock/subsys/blk-availability"
21  
22 -
23 -rtrn=1
24 -
25  case "$1" in
26    start)
27         touch $LOCK_FILE
28 +       exit 0
29         ;;
30 -
31    stop)
32 -       action "Stopping block device availability:" $sbindir/$script $options
33 +       run_cmd "Stopping block device availability:" /sbin/$DAEMON $OPTIONS
34         rm -f $LOCK_FILE
35 +       exit 0
36         ;;
37 -
38    status)
39 +       exit 0
40         ;;
41    *)
42 -       echo $"Usage: $0 {start|stop|status}"
43 +       msg_usage "$0 {start|stop|status}"
44 +       exit 3
45         ;;
46  esac
47 diff -ur LVM2.2.02.132.orig/scripts/clvmd_init_red_hat.in LVM2.2.02.132/scripts/clvmd_init_red_hat.in
48 --- LVM2.2.02.132.orig/scripts/clvmd_init_red_hat.in    2015-09-22 15:00:59.000000000 +0000
49 +++ LVM2.2.02.132/scripts/clvmd_init_red_hat.in 2015-10-05 19:20:56.249042000 +0000
50 @@ -18,15 +18,12 @@
51  
52  . /etc/rc.d/init.d/functions
53  
54 -DAEMON=clvmd
55 +DAEMON="clvmd"
56  
57 -exec_prefix=@exec_prefix@
58 -sbindir=@sbindir@
59 -
60 -lvm_vgchange=${sbindir}/vgchange
61 -lvm_vgs=${sbindir}/vgs
62 -lvm_vgscan=${sbindir}/vgscan
63 -lvm_lvs=${sbindir}/lvs
64 +lvm_vgchange="/sbin/vgchange"
65 +lvm_vgs="/sbin/vgs"
66 +lvm_vgscan="/sbin/vgscan"
67 +lvm_lvs="/sbin/lvs"
68  
69  CLVMDOPTS="-T30"
70  
71 @@ -50,20 +47,11 @@
72         ${lvm_lvs} --noheadings -o lv_name -S 'vg_clustered=1 && lv_active!=""' 2>/dev/null
73  }
74  
75 -rh_status() {
76 -       status $DAEMON
77 -}
78 -
79 -rh_status_q() {
80 -       rh_status >/dev/null 2>&1
81 -}
82 -
83  start()
84  {
85 -       if ! rh_status_q; then
86 -               echo -n "Starting $DAEMON: "
87 +       if ! status $DAEMON 1>/dev/null 2>&1; then
88 +               msg_starting "$DAEMON"
89                 $DAEMON $CLVMDOPTS || return $?
90 -               echo
91         fi
92  
93         # Refresh local cache.
94 @@ -82,74 +70,62 @@
95         # unnecessary warnings.
96  
97         ${lvm_vgscan} > /dev/null 2>&1
98 -
99 -       action "Activating VG(s):" ${lvm_vgchange} -aay $LVM_VGS || return $?
100 -
101 +       run_cmd "Activating VG(s):" ${lvm_vgchange} -aay $LVM_VGS || return $?
102         touch $LOCK_FILE
103 -
104         return 0
105  }
106  
107  wait_for_finish()
108  {
109         count=0
110 -       while [ "$count" -le "$CLVMD_STOP_TIMEOUT" ] && \
111 -                rh_status_q ]; do
112 +       while [ "$count" -le "$CLVMD_STOP_TIMEOUT" ] && status $DAEMON 1>/dev/null 2>&1 ; do
113                 sleep 1
114                 count=$((count+1))
115         done
116 -
117 -       ! rh_status_q
118 +       ! status $DAEMON 1>/dev/null 2>&1
119  }
120  
121  stop()
122  {
123 -       rh_status_q || return 0
124 +       status $DAEMON 1>/dev/null 2>&1 || return 0
125  
126         [ -z "$LVM_VGS" ] && LVM_VGS="$(clustered_vgs)"
127         if [ -n "$LVM_VGS" ]; then
128 -               action "Deactivating clustered VG(s):" ${lvm_vgchange} -anl $LVM_VGS || return $?
129 +               run_cmd "Deactivating clustered VG(s):" ${lvm_vgchange} -anl $LVM_VGS || return $?
130         fi
131  
132 -       action "Signaling $DAEMON to exit" kill -TERM $(pidofproc $DAEMON) || return $?
133 +       run_cmd "Signaling $DAEMON to exit" kill -TERM $(pidofproc $DAEMON) || return $?
134  
135         # wait half second before we start the waiting loop or we will show
136         # the loop more time than really necessary
137         usleep 500000
138  
139         # clvmd could take some time to stop
140 -       rh_status_q && action "Waiting for $DAEMON to exit:" wait_for_finish
141 -
142 -       if rh_status_q; then
143 -               echo -n "$DAEMON failed to exit"
144 -               failure
145 -               echo
146 +       status $DAEMON 1>/dev/null 2>&1 && run_cmd "Waiting for $DAEMON to exit:" wait_for_finish
147 +       if status $DAEMON 1>/dev/null 2>&1; then
148 +               fail
149                 return 1
150         else
151 -               echo -n "$DAEMON terminated"
152 -               success
153 -               echo
154 +               ok
155         fi
156 -
157         rm -f $LOCK_FILE
158 -
159         return 0
160  }
161  
162  reload() {
163 -       rh_status_q || exit 7
164 -       action "Reloading $DAEMON configuration: " $DAEMON -R || return $?
165 +       status $DAEMON 1>/dev/null 2>&1 || exit 7
166 +       run_cmd "Reloading $DAEMON configuration: " $DAEMON -R || return $?
167  }
168  
169  restart() {
170         # if stop fails, restart will return the error and not attempt
171 -       # another start. Even if start is protected by rh_status_q,
172 +       # another start. Even if start is protected by status call,
173         # that would avoid spawning another daemon, it would try to
174         # reactivate the VGs.
175  
176         # Try to get clvmd to restart itself. This will preserve 
177         # exclusive LV locks
178 -       action "Restarting $DAEMON: " $DAEMON -S
179 +       run_cmd "Restarting $DAEMON: " $DAEMON -S
180  
181         # If that fails then do a normal stop & restart
182         if  [ $? != 0 ]; then
183 @@ -166,49 +142,43 @@
184         exit 4
185  }
186  
187 +RETVAL=0
188  # See how we were called.
189  case "$1" in
190    start)
191         start
192 -       rtrn=$?
193 +       RETVAL=$?
194         ;;
195 -
196    stop)
197         stop
198 -       rtrn=$?
199 +       RETVAL=$?
200         ;;
201 -
202    restart|force-reload)
203         restart
204 -       rtrn=$?
205 +       RETVAL=$?
206         ;;
207 -
208    condrestart|try-restart)
209 -       rh_status_q || exit 0
210 +       status $DAEMON 1>/dev/null 2>&1 || exit 0
211         restart
212 -       rtrn=$? 
213 +       RETVAL=$? 
214         ;;
215 -
216    reload)
217         reload
218 -       rtrn=$?
219 +       RETVAL=$?
220         ;;
221 -
222    status)
223 -       rh_status
224 -       rtrn=$?
225 -       if [ $rtrn = 0 ]; then
226 +       status $DAEMON
227 +       RETVAL=$?
228 +       if [ $RETVAL = 0 ]; then
229                 cvgs="$(clustered_vgs)"
230                 echo Clustered Volume Groups: ${cvgs:-"(none)"}
231                 clvs="$(clustered_active_lvs)"
232                 echo Active clustered Logical Volumes: ${clvs:-"(none)"}
233         fi
234         ;;
235 -
236    *)
237 -       echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
238 -       rtrn=2
239 +       msg_usage "$0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
240 +       RETVAL=2
241         ;;
242  esac
243 -
244 -exit $rtrn
245 +exit $RETVAL
246 diff -ur LVM2.2.02.132.orig/scripts/lvm2_lvmetad_init_red_hat.in LVM2.2.02.132/scripts/lvm2_lvmetad_init_red_hat.in
247 --- LVM2.2.02.132.orig/scripts/lvm2_lvmetad_init_red_hat.in     2015-09-22 15:00:59.000000000 +0000
248 +++ LVM2.2.02.132/scripts/lvm2_lvmetad_init_red_hat.in  2015-10-05 12:31:30.993042000 +0000
249 @@ -1,4 +1,4 @@
250 -#!/bin/bash
251 +#!/bin/sh
252  #
253  # Copyright (C) 2012 Red Hat, Inc. All rights reserved.
254  #
255 @@ -33,80 +33,76 @@
256  
257  . /etc/init.d/functions
258  
259 -DAEMON=lvmetad
260 -
261 -exec_prefix=@exec_prefix@
262 -sbindir=@sbindir@
263 +DAEMON="lvmetad"
264 +NAME="LVM metadata daemon"
265  
266  LOCK_FILE="/var/lock/subsys/$DAEMON"
267  PID_FILE="@LVMETAD_PIDFILE@"
268  
269 -rh_status() {
270 -       status -p $PID_FILE $DAEMON
271 +start() {
272 +       if [ -f $LOCK_FILE ]; then
273 +               msg_already_running $NAME
274 +               return
275 +       fi
276 +        msg_starting $NAME
277 +        daemon /sbin/$DAEMON </dev/null
278 +        RETVAL=$?
279 +        [ $RETVAL -eq 0 ] && touch $LOCK_FILE
280  }
281  
282 -rh_status_q() {
283 -       rh_status >/dev/null 2>&1
284 +stop() {
285 +        if [ ! -f $LOCK_FILE ]; then
286 +                msg_not_running $NAME
287 +                return
288 +        fi
289 +        msg_stopping $NAME
290 +        killproc --pidfile $PID_FILE $DAEMON
291 +        rm -f $LOCK_FILE
292  }
293  
294 -start()
295 -{
296 -       ret=0
297 -       action "Starting LVM metadata daemon:" $DAEMON || ret=$?
298 -       return $ret
299 +condrestart() {
300 +        if [ ! -f $LOCK_FILE ]; then
301 +                msg_not_running $NAME
302 +                RETVAL=$1
303 +                return
304 +        fi
305 +        stop
306 +        start
307  }
308  
309 -
310 -stop()
311 -{
312 -       ret=0
313 -       action "Signaling LVM metadata daemon to exit:" killproc -p $PID_FILE $DAEMON -TERM || ret=$?
314 -       return $ret
315 +reload() {
316 +        if [ ! -f $LOCK_FILE ]; then
317 +                msg_not_running $NAME
318 +                RETVAL=7
319 +                return
320 +        fi
321 +        msg_reloading $NAME
322 +        killproc $DAEMON -HUP
323 +        RETVAL=$?
324  }
325  
326 -rtrn=1
327 -
328 +RETVAL=0
329  # See how we were called.
330  case "$1" in
331    start)
332 -       rh_status_q && exit 0
333         start
334 -       rtrn=$?
335 -       [ $rtrn = 0 ] && touch $LOCK_FILE
336         ;;
337 -
338 -  stop|force-stop)
339 -       rh_status_q || exit 0
340 +  stop)
341         stop
342 -       rtrn=$?
343 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
344         ;;
345 -
346    restart)
347 -       if stop
348 -       then
349 -               start
350 -       fi
351 -       rtrn=$?
352 +       stop
353 +       start
354         ;;
355 -
356    condrestart|try-restart)
357 -       rh_status_q || exit 0
358 -       if stop
359 -       then
360 -               start
361 -       fi
362 -       rtrn=$?
363 +       condrestart 0
364         ;;
365 -
366    status)
367 -       rh_status
368 -       rtrn=$?
369 +       status $DAEMON
370 +       exit $?
371         ;;
372 -
373    *)
374 -       echo $"Usage: $0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
375 +       msg_usage "$0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
376         ;;
377  esac
378 -
379 -exit $rtrn
380 +exit $RETVAL
381 diff -ur LVM2.2.02.132.orig/scripts/lvm2_lvmpolld_init_red_hat.in LVM2.2.02.132/scripts/lvm2_lvmpolld_init_red_hat.in
382 --- LVM2.2.02.132.orig/scripts/lvm2_lvmpolld_init_red_hat.in    2015-09-22 15:00:59.000000000 +0000
383 +++ LVM2.2.02.132/scripts/lvm2_lvmpolld_init_red_hat.in 2015-10-05 12:31:30.993042000 +0000
384 @@ -1,6 +1,6 @@
385 -#!/bin/bash
386 +#!/bin/sh
387  #
388 -# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
389 +# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
390  #
391  # This copyrighted material is made available to anyone wishing to use,
392  # modify, copy, or redistribute it subject to the terms and conditions
393 @@ -27,88 +27,84 @@
394  # Default-Start: 1 2 3 4 5
395  # Default-Stop: 0 6
396  # Short-Description: A daemon that is responsible for monitoring in-progress
397 -#                   and possibly longer term operations on logical volumes. 
398 -#                   It helps to reduce the number of spawned processes if same
399 +#                    and possibly longer term operations on logical volumes.
400 +#                    It helps to reduce the number of spawned processes if same
401  #                    logical volume is requested to get monitored multiple times.
402  #                    Also avoids unsolicited termination due to external factors.
403  ### END INIT INFO
404  
405  . /etc/init.d/functions
406  
407 -DAEMON=lvmpolld
408 -
409 -exec_prefix=@exec_prefix@
410 -sbindir=@sbindir@
411 +DAEMON="lvmpolld"
412 +NAME="LVM poll daemon"
413  
414  LOCK_FILE="/var/lock/subsys/$DAEMON"
415  PID_FILE="@LVMPOLLD_PIDFILE@"
416  
417 -rh_status() {
418 -       status -p $PID_FILE $DAEMON
419 +start() {
420 +       if [ -f $LOCK_FILE ]; then
421 +               msg_already_running $NAME
422 +               return
423 +       fi
424 +        msg_starting $NAME
425 +        daemon /sbin/$DAEMON </dev/null
426 +        RETVAL=$?
427 +        [ $RETVAL -eq 0 ] && touch $LOCK_FILE
428  }
429  
430 -rh_status_q() {
431 -       rh_status >/dev/null 2>&1
432 +stop() {
433 +        if [ ! -f $LOCK_FILE ]; then
434 +                msg_not_running $NAME
435 +                return
436 +        fi
437 +        msg_stopping $NAME
438 +        killproc --pidfile $PID_FILE $DAEMON
439 +        rm -f $LOCK_FILE
440  }
441  
442 -start()
443 -{
444 -       ret=0
445 -       action "Starting LVM poll daemon:" $DAEMON || ret=$?
446 -       return $ret
447 +condrestart() {
448 +        if [ ! -f $LOCK_FILE ]; then
449 +                msg_not_running $NAME
450 +                RETVAL=$1
451 +                return
452 +        fi
453 +        stop
454 +        start
455  }
456  
457 -
458 -stop()
459 -{
460 -       ret=0
461 -       action "Signaling LVM poll daemon to exit:" killproc -p $PID_FILE $DAEMON -TERM || ret=$?
462 -       return $ret
463 +reload() {
464 +        if [ ! -f $LOCK_FILE ]; then
465 +                msg_not_running $NAME
466 +                RETVAL=7
467 +                return
468 +        fi
469 +        msg_reloading $NAME
470 +        killproc $DAEMON -HUP
471 +        RETVAL=$?
472  }
473  
474 -rtrn=1
475 -
476 +RETVAL=0
477  # See how we were called.
478  case "$1" in
479    start)
480 -       rh_status_q && exit 0
481         start
482 -       rtrn=$?
483 -       [ $rtrn = 0 ] && touch $LOCK_FILE
484         ;;
485 -
486 -  stop|force-stop)
487 -       rh_status_q || exit 0
488 +  stop)
489         stop
490 -       rtrn=$?
491 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
492         ;;
493 -
494    restart)
495 -       if stop
496 -       then
497 -               start
498 -       fi
499 -       rtrn=$?
500 +       stop
501 +       start
502         ;;
503 -
504    condrestart|try-restart)
505 -       rh_status_q || exit 0
506 -       if stop
507 -       then
508 -               start
509 -       fi
510 -       rtrn=$?
511 +       condrestart 0
512         ;;
513 -
514    status)
515 -       rh_status
516 -       rtrn=$?
517 +       status $DAEMON
518 +       exit $?
519         ;;
520 -
521    *)
522 -       echo $"Usage: $0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
523 +       msg_usage "$0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
524         ;;
525  esac
526 -
527 -exit $rtrn
528 +exit $RETVAL
529 diff -ur LVM2.2.02.132.orig/scripts/lvm2_monitoring_init_red_hat.in LVM2.2.02.132/scripts/lvm2_monitoring_init_red_hat.in
530 --- LVM2.2.02.132.orig/scripts/lvm2_monitoring_init_red_hat.in  2015-09-22 15:00:59.000000000 +0000
531 +++ LVM2.2.02.132/scripts/lvm2_monitoring_init_red_hat.in       2015-10-05 12:32:01.204042000 +0000
532 @@ -1,4 +1,4 @@
533 -#!/bin/bash
534 +#!/bin/sh
535  #
536  # Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
537  #
538 @@ -31,15 +31,12 @@
539  
540  . /etc/init.d/functions
541  
542 -DAEMON=lvm2-monitor
543 -DMEVENTD_DAEMON=dmeventd
544 +DAEMON="lvm2-monitor"
545 +DMEVENTD_DAEMON="dmeventd"
546  
547 -exec_prefix=@exec_prefix@
548 -sbindir=@sbindir@
549 -
550 -VGCHANGE=${sbindir}/vgchange
551 -VGS=${sbindir}/vgs
552 -LVS=${sbindir}/lvs
553 +VGCHANGE="/sbin/vgchange"
554 +VGS="/sbin/vgs"
555 +LVS="/sbin/lvs"
556  
557  LOCK_FILE="/var/lock/subsys/$DAEMON"
558  PID_FILE="@DMEVENTD_PIDFILE@"
559 @@ -47,89 +44,69 @@
560  WARN=1
561  export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
562  
563 -rh_status() {
564 -       status -p $PID_FILE $DMEVENTD_DAEMON
565 -}
566 -
567 -rh_status_q() {
568 -       rh_status >/dev/null 2>&1
569 -}
570  start()
571  {
572 -       ret=0
573 +       local config="'log{command_names=0 prefix=\"  \"}'"
574         # TODO do we want to separate out already active groups only?
575 -       VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
576 +       VGSLIST=`eval $VGS --noheadings -o name --ignoreskippedcluster --config $config 2> /dev/null`
577         for vg in $VGSLIST
578         do
579 -           action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y --poll y --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' $vg || ret=$?
580 +           run_cmd "Starting monitoring for LVM VG $vg" $VGCHANGE --monitor y --poll y --ignoreskippedcluster --config $config $vg
581         done
582 -
583 -       return $ret
584  }
585  
586  
587  stop()
588  {
589 -       ret=0
590 +       local config="'log{command_names=0 prefix=\"  \"}'"
591         # TODO do we want to separate out already active groups only?
592         if test "$WARN" = "1"; then
593            echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
594            return 1
595         fi
596 -       VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
597 +       VGSLIST=`eval $VGS --noheadings -o name --ignoreskippedcluster --config ${config} 2> /dev/null`
598         for vg in $VGSLIST
599         do
600 -           action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' $vg || ret=$?
601 +           run_cmd "Stopping monitoring for LVM VG $vg" $VGCHANGE --monitor n --ignoreskippedcluster --config $config $vg
602         done
603 -       return $ret
604  }
605  
606 -rtrn=1
607 -
608 +RETVAL=0
609  # See how we were called.
610  case "$1" in
611    start)
612 -       rh_status_q && exit 0
613 +       status $DMEVENTD_DAEMON 1>/dev/null 2>&1 && exit 0
614         start
615 -       rtrn=$?
616 -       [ $rtrn = 0 ] && touch $LOCK_FILE
617 +       RETVAL=$?
618 +       [ $RETVAL = 0 ] && touch $LOCK_FILE
619         ;;
620 -
621    force-stop)
622 -       rh_status_q || exit 0
623 +       status $DMEVENTD_DAEMON 1>/dev/null 2>&1 || exit 0
624         WARN=0
625         stop
626 -       rtrn=$?
627 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
628 +       RETVAL=$?
629 +       [ $RETVAL = 0 ] && rm -f $LOCK_FILE
630         ;;
631 -
632    stop)
633 -       rh_status_q || exit 0
634 +       status $DMEVENTD_DAEMON 1>/dev/null 2>&1 || exit 0
635         test "$runlevel" = "0" && WARN=0
636         test "$runlevel" = "6" && WARN=0
637         stop
638 -       rtrn=$?
639 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
640 +       RETVAL=$?
641 +       [ $RETVAL = 0 ] && rm -f $LOCK_FILE
642         ;;
643 -
644    restart)
645         WARN=0
646 -       if stop
647 -       then
648 -               start
649 -       fi 
650 -       rtrn=$?
651 +       stop
652 +       start
653         ;;
654 -
655    status)
656 -       rh_status
657 -       rtrn=$?
658 -       [ $rtrn = 0 ] && $LVS -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor
659 +       status $DMEVENTD_DAEMON
660 +       RETVAL=$?
661 +       [ $RETVAL = 0 ] && $LVS -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor
662         ;;
663 -
664    *)
665 -       echo $"Usage: $0 {start|stop|restart|status|force-stop}"
666 +       msg_usage "$0 {start|stop|restart|status|force-stop}"
667         ;;
668  esac
669 -
670 -exit $rtrn
671 +exit $RETVAL