1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00
lvm2/scripts/lvm2_monitoring_init_red_hat.in

135 lines
3.0 KiB
Plaintext
Raw Normal View History

2009-09-17 03:22:40 +04:00
#!/bin/bash
#
# Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2009-09-17 03:22:40 +04:00
#
# This file is part of LVM2.
# It is required for the proper handling of failures of LVM2 mirror
# devices that were created using the -m option of lvcreate.
#
#
# chkconfig: 12345 02 99
# description: Starts and stops dmeventd monitoring for lvm2
#
# For Red-Hat-based distributions such as Fedora, RHEL, CentOS.
#
### BEGIN INIT INFO
2009-09-17 03:40:19 +04:00
# Provides: lvm2-monitor
2009-09-17 03:22:40 +04:00
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 1 2 3 4 5
# Default-Stop: 0 6
# Short-Description: Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
2009-09-17 03:22:40 +04:00
### END INIT INFO
. /etc/init.d/functions
DAEMON=lvm2-monitor
DMEVENTD_DAEMON=dmeventd
2009-09-17 03:22:40 +04:00
sbindir=@SBINDIR@
2009-09-17 03:22:40 +04:00
VGCHANGE="$sbindir/vgchange"
VGS="$sbindir/vgs"
LVS="$sbindir/lvs"
2009-09-17 03:22:40 +04:00
LOCK_FILE="@DEFAULT_SYS_LOCK_DIR@/subsys/$DAEMON"
PID_FILE="@DMEVENTD_PIDFILE@"
2009-09-17 03:22:40 +04:00
WARN=1
export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
2009-09-17 03:22:40 +04:00
rh_status() {
status -p "$PID_FILE" "$DMEVENTD_DAEMON"
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
2009-09-17 03:22:40 +04:00
start()
{
ret=0
# TODO do we want to separate out already active groups only?
VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
2009-09-17 03:22:40 +04:00
for vg in $VGSLIST
do
action "Starting monitoring for VG $vg:" "$VGCHANGE" --monitor y --poll y --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
2009-09-17 03:22:40 +04:00
done
return $ret
}
stop()
{
ret=0
# TODO do we want to separate out already active groups only?
if test "$WARN" = "1"; then
echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
return 1
fi
VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
2009-09-17 03:22:40 +04:00
for vg in $VGSLIST
do
action "Stopping monitoring for VG $vg:" "$VGCHANGE" --monitor n --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
2009-09-17 03:22:40 +04:00
done
return $ret
}
rtrn=1
# See how we were called.
case "$1" in
start)
rh_status_q && exit 0
2009-09-17 03:22:40 +04:00
start
rtrn=$?
[ "$rtrn" = 0 ] && touch "$LOCK_FILE"
2009-09-17 03:22:40 +04:00
;;
force-stop)
rh_status_q || exit 0
2009-09-17 03:22:40 +04:00
WARN=0
stop
rtrn=$?
[ "$rtrn" = 0 ] && rm -f "$LOCK_FILE"
2009-09-17 03:22:40 +04:00
;;
stop)
rh_status_q || exit 0
2009-09-17 03:22:40 +04:00
test "$runlevel" = "0" && WARN=0
test "$runlevel" = "6" && WARN=0
stop
rtrn=$?
[ "$rtrn" = 0 ] && rm -f "$LOCK_FILE"
2009-09-17 03:22:40 +04:00
;;
restart)
WARN=0
if stop
then
start
fi
rtrn=$?
;;
status)
rh_status
rtrn=$?
[ "$rtrn" = 0 ] && "$LVS" -S 'seg_monitor=monitored' -o lv_full_name,seg_monitor
2009-09-17 03:22:40 +04:00
;;
*)
echo $"Usage: $0 {start|stop|restart|status|force-stop}"
;;
esac
exit $rtrn