]> TLD Linux GIT Repositories - packages/lvm2.git/blob - lvm2-tld_init.patch
- reworked/updated init scripts
[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 11:36:09.176042000 +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 09:44:25.805042000 +0000
50 @@ -61,9 +61,8 @@
51  start()
52  {
53         if ! rh_status_q; then
54 -               echo -n "Starting $DAEMON: "
55 +               msg_starting "$DAEMON"
56                 $DAEMON $CLVMDOPTS || return $?
57 -               echo
58         fi
59  
60         # Refresh local cache.
61 @@ -83,7 +82,7 @@
62  
63         ${lvm_vgscan} > /dev/null 2>&1
64  
65 -       action "Activating VG(s):" ${lvm_vgchange} -aay $LVM_VGS || return $?
66 +       run_cmd "Activating VG(s):" ${lvm_vgchange} -aay $LVM_VGS || return $?
67  
68         touch $LOCK_FILE
69  
70 @@ -108,27 +107,23 @@
71  
72         [ -z "$LVM_VGS" ] && LVM_VGS="$(clustered_vgs)"
73         if [ -n "$LVM_VGS" ]; then
74 -               action "Deactivating clustered VG(s):" ${lvm_vgchange} -anl $LVM_VGS || return $?
75 +               run_cmd "Deactivating clustered VG(s):" ${lvm_vgchange} -anl $LVM_VGS || return $?
76         fi
77  
78 -       action "Signaling $DAEMON to exit" kill -TERM $(pidofproc $DAEMON) || return $?
79 +       run_cmd "Signaling $DAEMON to exit" kill -TERM $(pidofproc $DAEMON) || return $?
80  
81         # wait half second before we start the waiting loop or we will show
82         # the loop more time than really necessary
83         usleep 500000
84  
85         # clvmd could take some time to stop
86 -       rh_status_q && action "Waiting for $DAEMON to exit:" wait_for_finish
87 +       rh_status_q && run_cmd "Waiting for $DAEMON to exit:" wait_for_finish
88  
89         if rh_status_q; then
90 -               echo -n "$DAEMON failed to exit"
91 -               failure
92 -               echo
93 +               fail
94                 return 1
95         else
96 -               echo -n "$DAEMON terminated"
97 -               success
98 -               echo
99 +               ok
100         fi
101  
102         rm -f $LOCK_FILE
103 @@ -138,7 +133,7 @@
104  
105  reload() {
106         rh_status_q || exit 7
107 -       action "Reloading $DAEMON configuration: " $DAEMON -R || return $?
108 +       run_cmd "Reloading $DAEMON configuration: " $DAEMON -R || return $?
109  }
110  
111  restart() {
112 @@ -149,7 +144,7 @@
113  
114         # Try to get clvmd to restart itself. This will preserve 
115         # exclusive LV locks
116 -       action "Restarting $DAEMON: " $DAEMON -S
117 +       run_cmd "Restarting $DAEMON: " $DAEMON -S
118  
119         # If that fails then do a normal stop & restart
120         if  [ $? != 0 ]; then
121 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
122 --- LVM2.2.02.132.orig/scripts/lvm2_lvmetad_init_red_hat.in     2015-09-22 15:00:59.000000000 +0000
123 +++ LVM2.2.02.132/scripts/lvm2_lvmetad_init_red_hat.in  2015-10-05 11:12:06.584042000 +0000
124 @@ -1,4 +1,4 @@
125 -#!/bin/bash
126 +#!/bin/sh
127  #
128  # Copyright (C) 2012 Red Hat, Inc. All rights reserved.
129  #
130 @@ -33,80 +33,76 @@
131  
132  . /etc/init.d/functions
133  
134 -DAEMON=lvmetad
135 -
136 -exec_prefix=@exec_prefix@
137 -sbindir=@sbindir@
138 +DAEMON="lvmetad"
139 +NAME="LVM metadata daemon"
140  
141  LOCK_FILE="/var/lock/subsys/$DAEMON"
142  PID_FILE="@LVMETAD_PIDFILE@"
143  
144 -rh_status() {
145 -       status -p $PID_FILE $DAEMON
146 +start() {
147 +       if [ -f $LOCK_FILE ]; then
148 +               msg_already_running $NAME
149 +               return
150 +       fi
151 +        msg_starting $NAME
152 +        daemon /sbin/$DAEMON </dev/null
153 +        RETVAL=$?
154 +        [ $RETVAL -eq 0 ] && touch $LOCK_FILE
155  }
156  
157 -rh_status_q() {
158 -       rh_status >/dev/null 2>&1
159 +stop() {
160 +        if [ ! -f $LOCK_FILE ]; then
161 +                msg_not_running $NAME
162 +                return
163 +        fi
164 +        msg_stopping $NAME
165 +        killproc --pidfile $PID_FILE $DAEMON
166 +        rm -f $LOCK_FILE
167  }
168  
169 -start()
170 -{
171 -       ret=0
172 -       action "Starting LVM metadata daemon:" $DAEMON || ret=$?
173 -       return $ret
174 +condrestart() {
175 +        if [ ! -f $LOCK_FILE ]; then
176 +                msg_not_running $NAME
177 +                RETVAL=$1
178 +                return
179 +        fi
180 +        stop
181 +        start
182  }
183  
184 -
185 -stop()
186 -{
187 -       ret=0
188 -       action "Signaling LVM metadata daemon to exit:" killproc -p $PID_FILE $DAEMON -TERM || ret=$?
189 -       return $ret
190 +reload() {
191 +        if [ ! -f $LOCK_FILE ]; then
192 +                msg_not_running $NAME
193 +                RETVAL=7
194 +                return
195 +        fi
196 +        msg_reloading $NAME
197 +        killproc $DAEMON -HUP
198 +        RETVAL=$?
199  }
200  
201 -rtrn=1
202 -
203 +RETVAL=0
204  # See how we were called.
205  case "$1" in
206    start)
207 -       rh_status_q && exit 0
208         start
209 -       rtrn=$?
210 -       [ $rtrn = 0 ] && touch $LOCK_FILE
211         ;;
212 -
213 -  stop|force-stop)
214 -       rh_status_q || exit 0
215 +  stop)
216         stop
217 -       rtrn=$?
218 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
219         ;;
220 -
221    restart)
222 -       if stop
223 -       then
224 -               start
225 -       fi
226 -       rtrn=$?
227 +       stop
228 +       start
229         ;;
230 -
231    condrestart|try-restart)
232 -       rh_status_q || exit 0
233 -       if stop
234 -       then
235 -               start
236 -       fi
237 -       rtrn=$?
238 +       condrestart 0
239         ;;
240 -
241    status)
242 -       rh_status
243 -       rtrn=$?
244 +       status $DAEMON
245 +       exit $?
246         ;;
247 -
248    *)
249 -       echo $"Usage: $0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
250 +       msg_usage "$0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
251         ;;
252  esac
253 -
254 -exit $rtrn
255 +exit $RETVAL
256 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
257 --- LVM2.2.02.132.orig/scripts/lvm2_lvmpolld_init_red_hat.in    2015-09-22 15:00:59.000000000 +0000
258 +++ LVM2.2.02.132/scripts/lvm2_lvmpolld_init_red_hat.in 2015-10-05 11:11:58.892042000 +0000
259 @@ -1,6 +1,6 @@
260 -#!/bin/bash
261 +#!/bin/sh
262  #
263 -# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
264 +# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
265  #
266  # This copyrighted material is made available to anyone wishing to use,
267  # modify, copy, or redistribute it subject to the terms and conditions
268 @@ -27,88 +27,84 @@
269  # Default-Start: 1 2 3 4 5
270  # Default-Stop: 0 6
271  # Short-Description: A daemon that is responsible for monitoring in-progress
272 -#                   and possibly longer term operations on logical volumes. 
273 -#                   It helps to reduce the number of spawned processes if same
274 +#                    and possibly longer term operations on logical volumes.
275 +#                    It helps to reduce the number of spawned processes if same
276  #                    logical volume is requested to get monitored multiple times.
277  #                    Also avoids unsolicited termination due to external factors.
278  ### END INIT INFO
279  
280  . /etc/init.d/functions
281  
282 -DAEMON=lvmpolld
283 -
284 -exec_prefix=@exec_prefix@
285 -sbindir=@sbindir@
286 +DAEMON="lvmpolld"
287 +NAME="LVM poll daemon"
288  
289  LOCK_FILE="/var/lock/subsys/$DAEMON"
290  PID_FILE="@LVMPOLLD_PIDFILE@"
291  
292 -rh_status() {
293 -       status -p $PID_FILE $DAEMON
294 +start() {
295 +       if [ -f $LOCK_FILE ]; then
296 +               msg_already_running $NAME
297 +               return
298 +       fi
299 +        msg_starting $NAME
300 +        daemon /sbin/$DAEMON </dev/null
301 +        RETVAL=$?
302 +        [ $RETVAL -eq 0 ] && touch $LOCK_FILE
303  }
304  
305 -rh_status_q() {
306 -       rh_status >/dev/null 2>&1
307 +stop() {
308 +        if [ ! -f $LOCK_FILE ]; then
309 +                msg_not_running $NAME
310 +                return
311 +        fi
312 +        msg_stopping $NAME
313 +        killproc --pidfile $PID_FILE $DAEMON
314 +        rm -f $LOCK_FILE
315  }
316  
317 -start()
318 -{
319 -       ret=0
320 -       action "Starting LVM poll daemon:" $DAEMON || ret=$?
321 -       return $ret
322 +condrestart() {
323 +        if [ ! -f $LOCK_FILE ]; then
324 +                msg_not_running $NAME
325 +                RETVAL=$1
326 +                return
327 +        fi
328 +        stop
329 +        start
330  }
331  
332 -
333 -stop()
334 -{
335 -       ret=0
336 -       action "Signaling LVM poll daemon to exit:" killproc -p $PID_FILE $DAEMON -TERM || ret=$?
337 -       return $ret
338 +reload() {
339 +        if [ ! -f $LOCK_FILE ]; then
340 +                msg_not_running $NAME
341 +                RETVAL=7
342 +                return
343 +        fi
344 +        msg_reloading $NAME
345 +        killproc $DAEMON -HUP
346 +        RETVAL=$?
347  }
348  
349 -rtrn=1
350 -
351 +RETVAL=0
352  # See how we were called.
353  case "$1" in
354    start)
355 -       rh_status_q && exit 0
356         start
357 -       rtrn=$?
358 -       [ $rtrn = 0 ] && touch $LOCK_FILE
359         ;;
360 -
361 -  stop|force-stop)
362 -       rh_status_q || exit 0
363 +  stop)
364         stop
365 -       rtrn=$?
366 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
367         ;;
368 -
369    restart)
370 -       if stop
371 -       then
372 -               start
373 -       fi
374 -       rtrn=$?
375 +       stop
376 +       start
377         ;;
378 -
379    condrestart|try-restart)
380 -       rh_status_q || exit 0
381 -       if stop
382 -       then
383 -               start
384 -       fi
385 -       rtrn=$?
386 +       condrestart 0
387         ;;
388 -
389    status)
390 -       rh_status
391 -       rtrn=$?
392 +       status $DAEMON
393 +       exit $?
394         ;;
395 -
396    *)
397 -       echo $"Usage: $0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
398 +       msg_usage "$0 {start|stop|force-stop|restart|condrestart|try-restart|status}"
399         ;;
400  esac
401 -
402 -exit $rtrn
403 +exit $RETVAL
404 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
405 --- LVM2.2.02.132.orig/scripts/lvm2_monitoring_init_red_hat.in  2015-09-22 15:00:59.000000000 +0000
406 +++ LVM2.2.02.132/scripts/lvm2_monitoring_init_red_hat.in       2015-10-05 11:33:13.048042000 +0000
407 @@ -1,4 +1,4 @@
408 -#!/bin/bash
409 +#!/bin/sh
410  #
411  # Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
412  #
413 @@ -31,15 +31,12 @@
414  
415  . /etc/init.d/functions
416  
417 -DAEMON=lvm2-monitor
418 -DMEVENTD_DAEMON=dmeventd
419 +DAEMON="lvm2-monitor"
420 +DMEVENTD_DAEMON="dmeventd"
421  
422 -exec_prefix=@exec_prefix@
423 -sbindir=@sbindir@
424 -
425 -VGCHANGE=${sbindir}/vgchange
426 -VGS=${sbindir}/vgs
427 -LVS=${sbindir}/lvs
428 +VGCHANGE="/sbin/vgchange"
429 +VGS="/sbin/vgs"
430 +LVS="/sbin/lvs"
431  
432  LOCK_FILE="/var/lock/subsys/$DAEMON"
433  PID_FILE="@DMEVENTD_PIDFILE@"
434 @@ -47,89 +44,69 @@
435  WARN=1
436  export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
437  
438 -rh_status() {
439 -       status -p $PID_FILE $DMEVENTD_DAEMON
440 -}
441 -
442 -rh_status_q() {
443 -       rh_status >/dev/null 2>&1
444 -}
445  start()
446  {
447 -       ret=0
448 +       local config="'log{command_names=0 prefix=\"  \"}'"
449         # TODO do we want to separate out already active groups only?
450 -       VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
451 +       VGSLIST=`eval $VGS --noheadings -o name --ignoreskippedcluster --config $config 2> /dev/null`
452         for vg in $VGSLIST
453         do
454 -           action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y --poll y --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' $vg || ret=$?
455 +           run_cmd "Starting monitoring for LVM VG $vg" $VGCHANGE --monitor y --poll y --ignoreskippedcluster --config $config $vg
456         done
457 -
458 -       return $ret
459  }
460  
461  
462  stop()
463  {
464 -       ret=0
465 +       local config="'log{command_names=0 prefix=\"  \"}'"
466         # TODO do we want to separate out already active groups only?
467         if test "$WARN" = "1"; then
468            echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
469            return 1
470         fi
471 -       VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' 2> /dev/null`
472 +       VGSLIST=`eval $VGS --noheadings -o name --ignoreskippedcluster --config ${config} 2> /dev/null`
473         for vg in $VGSLIST
474         do
475 -           action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n --ignoreskippedcluster --config 'log{command_names=0 prefix="  "}' $vg || ret=$?
476 +           run_cmd "Stopping monitoring for LVM VG $vg" $VGCHANGE --monitor n --ignoreskippedcluster --config $config $vg
477         done
478 -       return $ret
479  }
480  
481 -rtrn=1
482 -
483 +RETVAL=0
484  # See how we were called.
485  case "$1" in
486    start)
487 -       rh_status_q && exit 0
488 +       status $DMEVENTD_DAEMON || exit 0
489         start
490 -       rtrn=$?
491 -       [ $rtrn = 0 ] && touch $LOCK_FILE
492 +       RETVAL=$?
493 +       [ $RETVAL = 0 ] && touch $LOCK_FILE
494         ;;
495 -
496    force-stop)
497 -       rh_status_q || exit 0
498 +       status $DMEVENTD_DAEMON || exit 0
499         WARN=0
500         stop
501 -       rtrn=$?
502 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
503 +       RETVAL=$?
504 +       [ $RETVAL = 0 ] && rm -f $LOCK_FILE
505         ;;
506 -
507    stop)
508 -       rh_status_q || exit 0
509 +       status $DMEVENTD_DAEMON || exit 0
510         test "$runlevel" = "0" && WARN=0
511         test "$runlevel" = "6" && WARN=0
512         stop
513 -       rtrn=$?
514 -       [ $rtrn = 0 ] && rm -f $LOCK_FILE
515 +       RETVAL=$?
516 +       [ $RETVAL = 0 ] && rm -f $LOCK_FILE
517         ;;
518 -
519    restart)
520         WARN=0
521 -       if stop
522 -       then
523 -               start
524 -       fi 
525 -       rtrn=$?
526 +       stop
527 +       start
528         ;;
529 -
530    status)
531 -       rh_status
532 -       rtrn=$?
533 -       [ $rtrn = 0 ] && $LVS -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor
534 +       status $DMEVENTD_DAEMON
535 +       RETVAL=$?
536 +       [ $RETVAL = 0 ] && $LVS -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor
537         ;;
538 -
539    *)
540 -       echo $"Usage: $0 {start|stop|restart|status|force-stop}"
541 +       msg_usage "$0 {start|stop|restart|status|force-stop}"
542         ;;
543  esac
544 -
545 -exit $rtrn
546 +exit $RETVAL