summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Goldstein <cardoe@gentoo.org>2016-03-14 22:56:59 -0500
committerDoug Goldstein <cardoe@gentoo.org>2016-03-14 22:58:54 -0500
commitd537027f4c66273bd05b9b9105f8fd1b5ab25f31 (patch)
tree6c98617dec435fcf7e79d9594bc4f7cc645e61c5 /sys-fs/lvm2/files/lvm.rc-2.02.116-r6
parentdev-python/aniso8601: add missing python-dateutil rdep and py35 support (diff)
downloadgentoo-d537027f4c66273bd05b9b9105f8fd1b5ab25f31.tar.gz
gentoo-d537027f4c66273bd05b9b9105f8fd1b5ab25f31.tar.bz2
gentoo-d537027f4c66273bd05b9b9105f8fd1b5ab25f31.zip
sys-fs/lvm2: make depend() in lvm init script quiet
The depend() function makes a call to lvm which can produce output on stderr which might seem concerning to some but is really just harmless. We are checking to see if we need lvmetad to be able to start up properly. At the same time make sure all possible versions receive updated init scripts. Gentoo-Bug: 577308 Gentoo-Bug: 573384 Package-Manager: portage-2.2.26 Signed-off-by: Doug Goldstein <cardoe@gentoo.org>
Diffstat (limited to 'sys-fs/lvm2/files/lvm.rc-2.02.116-r6')
-rw-r--r--sys-fs/lvm2/files/lvm.rc-2.02.116-r6133
1 files changed, 133 insertions, 0 deletions
diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.116-r6 b/sys-fs/lvm2/files/lvm.rc-2.02.116-r6
new file mode 100644
index 000000000000..db7c3a4ec7c1
--- /dev/null
+++ b/sys-fs/lvm2/files/lvm.rc-2.02.116-r6
@@ -0,0 +1,133 @@
+#!/sbin/runscript
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+_get_lvm_path() {
+ local lvm_path=
+ for lvm_path in /bin/lvm /sbin/lvm ; do
+ [ -x "$lvm_path" ] && break
+ done
+ echo "${lvm_path}"
+}
+
+_need_lvmetad()
+{
+ local lvm_path="$(_get_lvm_path)"
+ [ ! -x "${lvm_path}" ] && return 1
+ ${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmetad=1'
+}
+
+depend() {
+ before checkfs fsck
+ after modules device-mapper
+ # We may use lvmetad based on the configuration. If we added lvmetad
+ # support while lvm2 is running then we aren't dependent on it. For the
+ # more common case, if its disabled in the config we aren't dependent
+ # on it.
+ config /etc/lvm/lvm.conf
+ local _need=
+ if service_started; then
+ _need=$(service_get_value need)
+ else
+ if _need_lvmetad; then
+ _need="${_need} lvmetad"
+ fi
+ fi
+ need sysfs ${_need}
+}
+
+config='global { locking_dir = "/run/lock/lvm" }'
+
+dm_in_proc() {
+ local retval=0
+ for x in devices misc ; do
+ grep -qs 'device-mapper' /proc/${x}
+ retval=$((${retval} + $?))
+ done
+ return ${retval}
+}
+
+start() {
+ # LVM support for /usr, /home, /opt ....
+ # This should be done *before* checking local
+ # volumes, or they never get checked.
+
+ # NOTE: Add needed modules for LVM or RAID, etc
+ # to /etc/modules.autoload if needed
+ lvm_path="$(_get_lvm_path)"
+ for lvm_path in /bin/lvm /sbin/lvm ; do
+ [ -x "$lvm_path" ] && break
+ done
+ if [ ! -x "$lvm_path" ]; then
+ eerror "Cannot find lvm binary in /sbin or /bin!"
+ return 1
+ fi
+ if [ -z "${CDBOOT}" ] ; then
+ if [ -e /proc/modules ] && ! dm_in_proc ; then
+ modprobe dm-mod 2>/dev/null
+ fi
+ if [ -d /proc/lvm ] || dm_in_proc ; then
+ ebegin "Setting up the Logical Volume Manager"
+ #still echo stderr for debugging
+ lvm_commands="#! ${lvm_path} --config '${config}'\n"
+ # Extra PV find pass because some devices might not have been available until very recently
+ lvm_commands="${lvm_commands}pvscan\n"
+ # Now make the nodes
+ lvm_commands="${lvm_commands}vgscan --mknodes\n"
+ # And turn them on!
+ lvm_commands="${lvm_commands}vgchange --sysinit -a ly\n"
+ # Order of this is important, have to work around dash and LVM readline
+ printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
+ eend $? "Failed to setup the LVM"
+ fi
+ fi
+}
+
+start_post()
+{
+ # Save if we needed lvmetad
+ if _need_lvmetad; then
+ service_set_value need lvmetad
+ fi
+}
+
+stop() {
+ for lvm_path in /bin/lvm /sbin/lvm ; do
+ [ -x "$lvm_path" ] && break
+ done
+ if [ ! -x "$lvm_path" ]; then
+ eerror "Cannot find lvm binary in /sbin or /bin!"
+ return 1
+ fi
+# Stop LVM2
+if [ -x /sbin/vgs ] && \
+ [ -x /sbin/vgchange ] && \
+ [ -x /sbin/lvchange ] && \
+ [ -f /etc/lvmtab -o -d /etc/lvm ] && \
+ [ -d /proc/lvm -o "`grep device-mapper /proc/misc 2>/dev/null`" ]
+then
+ einfo "Shutting down the Logical Volume Manager"
+
+ VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
+
+ if [ "$VGS" ]
+ then
+ ebegin " Shutting Down LVs & VGs"
+ #still echo stderr for debugging
+ lvm_commands="#! ${lvm_path} --config '${config}'\n"
+ # Extra PV find pass because some devices might not have been available until very recently
+ lvm_commands="${lvm_commands}lvchange --sysinit -a ln ${VGS}\n"
+ # Now make the nodes
+ lvm_commands="${lvm_commands}vgchange --sysinit -a ln ${VGS}\n"
+ # Order of this is important, have to work around dash and LVM readline
+ printf "%b\n" "${lvm_commands}" | $lvm_path /proc/self/fd/0 --config "${config}" >/dev/null
+ eend $? "Failed (possibly some LVs still needed for /usr or root)"
+ fi
+
+ einfo "Finished shutting down the Logical Volume Manager"
+ return 0
+fi
+}
+
+# vim:ts=4