forked from void-linux/void-runit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions
57 lines (49 loc) · 1.2 KB
/
functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# *-*-shell-*-*
msg() {
# bold
printf "\033[1m=> $@\033[m\n"
}
msg_ok() {
# bold/green
printf "\033[1m\033[32m OK\033[m\n"
}
msg_error() {
# bold/red
printf "\033[1m\033[31mERROR: $@\033[m\n"
}
msg_warn() {
# bold/yellow
printf "\033[1m\033[33mWARNING: $@\033[m\n"
}
emergency_shell() {
echo
echo "Cannot continue due to errors above, starting emergency shell."
echo "When ready type exit to continue booting."
/bin/sh -l
}
detect_virt() {
# Detect LXC containers
[ ! -e /proc/self/environ ] && return
if grep -q lxc /proc/self/environ >/dev/null; then
export VIRTUALIZATION=1
fi
}
deactivate_vgs() {
_group=${1:-All}
if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
vgs=$(vgs|wc -l)
if [ $vgs -gt 0 ]; then
msg "Deactivating $_group LVM Volume Groups..."
vgchange -an
fi
fi
}
deactivate_crypt() {
if [ -x /sbin/dmsetup -o -x /bin/dmsetup ]; then
msg "Deactivating Crypt Volumes"
for v in $(dmsetup ls --target crypt --exec "dmsetup info -c --noheadings -o open,name"); do
[ ${v%%:*} = "0" ] && cryptsetup close ${v##*:}
done
deactivate_vgs "Crypt"
fi
}