Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/musl:master commit in: sys-fs/lvm2/files/
Date: Mon, 27 Apr 2020 12:45:51
Message-Id: 1587991491.d8d90c46de2431c9c848d58f6d3ef001fd3d17a3.blueness@gentoo
1 commit: d8d90c46de2431c9c848d58f6d3ef001fd3d17a3
2 Author: Petr Vaněk <arkamar <AT> atlas <DOT> cz>
3 AuthorDate: Sun Apr 26 10:05:00 2020 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Mon Apr 27 12:44:51 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=d8d90c46
7
8 sys-fs/lvm2: add missing rc script
9
10 Package-Manager: Portage-2.3.89, Repoman-2.3.20
11 Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
12
13 sys-fs/lvm2/files/lvm.rc-2.02.187 | 173 ++++++++++++++++++++++++++++++++++++++
14 1 file changed, 173 insertions(+)
15
16 diff --git a/sys-fs/lvm2/files/lvm.rc-2.02.187 b/sys-fs/lvm2/files/lvm.rc-2.02.187
17 new file mode 100644
18 index 0000000..3468adc
19 --- /dev/null
20 +++ b/sys-fs/lvm2/files/lvm.rc-2.02.187
21 @@ -0,0 +1,173 @@
22 +#!/sbin/openrc-run
23 +# Copyright 1999-2020 Gentoo Authors
24 +# Distributed under the terms of the GNU General Public License v2
25 +
26 +_get_lvm_path() {
27 + local lvm_path=
28 + for lvm_path in /bin/lvm /sbin/lvm ; do
29 + [ -x "${lvm_path}" ] && break
30 + done
31 + echo "${lvm_path}"
32 +}
33 +
34 +_use_lvmetad() {
35 + local lvm_path="$(_get_lvm_path)"
36 + [ ! -x "${lvm_path}" ] && return 1
37 + ${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmetad=1'
38 +}
39 +
40 +_use_lvmlockd() {
41 + local lvm_path="$(_get_lvm_path)"
42 + [ ! -x "${lvm_path}" ] && return 1
43 + ${lvm_path} dumpconfig global 2>/dev/null | grep -q 'use_lvmlockd=1'
44 +}
45 +
46 +depend() {
47 + before checkfs fsck
48 + after modules device-mapper
49 + # We may want lvmetad based on the configuration. If we added lvmetad
50 + # support while lvm2 is running then we aren't dependent on it. For the
51 + # more common case, if its disabled in the config we aren't dependent
52 + # on it.
53 + config /etc/lvm/lvm.conf
54 + local _want=
55 +
56 + if service_started ; then
57 + _want=$(service_get_value want)
58 + else
59 + if _use_lvmetad ; then
60 + _want="${_want} lvmetad"
61 + fi
62 +
63 + if _use_lvmlockd ; then
64 + _want="${_want} lvmlockd"
65 + fi
66 + fi
67 +
68 + # Make sure you review /etc/conf.d/lvm as well!
69 + # Depending on your system, it might also introduce udev & mdraid
70 + need sysfs
71 +
72 + if [ -n "${_want}" ] ; then
73 + want ${_want}
74 + fi
75 +}
76 +
77 +config='global { locking_dir = "/run/lock/lvm" }'
78 +
79 +dm_in_proc() {
80 + local retval=0
81 + for x in devices misc ; do
82 + grep -qs 'device-mapper' /proc/${x}
83 + retval=$((${retval} + $?))
84 + done
85 + return ${retval}
86 +}
87 +
88 +start() {
89 + # LVM support for /usr, /home, /opt ....
90 + # This should be done *before* checking local
91 + # volumes, or they never get checked.
92 +
93 + # NOTE: Add needed modules for LVM or RAID, etc
94 + # to /etc/modules.autoload if needed
95 +
96 + lvm_path="$(_get_lvm_path)"
97 + if [ -z "${lvm_path}" ] ; then
98 + eerror "Failed to find lvm binary in /bin or /sbin!"
99 + return 1
100 + fi
101 +
102 + if [ -z "${CDBOOT}" ] ; then
103 + if [ -e /proc/modules ] && ! dm_in_proc ; then
104 + ebegin "Trying to load dm-mod module"
105 + modprobe dm-mod 2>/dev/null
106 + eend $?
107 + fi
108 +
109 + if [ -d /proc/lvm ] || dm_in_proc ; then
110 + local has_errors=0 verbose_command
111 +
112 + yesno "${rc_verbose}" && verbose_command=" -v"
113 +
114 + ebegin "Starting the Logical Volume Manager"
115 +
116 + if _use_lvmetad ; then
117 + # Extra PV find pass because some devices might not have been available until very recently
118 + ${lvm_path} pvscan${verbose_command} --config "${config}" --cache
119 + [ $? -ne 0 ] && has_errors=1
120 + fi
121 +
122 + # Now make the nodes
123 + ${lvm_path} vgscan${verbose_command} --config "${config}" --mknodes
124 + [ $? -ne 0 ] && has_errors=1
125 +
126 + # Enable all VGs
127 + ${lvm_path} vgchange${verbose_command} --config "${config}" --sysinit --activate y
128 + [ $? -ne 0 ] && has_errors=1
129 +
130 + if _use_lvmlockd ; then
131 + # Start lockd VGs as required
132 + ${lvm_path} vgchange${verbose_command} --config "${config}" --lock-start --lock-opt auto
133 + [ $? -ne 0 ] && has_errors=1
134 + fi
135 +
136 + eend ${has_errors} "Failed to start the Logical Volume Manager"
137 + fi
138 + fi
139 +}
140 +
141 +start_post() {
142 + local _want=
143 + if _use_lvmetad ; then
144 + _want="${_want} lvmetad"
145 + fi
146 +
147 + if _use_lvmlockd ; then
148 + _want="${_want} lvmlockd"
149 + fi
150 +
151 + service_set_value want "${_want}"
152 +}
153 +
154 +stop() {
155 + lvm_path="$(_get_lvm_path)"
156 + if [ -z "${lvm_path}" ] ; then
157 + eerror "Failed to find lvm binary in /bin or /sbin!"
158 + return 1
159 + fi
160 +
161 + # Stop LVM2
162 + if [ -f /etc/lvmtab -o -d /etc/lvm ] \
163 + && [ -d /proc/lvm -o "$(grep device-mapper /proc/misc 2>/dev/null)" ]
164 + then
165 + local VGS=$($lvm_path vgs --config "${config}" -o vg_name --noheadings --nosuffix --rows 2> /dev/null)
166 + if [ -z "${VGS}" ] ; then
167 + # nothing to do for us
168 + return 0
169 + fi
170 +
171 + local has_errors=0 verbose_command eend_cmd="eend"
172 +
173 + yesno "${rc_verbose}" && verbose_command=" -v"
174 +
175 + local msg="Failed to stop Logical Volume Manager"
176 + if [ "${RC_RUNLEVEL}" = shutdown ] ; then
177 + # failures on shutdown are non-fatal
178 + eend_cmd="ewend"
179 + msg="${msg} (possibly some LVs still needed for /usr or root)"
180 + fi
181 +
182 + ebegin "Stopping the Logical Volume Manager"
183 +
184 + ${lvm_path} vgchange${verbose_command} --config "${config}" --sysinit --activate n
185 + [ $? -ne 0 ] && has_errors=1
186 +
187 + ${eend_cmd} ${has_errors} "${msg}"
188 + fi
189 +
190 + # at this point make sure we always exit without indicating an error
191 + return 0
192 +}
193 +
194 +# vim:ts=4