Adding upstream version 1.154.6.
[live-boot-grml.git] / scripts / live
index 389fc21..bf90781 100755 (executable)
@@ -109,6 +109,11 @@ Arguments ()
                                export IGNORE_UUID
                                ;;
 
+                       integrity-check)
+                               INTEGRITY_CHECK="Yes"
+                               export INTEGRITY_CHECK
+                               ;;
+
                        ip=*)
                                STATICIP="${ARGUMENT#ip=}"
 
@@ -335,6 +340,11 @@ Arguments ()
                                export PERSISTENT
                                ;;
 
+                       persistent-path=*)
+                               PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
+                               export PERSISTENT_PATH
+                               ;;
+
                        nopersistent)
                                NOPERSISTENT="Yes"
                                export NOPERSISTENT
@@ -422,6 +432,11 @@ Arguments ()
                                export PLAIN_ROOT
                                ;;
 
+                       skipunion)
+                                SKIP_UNION_MOUNTS="Yes"
+                                export SKIP_UNION_MOUNTS
+                                ;;
+
                        root=*)
                                ROOT="${ARGUMENT#root=}"
                                export ROOT
@@ -1080,6 +1095,12 @@ setup_unionfs ()
        do
                imagename=$(basename "${image}")
 
+               export image devname
+               maybe_break live-realpremount
+               log_begin_msg "Running /scripts/live-realpremount"
+               run_scripts /scripts/live-realpremount
+               log_end_msg
+
                if [ -d "${image}" ]
                then
                        # it is a plain directory: do nothing
@@ -1237,8 +1258,12 @@ setup_unionfs ()
                mount --bind ${exposedrootfs} ${rootmnt} || \
                        panic "bind mount of ${exposedrootfs} failed"
 
-               cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
-                       /home /var/lib/live'
+               if [ -z "${SKIP_UNION_MOUNTS}" ]
+               then
+                       cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
+               else
+                       cow_dirs=''
+               fi
 
                for dir in ${cow_dirs}; do
                        mkdir -p /cow${dir}
@@ -1426,6 +1451,32 @@ set_usplash_timeout ()
        fi ; fi
 }
 
+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
@@ -1492,6 +1543,11 @@ mountroot ()
                panic "Unable to find a medium containing a live file system"
        fi
 
+       if [ "${INTEGRITY_CHECK}" ]
+       then
+               integrity_check "${livefs_root}"
+       fi
+
        if [ "${TORAM}" ]
        then
                live_dest="ram"
@@ -1519,7 +1575,7 @@ mountroot ()
        log_end_msg
 
        maybe_break live-bottom
-       log_begin_msg "Running /scripts/live-bottom"
+       log_begin_msg "Running /scripts/live-bottom\n"
 
        run_scripts /scripts/live-bottom
        log_end_msg