utils (1179B)
1 # *-*-shell-*-* 2 3 msg() { 4 # bold 5 printf "\033[1m=> $@\033[m\n" 6 } 7 8 msg_ok() { 9 # bold/green 10 printf "\033[1m\033[32m OK\033[m\n" 11 } 12 13 msg_error() { 14 # bold/red 15 printf "\033[1m\033[31mERROR: $@\033[m\n" 16 } 17 18 msg_warn() { 19 # bold/yellow 20 printf "\033[1m\033[33mWARNING: $@\033[m\n" 21 } 22 23 emergency_shell() { 24 echo 25 echo "Cannot continue due to errors above, starting emergency shell." 26 echo "When ready type exit to continue booting." 27 /bin/sh -l 28 } 29 30 detect_virt() { 31 # Detect LXC (and other) containers 32 [ -z "${container+x}" ] || export VIRTUALIZATION=1 33 } 34 35 deactivate_vgs() { 36 _group=${1:-All} 37 if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then 38 vgs=$(vgs|wc -l) 39 if [ $vgs -gt 0 ]; then 40 msg "Deactivating $_group LVM Volume Groups..." 41 vgchange -an 42 fi 43 fi 44 } 45 46 deactivate_crypt() { 47 if [ -x /sbin/dmsetup -o -x /bin/dmsetup ]; then 48 msg "Deactivating Crypt Volumes" 49 for v in $(dmsetup ls --target crypt --exec "dmsetup info -c --noheadings -o open,name"); do 50 [ ${v%%:*} = "0" ] && cryptsetup close ${v##*:} 51 done 52 deactivate_vgs "Crypt" 53 fi 54 }