Adding upstream version 1.119.1.
[live-boot-grml.git] / scripts / live-helpers
index e74108c..807553a 100644 (file)
@@ -1,16 +1,6 @@
 #!/bin/sh
 # live-initramfs helper functions, used by live-initramfs on boot and by live-snapshot
 
-if [ "${BUILD_SYSTEM}" = "Ubuntu" ]
-then
-       MP_QUIET="-Q"
-elif [ "${BUILD_SYSTEM}" = "Debian" ]
-then
-       MP_QUIET="-q"
-else
-       MP_QUIET=""
-fi
-
 if [ ! -x "/bin/fstype" ]
 then
        # klibc not in path -> not in initramfs
@@ -44,6 +34,13 @@ get_fstype ()
        local FSTYPE
        local FSSIZE
 
+       # fstype misreports LUKS devices
+       is_luks "${1}"
+       if [ $? -eq 0 ]; then
+           /lib/udev/vol_id -t ${1} 2>/dev/null
+           return
+       fi
+
        eval $(fstype < ${1})
 
        if [ "${FSTYPE}" != "unknown" ]
@@ -157,7 +154,7 @@ setup_loop ()
        local offset=${4}
        local encryption=${5}
 
-       modprobe ${MP_QUIET} -b "${module}"
+       modprobe -q -b "${module}"
        udevsettle
 
        for loopdev in ${pattern}
@@ -278,7 +275,7 @@ find_files ()
                        devname=$(sys2dev "${dev}")
                        devfstype="$(get_fstype ${devname})"
 
-                       if [ "${devfstype}" = "vfat" ] ||  [ "${devfstype}" = "ext2" ] || [ "${devfstype}" = "ext3" ]
+                       if [ "${devfstype}" = "vfat" ] ||  [ "${devfstype}" = "ext2" ] || [ "${devfstype}" = "ext3" ] || [ "${devfstype}" = "jffs2" ]
                        then
                                # FIXME: all supported block devices should be scanned
                                mkdir -p "${snap_backing}"
@@ -298,3 +295,34 @@ find_files ()
                done
        done
 }
+
+get_mac ()
+{
+       mac=""
+
+       for adaptor in /sys/class/net/*
+       do
+               status="$(cat ${adaptor}/iflink)"
+
+               if [ "${status}" -eq 2 ]
+               then
+                       mac="$(cat ${adaptor}/address)"
+                       mac="$(echo ${mac} | sed 's/:/-/g' | tr '[a-z]' '[A-Z]')"
+               fi
+       done
+
+       echo ${mac}
+}
+
+is_luks()
+{
+    devname="${1}"
+    if [ -x /sbin/cryptsetup ]
+    then
+       /sbin/cryptsetup isLuks "${devname}" 2>/dev/null
+       return $?
+    else
+       return 1
+    fi
+
+}