Removing getty and login wrappers, live-config takes care about that now.
[live-boot-grml.git] / scripts / live
index ec3a639..c525c80 100755 (executable)
@@ -8,6 +8,7 @@ echo "/root/lib" >> /etc/ld.so.conf
 echo "/root/usr/lib" >> /etc/ld.so.conf
 
 mountpoint="/live/image"
+alt_mountpoint="/media"
 LIVE_MEDIA_PATH="live"
 
 root_persistence="live-rw"
@@ -33,9 +34,6 @@ then
        touch /etc/mtab
 fi
 
-[ -f /etc/live.conf ] && . /etc/live.conf
-export USERNAME USERFULLNAME HOSTNAME
-
 . /scripts/live-helpers
 
 if [ ! -f /live.vars ]
@@ -43,35 +41,6 @@ then
        touch /live.vars
 fi
 
-network_started=
-
-start_network ()
-{
-       [ -z "$network_started" ] || return
-       [ -z "$NETBOOT" ] || return
-
-       mount -n -o bind /sys /root/sys
-       mount -n -o bind /proc /root/proc
-       mount -n -o bind /dev /root/dev
-       mkdir -p /root/var/run/network
-
-       # Close inherited fd's to prevent debconf-communicate from
-       # continuing to run post-live-initramfs.
-       chroot /root dhclient eth0 3>&- 4<&-
-
-       network_started=1
-}
-
-stop_network ()
-{
-       [ "$network_started" ] || return
-
-       chroot /root ifconfig eth0 down
-       umount /root/sys
-       umount /root/proc
-       umount /root/dev
-}
-
 Arguments ()
 {
        PRESEEDS=""
@@ -82,31 +51,14 @@ Arguments ()
                case "${ARGUMENT}" in
                        skipconfig)
                                NOACCESSIBILITY="Yes"
-                               NOAPPARMOR="Yes"
-                               NOAPTCDROM="Yes"
                                NOAUTOLOGIN="Yes"
                                NOCONSOLEKEYBOARD="Yes"
                                NOFASTBOOT="Yes"
                                NOFSTAB="Yes"
-                               NOGNOMEPANEL="Yes"
-                               NOHOSTS="Yes"
-                               NOJOCKEY="Yes"
-                               NOKPERSONALIZER="Yes"
-                               NOLANGUAGESELECTOR="Yes"
-                               NOLOCALES="Yes"
                                NONETWORKING="Yes"
-                               NOPOLKITCONF="Yes"
-                               NOPOWERMANAGEMENT="Yes"
-                               NOPROGRAMCRASHES="Yes"
-                               NOSUDO="Yes"
-                               NOTIMEZONE="Yes"
-                               NOUPDATENOTIFIER="Yes"
-                               NOUSER="Yes"
                                NOXAUTOCONFIG="Yes"
-                               NOXAUTOLOGIN="Yes"
-                               NOXSCREENSAVER="Yes"
 
-                               export NOACCESSIBILITY NOAPPARMOR NOAPTCDROM NOAUTOLOGIN NOCONSOLEKEYBOARD NOFASTBOOT NOFSTAB NOGNOMEPANEL NOHOSTS NOJOCKEY NOKPERSONALIZER NOLANGUAGESELECTOR NOLOCALES NONETWORKING NOPOLKITCONF NOPOWERMANAGEMENT NOPROGRAMCRASHES NOSUDO NOTIMEZONE NOUPDATENOTIFIER NOUSER NOXAUTOCONFIG NOXAUTOLOGIN NOXSCREENSAVER
+                               export NOACCESSIBILITY NOAUTOLOGIN NOCONSOLEKEYBOARD NOFASTBOOT NOFSTAB NONETWORKING NOXAUTOCONFIG
                                ;;
 
                        access=*)
@@ -126,6 +78,17 @@ Arguments ()
                                set -x
                                ;;
 
+                       dhcp)
+                               # Force dhcp even while netbooting
+                               # Use for debugging in case somebody works on fixing dhclient
+                               DHCP="Force";
+                               export DHCP
+                               ;;
+
+                       nodhcp)
+                               unset DHCP
+                               ;;
+
                        ethdevice=*)
                                DEVICE="${ARGUMENT#ethdevice=}"
                                export DEVICE
@@ -151,11 +114,6 @@ Arguments ()
                                export FORCEPERSISTENTFSCK
                                ;;
 
-                       hook=*)
-                               HOOK="${ARGUMENT#hook=}"
-                               export HOOK
-                               ;;
-
                        ftpfs=*)
                                FTPFS="${ARGUMENT#ftpfs=}"
                                export FTPFS
@@ -166,29 +124,11 @@ Arguments ()
                                export HTTPFS
                                ;;
 
-                       hostname=*)
-                               HOSTNAME="${ARGUMENT#hostname=}"
-                               LIVECONF="changed"
-                               export HOSTNAME LIVECONF
-                               ;;
-
                        isofrom=*|fromiso=*)
                                FROMISO="${ARGUMENT#*=}"
                                export FROMISO
                                ;;
 
-                       username=*)
-                               USERNAME="${ARGUMENT#username=}"
-                               LIVECONF="changed"
-                               export USERNAME LIVECONF
-                               ;;
-
-                       userfullname=*)
-                               USERFULLNAME="${ARGUMENT#userfullname=}"
-                               LIVECONF="changed"
-                               export USERFULLNAME LIVECONF
-                               ;;
-
                        ignore_uuid)
                                IGNORE_UUID="Yes"
                                export IGNORE_UUID
@@ -210,31 +150,6 @@ Arguments ()
                                export STATICIP
                                ;;
 
-                       keyb=*|kbd-chooser/method=*)
-                               KBD="${ARGUMENT#*=}"
-                               export KBD
-                               ;;
-
-                       klayout=*|console-setup/layoutcode=*)
-                               KLAYOUT="${ARGUMENT#*=}"
-                               export KLAYOUT
-                               ;;
-
-                       kvariant=*|console-setup/variantcode=*)
-                               KVARIANT="${ARGUMENT#*=}"
-                               export KVARIANT
-                               ;;
-
-                       kmodel=*|console-setup/modelcode=*)
-                               KMODEL="${ARGUMENT#*=}"
-                               export KMODEL
-                               ;;
-
-                       koptions=*)
-                               KOPTIONS="${ARGUMENT#koptions=}"
-                               export KOPTIONS
-                               ;;
-
                        live-getty)
                                LIVE_GETTY="1"
                                export LIVE_GETTY
@@ -265,17 +180,6 @@ Arguments ()
                                export LIVE_MEDIA_TIMEOUT
                                ;;
 
-                       language=*|debian-installer/language=*)
-                               language=${x#debian-installer/language=}
-                               locale="$(lang2locale "$language")"
-                               set_locale="true"
-                               ;;
-
-                       locale=*|debian-installer/locale=*)
-                               LOCALE="${ARGUMENT#*=}"
-                               export LOCALE
-                               ;;
-
                        module=*)
                                MODULE="${ARGUMENT#module=}"
                                export MODULE
@@ -301,31 +205,11 @@ Arguments ()
                                export NOACCESSIBILITY
                                ;;
 
-                       noapparmor)
-                               NOAPPARMOR="Yes"
-                               export NOAPPARMOR
-                               ;;
-
-                       noaptcdrom)
-                               NOAPTCDROM="Yes"
-                               export NOAPTCDROM
-                               ;;
-
                        noautologin)
                                NOAUTOLOGIN="Yes"
                                export NOAUTOLOGIN
                                ;;
 
-                       noxautologin)
-                               NOXAUTOLOGIN="Yes"
-                               export NOXAUTOLOGIN
-                               ;;
-
-                       noconsolekeyboard)
-                               NOCONSOLEKEYBOARD="Yes"
-                               export NOCONSOLEKEYBOARD
-                               ;;
-
                        nofastboot)
                                NOFASTBOOT="Yes"
                                export NOFASTBOOT
@@ -336,81 +220,21 @@ Arguments ()
                                export NOFSTAB
                                ;;
 
-                       nognomepanel)
-                               NOGNOMEPANEL="Yes"
-                               export NOGNOMEPANEL
-                               ;;
-
-                       nohosts)
-                               NOHOSTS="Yes"
-                               export NOHOSTS
-                               ;;
-
-                       nokpersonalizer)
-                               NOKPERSONALIZER="Yes"
-                               export NOKPERSONALIZER
-                               ;;
-
-                       nolanguageselector)
-                               NOLANGUAGESELECTOR="Yes"
-                               export NOLANGUAGESELECTOR
-                               ;;
-
-                       nolocales)
-                               NOLOCALES="Yes"
-                               export NOLOCALES
-                               ;;
-
                        nonetworking)
                                NONETWORKING="Yes"
                                export NONETWORKING
                                ;;
 
-                       nopowermanagement)
-                               NOPOWERMANAGEMENT="Yes"
-                               export NOPOWERMANAGEMENT
-                               ;;
-
-                       noprogramcrashes)
-                               NOPROGRAMCRASHES="Yes"
-                               export NOPROGRAMCRASHES
-                               ;;
-
-                       nojockey)
-                               NOJOCKEY="Yes"
-                               export NOJOCKEY
-                               ;;
-
-                       nosudo)
-                               NOSUDO="Yes"
-                               export NOSUDO
-                               ;;
-
                        swapon)
                                SWAPON="Yes"
                                export SWAPON
                                ;;
 
-                       noupdatenotifier)
-                               NOUPDATENOTIFIER="Yes"
-                               export NOUPDATENOTIFIER
-                               ;;
-
-                       nouser)
-                               NOUSER="Yes"
-                               export NOUSER
-                               ;;
-
                        noxautoconfig)
                                NOXAUTOCONFIG="Yes"
                                export NOXAUTOCONFIG
                                ;;
 
-                       noxscreensaver)
-                               NOXSCREENSAVER="Yes"
-                               export NOXSCREENSAVER
-                               ;;
-
                        persistent)
                                PERSISTENT="Yes"
                                export PERSISTENT
@@ -457,14 +281,6 @@ Arguments ()
                                export NOPRESEED
                                ;;
 
-                       url=*)
-                               URL_LOCATION="${ARGUMENT#url=}"
-
-                               start_network
-                               chroot /root wget -P /tmp "${URL_LOCATION}"
-                               LOCATIONS="/tmp/$(basename ${URL_LOCATION}) ${LOCATIONS}"
-                               ;;
-
                        */*=*)
                                question="${ARGUMENT%%=*}"
                                value="${ARGUMENT#*=}"
@@ -482,21 +298,6 @@ Arguments ()
                                export SILENT
                                ;;
 
-                       textonly)
-                               TEXTONLY="Yes"
-                               export TEXTONLY
-                               ;;
-
-                       timezone=*)
-                               TIMEZONE="${ARGUMENT#timezone=}"
-                               export TIMEZONE
-                               ;;
-
-                       notimezone)
-                               NOTIMEZONE="Yes"
-                               export NOTIMEZONE
-                               ;;
-
                        todisk=*)
                                TODISK="${ARGUMENT#todisk=}"
                                export TODISK
@@ -538,11 +339,6 @@ Arguments ()
                                export UNIONTYPE
                                ;;
 
-                       utc=*)
-                               UTC="${ARGUMENT#utc=}"
-                               export UTC
-                               ;;
-
                        xdebconf)
                                XDEBCONF="Yes"
                                export XDEBCONF
@@ -795,8 +591,6 @@ copy_live_to ()
 
 do_netmount ()
 {
-       rc=1
-
        modprobe -q af_packet # For DHCP
 
        udevadm trigger
@@ -874,10 +668,12 @@ do_netmount ()
                NFSROOT=${ROOTSERVER}:${ROOTPATH}
        fi
 
-       if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
+       rc=1
+
+       if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] )
        then
-               rc=0
-               return ${rc}
+               do_httpmount
+               return $?
        fi
 
        if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
@@ -904,19 +700,25 @@ do_netmount ()
 do_httpmount ()
 {
        rc=1
-       dest="${mountpoint}/${LIVE_MEDIA_PATH}"
-       mount -t ramfs ram "${mountpoint}"
-       mkdir -p "${dest}"
 
        for webfile in HTTPFS FTPFS FETCH
        do
-               url="$(eval echo \"\$\{${webfile}\}\")"
-               extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
+               local url="$(eval echo \"\$\{${webfile}\}\")"
+               local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
 
                if [ -n "$url" ]
                then
                        case "${extension}" in
-                               squashfs|tgz|tar)
+                               iso|squashfs|tgz|tar)
+                                       if [ "${extension}" = "iso" ]
+                                       then
+                                               mkdir -p "${alt_mountpoint}"
+                                               dest="${alt_mountpoint}"
+                                       else
+                                               local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
+                                               mount -t ramfs ram "${mountpoint}"
+                                               mkdir -p "${dest}"
+                                       fi
                                        if [ "${webfile}" = "FETCH" ]
                                        then
                                                case "$url" in
@@ -947,6 +749,12 @@ do_httpmount ()
                                        fi
                                        [ ${?} -eq 0 ] && rc=0
                                        [ "${extension}" = "tgz" ] && live_dest="ram"
+                                       if [ "${extension}" = "iso" ]
+                                       then
+                                               isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
+                                               mount -t iso9660 "${isoloop}" "${mountpoint}"
+                                               rc=${?}
+                                       fi
                                        break
                                        ;;
 
@@ -959,7 +767,15 @@ do_httpmount ()
 
        if [ ${rc} != 0 ]
        then
-           umount "${mountpoint}"
+               if [ -d "${alt_mountpoint}" ]
+               then
+                       umount "${alt_mountpoint}"
+                       rmdir "${alt_mountpoint}"
+               fi
+               umount "${mountpoint}"
+       elif [ "${webfile}"  != "FETCH" ] ; then
+               NETBOOT="${webfile}"
+               export NETBOOT
        fi
 
        return ${rc}
@@ -1088,7 +904,7 @@ find_snap ()
 try_snap ()
 {
         # copy the contents of previously found snapshot to ${snap_mount}
-       # and remember the device and filename for resync on exit in live-initramfs.init
+       # and remember the device and filename for resync on exit in live-boot.init
 
        snapdata="${1}"
        snap_mount="${2}"
@@ -1739,7 +1555,7 @@ find_livefs ()
                then
                        # This is an ugly hack situation, the block device has
                        # an image directly on it.  It's hopefully
-                       # live-initramfs, so take it and run with it.
+                       # live-boot, so take it and run with it.
                        ln -s "${devname}" "${devname}.${fstype}"
                        echo "${devname}.${fstype}"
                        return 0
@@ -1907,35 +1723,12 @@ mountroot ()
                mount -n -o bind /dev "${rootmnt}/dev"
        fi
 
-       # Open up two fifo's fd's for debconf-communicate to use. Speeds up
-       # the live-initramfs process considerably.
-       log_begin_msg "Creating debconf-communicate fifo mechanism"
-       mkfifo /tmp/debconf-in.fifo
-       mkfifo /tmp/debconf-out.fifo
-
-       # Make the template database read-only, so that passthrough debconf
-       # instances can write to it directly; otherwise templates are only
-       # passed through when necessary.  Use temporary config databases as
-       # well; we'll copy their contents back at the end.
-       DEBCONF_TMPDIR="$(chroot /root mktemp -dt debconf.XXXXXX)"
-       cp -a /root/var/cache/debconf/config.dat "/root$DEBCONF_TMPDIR/"
-       cp -a /root/var/cache/debconf/passwords.dat "/root$DEBCONF_TMPDIR/"
-       sed "s,^Filename: /var/cache/debconf/\(config\|passwords\).dat$,Filename: $DEBCONF_TMPDIR/\1.dat,; /^Name: templatedb/a\
-+Readonly: true" /root/etc/debconf.conf >"/root$DEBCONF_TMPDIR/debconf.conf"
-
-       # Save the PID so it can be killed later.
-       DEBCONF_SYSTEMRC="$DEBCONF_TMPDIR/debconf.conf" chroot /root debconf-communicate -fnoninteractive live-initramfs > /tmp/debconf-out.fifo < /tmp/debconf-in.fifo &
-
-       if [ ! -p /tmp/debconf-in.fifo ] || [ ! -p /tmp/debconf-out.fifo ]
+       # Move to the new root filesystem so that programs there can get at it.
+       if [ ! -d /root/live/image ]
        then
-               log_warning_msg "failed to setup debconf-communicate channel"
+               mkdir -p /root/live/image
+               mount --move /live/image /root/live/image
        fi
-       log_end_msg
-
-       # Order matters!
-       # These file descriptors must stay open until we're finished with
-       # debconf-communicate.
-       exec 4</tmp/debconf-out.fifo 3>/tmp/debconf-in.fifo
 
        maybe_break live-bottom
        log_begin_msg "Running /scripts/live-bottom\n"
@@ -1948,26 +1741,8 @@ mountroot ()
                umount "${rootmnt}/dev"
        fi
 
-       # Close the fd's associated with debconf-communicate
-       exec 3>&- 4<&-
-       rm -f /tmp/debconf-in.fifo
-       rm -f /tmp/debconf-out.fifo
-
-       # Copy config database changes back to the master files.
-       chroot /root debconf-copydb tmpdb config \
-               --config=Name:tmpdb --config=Driver:File \
-               --config="Filename:$DEBCONF_TMPDIR/config.dat"
-       chroot /root debconf-copydb tmpdb passwords \
-               --config=Name:tmpdb --config=Driver:File \
-               --config="Filename:$DEBCONF_TMPDIR/passwords.dat"
-       rm -rf "$DEBCONF_TMPDIR"
-
        exec 1>&6 6>&-
        exec 2>&7 7>&-
        kill ${tailpid}
        [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null
-       if [ -f /etc/live.conf ]
-       then
-               cp /etc/live.conf "${rootmnt}/etc/"
-       fi
 }