Splitting out swap handling and rewriting to a live-boot subscript.
[live-boot-grml.git] / scripts / boot.sh
index 5d4a20d..02ac43a 100755 (executable)
@@ -2,6 +2,12 @@
 
 # set -e
 
+if [ -e /scripts/functions ]
+then
+       # initramfs-tools specific (FIXME)
+       . /scripts/functions
+fi
+
 for _SCRIPT in /lib/live/boot/*
 do
        if [ -e "${_SCRIPT}" ]
@@ -35,7 +41,28 @@ then
        touch /etc/mtab
 fi
 
-. /scripts/live-helpers
+if [ ! -x "/bin/fstype" ]
+then
+       # klibc not in path -> not in initramfs
+       export PATH="${PATH}:/usr/lib/klibc/bin"
+fi
+
+# handle upgrade path from old udev (using udevinfo) to
+# recent versions of udev (using udevadm info)
+if [ -x /sbin/udevadm ]
+then
+       udevinfo='/sbin/udevadm info'
+else
+       udevinfo='udevinfo'
+fi
+
+old_root_overlay_label="live-rw"
+old_home_overlay_label="home-rw"
+custom_overlay_label="custom-ov"
+root_snapshot_label="live-sn"
+old_root_snapshot_label="live-sn"
+home_snapshot_label="home-sn"
+persistence_list="live-persistence.conf"
 
 if [ ! -f /live.vars ]
 then
@@ -402,32 +429,6 @@ find_livefs ()
        return 1
 }
 
-integrity_check ()
-{
-       media_mountpoint="${1}"
-
-       log_begin_msg "Checking media integrity"
-
-       cd ${media_mountpoint}
-       /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
-       RC="${?}"
-
-       log_end_msg
-
-       if [ "${RC}" -eq 0 ]
-       then
-               log_success_msg "Everything ok, will reboot in 10 seconds."
-               sleep 10
-               cd /
-               umount ${media_mountpoint}
-               sync
-               echo u > /proc/sysrq-trigger
-               echo b > /proc/sysrq-trigger
-       else
-               panic "Not ok, a media defect is likely, switch to VT8 for details."
-       fi
-}
-
 mountroot ()
 {
        if [ -x /scripts/local-top/cryptroot ]; then
@@ -441,15 +442,24 @@ mountroot ()
        tail -f boot.log >&7 &
        tailpid="${!}"
 
-       # Ensure 'panic' function is overridden
-       . /scripts/live-functions
+       . /live.vars
 
-       Arguments
+       _CMDLINE="$(cat /proc/cmdline)"
+       Cmdline
 
-       maybe_break live-premount
-       log_begin_msg "Running /scripts/live-premount"
-       run_scripts /scripts/live-premount
-       log_end_msg
+       case "${LIVE_DEBUG}" in
+               true)
+                       set -x
+                       ;;
+       esac
+
+       case "${LIVE_READ_ONLY}" in
+               true)
+                       Read_only
+                       ;;
+       esac
+
+       Select_eth_device
 
        # Needed here too because some things (*cough* udev *cough*)
        # changes the timeout
@@ -507,10 +517,11 @@ mountroot ()
                panic "Unable to find a medium containing a live file system"
        fi
 
-       if [ "${INTEGRITY_CHECK}" ]
-       then
-               integrity_check "${livefs_root}"
-       fi
+       case "${LIVE_VERIFY_CHECKSUMS}" in
+               true)
+                       Verify_checksums "${livefs_root}"
+                       ;;
+       esac
 
        if [ "${TORAM}" ]
        then
@@ -625,6 +636,12 @@ mountroot ()
        run_scripts /scripts/live-bottom
        log_end_msg
 
+       case "${LIVE_SWAPON}" in
+               true)
+                       Swapon
+                       ;;
+       esac
+
        if [ "${UNIONFS}" = unionfs-fuse ]
        then
                umount "${rootmnt}/dev"