Print friendly error message on live-initramfs panic.
[live-boot-grml.git] / scripts / live
index 62b5224..fb61d01 100755 (executable)
@@ -456,7 +456,7 @@ Arguments ()
 
        if [ -z "${UNIONTYPE}" ]
        then
-               UNIONTYPE="unionfs"
+               UNIONTYPE="aufs"
                export UNIONTYPE
        fi
 }
@@ -561,6 +561,9 @@ is_nice_device ()
        if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"
        then
                return 0
+       elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
+       then
+               return 0
        fi
 
        return 1
@@ -650,8 +653,16 @@ do_netmount ()
 
        modprobe -q af_packet # For DHCP
 
-       udevtrigger
-       udevsettle
+       if [ -x /sbin/udevadm ]
+       then
+               # lenny
+               udevadm trigger
+               udevadm settle
+       else
+               # etch
+               udevtrigger
+               udevsettle
+       fi
 
        ipconfig ${DEVICE} | tee /netboot.config
 
@@ -711,9 +722,20 @@ do_httpmount ()
                                squashfs|tgz|tar)
                                        if [ "${webfile}" = "FETCH" ]
                                        then
-                                               [ "${quiet}" != "y" ] &&
-                                                       log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
-                                               wget "${url}" -O "${dest}/$(basename ${url})"
+                                               case "$url" in
+                                                       tftp*)
+                                                               ip="$(dirname $url | sed -e 's|tftp://||g')"
+                                                               [ "${quiet}" != "y" ] &&
+                                                               log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url})  -l ${dest}/$(basename ${url}) $ip"
+                                                               tftp -g -b 10240 -r $(basename ${url})  -l ${dest}/$(basename ${url}) $ip
+                                                       ;;
+
+                                                       *)
+                                                               [ "${quiet}" != "y" ] &&
+                                                               log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
+                                                               wget "${url}" -O "${dest}/$(basename ${url})"
+                                                               ;;
+                                               esac
                                        else
                                                [ "${quiet}" != "y" ] &&
                                                        log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
@@ -875,7 +897,7 @@ try_snap ()
                        fi
                else
                        # cpio.gz snapshot
-                       if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i -u -d 2>/dev/null)
+                       if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1)
                        then
                                log_warning_msg "Impossible to include the ${snapfile} Snapshot"
                                return 1
@@ -1008,7 +1030,12 @@ setup_unionfs ()
                        rofslist="${image} ${rofslist}"
                elif [ -f "${image}" ]
                then
-                       backdev=$(get_backing_device "${image}" "-r")
+                       if losetup --help 2>&1 | grep -q -- "-r\b"
+                       then
+                               backdev=$(get_backing_device "${image}" "-r")
+                       else
+                               backdev=$(get_backing_device "${image}")
+                       fi
                        fstype=$(get_fstype "${backdev}")
 
                        if [ "${fstype}" = "unknown" ]
@@ -1036,8 +1063,16 @@ setup_unionfs ()
                        modprobe -q -b ${module}
                done
 
-               udevtrigger
-               udevsettle
+               if [ -x /sbin/udevadm ]
+               then
+                       # lenny
+                       udevadm trigger
+                       udevadm settle
+               else
+                       # etch
+                       udevtrigger
+                       udevsettle
+               fi
 
                # For some reason, udevsettle does not block in this scenario,
                # so we sleep for a little while.
@@ -1059,10 +1094,12 @@ setup_unionfs ()
                then
                        cowdevice=${cowprobe}
                        cow_fstype=$(get_fstype "${cowprobe}")
+                       cow_mountopt="rw,noatime"
                else
                        [ "${quiet}" != "y" ] && log_warning_msg "Unable to find the persistent medium"
                        cowdevice="tmpfs"
                        cow_fstype="tmpfs"
+                       cow_mountopt="rw,noatime,mode=755"
                fi
        elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
        then
@@ -1086,6 +1123,7 @@ setup_unionfs ()
        else
                cowdevice="tmpfs"
                cow_fstype="tmpfs"
+               cow_mountopt="rw,noatime,mode=755"
        fi
 
        if [ "${cow_fstype}" = "nfs" ]
@@ -1095,7 +1133,7 @@ setup_unionfs ()
                nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
                        panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
        else
-               mount -t ${cow_fstype} -o rw,noatime ${cowdevice} /cow || \
+               mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
                        panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
        fi
 
@@ -1173,7 +1211,7 @@ setup_unionfs ()
 
        # shows cow fs on /cow for use by live-snapshot
        mkdir -p "${rootmnt}/live/cow"
-       mount -o move /cow "${rootmnt}/live/cow"
+       mount -o move /cow "${rootmnt}/live/cow" || mount -o bind /cow "${rootmnt}/live/cow" || [ "${quiet}" != "y" ] && log_warning_msg "Unable to move or bind /cow to ${rootmnt}/live/cow"
 }
 
 check_dev ()
@@ -1187,12 +1225,6 @@ check_dev ()
                devname=$(sys2dev "${sysdev}")
        fi
 
-       if [ -n "${LIVE_MEDIA_OFFSET}" ]
-       then
-               loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
-               devname="${loopdevname}"
-       fi
-
        if [ -d "${devname}" ]
        then
                mount -o bind "${devname}" $mountpoint || continue
@@ -1206,6 +1238,12 @@ check_dev ()
                fi
        fi
 
+       if [ -n "${LIVE_MEDIA_OFFSET}" ]
+       then
+               loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
+               devname="${loopdevname}"
+       fi
+
        fstype=$(get_fstype "${devname}")
 
        if is_supported_fs ${fstype}
@@ -1312,6 +1350,9 @@ mountroot ()
        tail -f live.log >&7 &
        tailpid="${!}"
 
+       # Ensure 'panic' function is overridden
+       . /scripts/live-functions
+
        Arguments
 
        set_usplash_timeout