Adding live-initramfs 1.87.1-1.
[live-boot-grml.git] / scripts / casper
old mode 100644 (file)
new mode 100755 (executable)
index 7358f85..a4c78b3
@@ -4,22 +4,20 @@
 
 export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin
 
-mountpoint=/live_media
+echo "/root/lib" >> /etc/ld.so.conf
+echo "/root/usr/lib" >> /etc/ld.so.conf
 
-root_persistence="casper-rw"
-home_persistence="home-rw"
-root_snapshot_label="casper-sn"
-home_snapshot_label="home-sn"
+mountpoint=/cdrom
 
-USERNAME="casper"
+USERNAME=casper
 USERFULLNAME="Live session user"
-HOSTNAME="live"
-BUILD_SYSTEM="Debian"
+HOST=live
+BUILD_SYSTEM=Custom
 
 mkdir -p $mountpoint
 
 [ -f /etc/casper.conf ] && . /etc/casper.conf
-export USERNAME USERFULLNAME HOSTNAME BUILD_SYSTEM
+export USERNAME USERFULLNAME HOST BUILD_SYSTEM
 
 . /scripts/casper-helpers
 
@@ -27,90 +25,6 @@ if [ ! -f /casper.vars ]; then
     touch /casper.vars
 fi
 
-parse_cmdline ()
-{
-    PRESEEDS=
-    # looking for casper specifics options as kernel parameters
-    for x in $(cat /proc/cmdline); do
-        case $x in
-            userfullname=*)
-                export USERFULLNAME=${x#userfullname=}
-                export CASPERCONF="changed"
-                ;;
-            hostname=*)
-                export HOSTNAME=${x#hostname=}
-                export CASPERCONF="changed"
-                ;;
-            username=*)
-                export USERNAME=${x#username=}
-                export CASPERCONF="changed"
-                ;;
-            netboot*)
-                export NETBOOT=${x#netboot=} ;;
-            access=*)
-                export ACCESS=${x#access=} ;;
-            xdebconf)
-                export XDEBCONF="Yes" ;;
-            toram)
-                export TORAM="Yes" ;;
-            todisk=*)
-                export TODISK=${x#todisk=} ;;
-            showmounts)
-                export SHOWMOUNTS="Yes" ;;
-            persistent)
-                export PERSISTENT="Yes" ;;
-            nopersistent)
-                export PERSISTENT="" ;;
-            ip*)
-                STATICIP=${x#ip=}
-                if [ "${STATICIP}" == "" ]; then
-                    STATICIP="frommedia"
-                fi
-                export STATICIP ;;
-            casper-getty)
-                export CASPERGETTY=1 ;;
-            bootfrom=*|live-media=*)
-                export LIVEMEDIA=${x#*=} ;;
-            live-media-timeout=*)
-                export LIVEMEDIA_TIMEOUT=${x#live-media-timeout=} ;;
-            live-media-offset=*)
-                export LIVEMEDIA_OFFSET=${x#live-media-offset=} ;;
-            locale=*|debian-installer/locale=*)
-                export LOCALE=${x#*=} ;;
-            keyb=*|kbd-chooser/method=*)
-                export KBD=${x#*=} ;;
-            klayout=*|console-setup/layoutcode=*)
-                export KLAYOUT=${x#*=} ;;
-            koptions=*)
-                export KOPTIONS=${x#koptions=} ;;
-            kvariant=*|console-setup/variantcode=*)
-                export KVARIANT=${x#*=} ;;
-            kmodel=*|console-setup/modelcode=*)
-                export KMODEL=${x#*=} ;;
-            preseed/file=*|file=*)
-                export LOCATION="${x#*=}" ;;
-            */*=*)
-                question="${x%%=*}"
-                value="${x#*=}"
-                PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
-                ;;
-            console=*)
-                export DEFCONSOLE=$(sed -e 's%.*console=%console=%' /proc/cmdline) ;;
-        esac
-    done
-
-    # sort of compatibility with netboot.h from linux docs
-    if [ -z "${NETBOOT}" ]; then
-        if [ "${ROOT}" == "/dev/nfs" ]; then
-            NETBOOT="nfs"
-            export NETBOOT
-        elif [ "${ROOT}" == "/dev/cifs" ]; then
-            NETBOOT="cifs"
-            export NETBOOT
-        fi
-    fi
-}
-
 is_casper_path() {
     path=$1
     if [ -d "$path/casper" ]; then
@@ -167,8 +81,7 @@ is_nice_device() {
     return 1
 }
 
-is_supported_fs ()
-{
+is_supported_fs () {
     # FIXME: do something better like the scan of supported filesystems
     fstype="${1}"
     case ${fstype} in
@@ -226,6 +139,9 @@ do_netmount() {
 
     modprobe "${MP_QUIET}" af_packet # For DHCP
 
+    udevtrigger
+    udevsettle
+
     ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config
 
     if [ "${NFSROOT}" = "auto" ]; then
@@ -398,7 +314,7 @@ setup_unionfs() {
     # Let's just mount the read-only file systems first
     rofsstring=""
     rofslist=""
-    if [ "${NETBOOT}" == "nfs" ] ; then
+    if [ "${NETBOOT}" = "nfs" ] ; then
         roopt="nfsro" # go aroung a bug in nfs-unionfs locking
     else
         roopt="ro"
@@ -470,11 +386,17 @@ setup_unionfs() {
                     ;;
             esac
         done
+        # shows cow fs on /cow for use by casper-snapshot
+        mkdir -p "${rootmnt}/cow"
+        mount -o bind /cow "${rootmnt}/cow"
     fi
 
-    # shows cow fs on /cow for use by casper-snapshot
-    mkdir -p "${rootmnt}/cow"
-    mount -o bind /cow "${rootmnt}/cow"
+    # move the first mount; no head in busybox-initramfs
+    for d in $(mount -t squashfs | cut -d\  -f 3); do
+        mkdir -p "${rootmnt}/rofs"
+        mount -o move "${d}" "${rootmnt}/rofs"
+        break
+    done
 }
 
 check_dev ()
@@ -567,8 +489,6 @@ mountroot() {
     exec > casper.log
     exec 2>&1
 
-    parse_cmdline
-
     set_usplash_timeout
     [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount"
     pulsate
@@ -584,13 +504,13 @@ mountroot() {
         if do_netmount ; then
             livefs_root="${mountpoint}"
         else
-            panic "Unable to find a the network rootfs live file system"
+            panic "Unable to find a live file system on the network"
         fi
     else
         # Scan local devices for the image
         for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do
             livefs_root=$(find_livefs $i)
-            if [ -n "${livefs_root}" ]; then
+            if [ "${livefs_root}" ]; then
                 break
             fi
             sleep 1
@@ -601,15 +521,15 @@ mountroot() {
         panic "Unable to find a medium containing a live file system"
     fi
 
-    if [ -n "${TORAM}" ]; then
+    if [ "${TORAM}" ]; then
         live_dest="ram"
-    elif [ -n "${TODISK}" ]; then
+    elif [ "${TODISK}" ]; then
         live_dest="${TODISK}"
     fi
-    if [ -n "${live_dest}" ]; then
-        [ "$quiet" != "y" ] && log_begin_msg "Copying live_media to ${live_dest}"
+    if [ "${live_dest}" ]; then
+        log_begin_msg "Copying live_media to ${live_dest}"
         copy_live_to "${livefs_root}" "${live_dest}"
-        [ "$quiet" != "y" ] && log_end_msg
+        log_end_msg
     fi
 
     mount_images_in_directory "${livefs_root}" "${rootmnt}"