diff options
author | Daniel Baumann <daniel@debian.org> | 2007-09-23 14:46:37 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2011-03-09 17:25:54 +0100 |
commit | 3d52fbcb4fe70132ade14759d76573b471294800 (patch) | |
tree | 7ee8e69a62e032cb427e6b3ae96481ae4e8c9df8 /scripts | |
parent | 9fc9e2a1a11b0edada38cb501fefe4f58aa414ac (diff) | |
download | live-boot-3d52fbcb4fe70132ade14759d76573b471294800.tar.gz live-boot-3d52fbcb4fe70132ade14759d76573b471294800.zip |
Adding live-initramfs 1.87.3-1.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/live | 203 | ||||
-rwxr-xr-x | scripts/live-bottom/01integrity_check | 2 | ||||
-rwxr-xr-x | scripts/live-bottom/02etc_live_conf | 39 | ||||
-rwxr-xr-x | scripts/live-bottom/05mountpoints | 6 | ||||
-rwxr-xr-x | scripts/live-bottom/10adduser | 60 | ||||
-rwxr-xr-x | scripts/live-bottom/13swap | 7 | ||||
-rwxr-xr-x | scripts/live-bottom/14locales | 47 | ||||
-rwxr-xr-x | scripts/live-bottom/15autologin | 5 | ||||
-rwxr-xr-x | scripts/live-bottom/18hostname | 4 | ||||
-rwxr-xr-x | scripts/live-bottom/19keyboard | 37 | ||||
-rwxr-xr-x | scripts/live-bottom/20xconfig | 35 | ||||
-rwxr-xr-x | scripts/live-bottom/21xvidemode | 41 | ||||
-rwxr-xr-x | scripts/live-bottom/23networking | 18 | ||||
-rwxr-xr-x | scripts/live-bottom/24preseed | 33 | ||||
-rwxr-xr-x | scripts/live-bottom/25configure_init | 44 | ||||
-rwxr-xr-x | scripts/live-bottom/30accessibility | 10 | ||||
-rwxr-xr-x | scripts/live-bottom/40install_driver_updates | 2 | ||||
-rw-r--r-- | scripts/live-functions | 14 | ||||
-rw-r--r-- | scripts/live-helpers | 42 |
19 files changed, 487 insertions, 162 deletions
diff --git a/scripts/live b/scripts/live index 9ab1ac5..04243d7 100755 --- a/scripts/live +++ b/scripts/live @@ -7,17 +7,22 @@ export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin echo "/root/lib" >> /etc/ld.so.conf echo "/root/usr/lib" >> /etc/ld.so.conf -mountpoint=/cdrom +mountpoint=/live_media + +root_persistence="live-rw" +home_persistence="home-rw" +root_snapshot_label="live-sn" +home_snapshot_label="home-sn" USERNAME=user -USERFULLNAME="Live session user" -HOST=live +USERFULLNAME="Live user" +HOSTNAME=host BUILD_SYSTEM=Custom mkdir -p $mountpoint [ -f /etc/live.conf ] && . /etc/live.conf -export USERNAME USERFULLNAME HOST BUILD_SYSTEM +export USERNAME USERFULLNAME HOSTNAME BUILD_SYSTEM . /scripts/live-helpers @@ -25,7 +30,103 @@ if [ ! -f /live.vars ]; then touch /live.vars fi -is_casper_path() { +parse_cmdline () +{ + PRESEEDS= + # looking for live-initramfs specifics options as kernel parameters + for x in $(cat /proc/cmdline); do + case $x in + userfullname=*) + export USERFULLNAME=${x#userfullname=} + export LIVECONF="changed" + ;; + hostname=*) + export HOSTNAME=${x#hostname=} + export LIVECONF="changed" + ;; + username=*) + export USERNAME=${x#username=} + export LIVECONF="changed" + ;; + netboot*) + export NETBOOT=${x#netboot=} ;; + access=*) + export ACCESS=${x#access=} ;; + xdebconf) + export XDEBCONF="Yes" ;; + xvideomode=*) + export XVIDEOMODE="${x#xvideomode=}" ;; + toram) + export TORAM="Yes" ;; + todisk=*) + export TODISK=${x#todisk=} ;; + swapoff) + export SWAPOFF="Yes" ;; + showmounts) + export SHOWMOUNTS="Yes" ;; + persistent) + export PERSISTENT="Yes" ;; + nopersistent) + export PERSISTENT="" ;; + ip*) + STATICIP=${x#ip=} + if [ "${STATICIP}" == "" ]; then + STATICIP="frommedia" + fi + export STATICIP ;; + live-getty) + export LIVE_GETTY=1 ;; + bootfrom=*|live-media=*) + export LIVE_MEDIA=${x#*=} ;; + live-media-encryption=*|encryption=*) + export LIVE_MEDIA_ENCRYPTION=${x#*=} ;; + live-media-timeout=*) + export LIVE_MEDIA_TIMEOUT=${x#live-media-timeout=} ;; + live-media-offset=*) + export LIVE_MEDIA_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#*=} ;; + module=*) + export MODULE=${x#module=} ;; + preseed/file=*|file=*) + export LOCATION="${x#*=}" ;; + */*=*) + question="${x%%=*}" + value="${x#*=}" + PRESEEDS="${PRESEEDS}\"${question}=${value}\" " + ;; + console=*) + export DEFCONSOLE="${x#*=}" ;; + 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 + + if [ -z "${MODULE}" ]; then + MODULE=order + fi +} + +is_live_path() { path=$1 if [ -d "$path/live" ]; then if [ "$(echo $path/live/*.squashfs)" != "$path/live/*.squashfs" ] || @@ -40,7 +141,7 @@ is_casper_path() { get_backing_device() { case "$1" in *.squashfs|*.ext2) - echo $(setup_loop "$1" "loop" "/sys/block/loop*") + echo $(setup_loop "$1" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}") ;; *.dir) echo "directory" @@ -243,7 +344,7 @@ do_snap_copy () try_snap () { # Look for $snap_label.* in block devices and copy the contents to $snap_mount - # and remember the device and filename for resync on exit in casper.init + # and remember the device and filename for resync on exit in live-initramfs.init snap_label="${1}" snap_mount="${2}" @@ -320,24 +421,40 @@ setup_unionfs() { roopt="ro" fi - mkdir -p "${croot}" - for image_type in "ext2" "squashfs" "dir" ; do - for image in "${image_directory}"/*."${image_type}"; do - imagename=$(basename "${image}") - if [ -d "${image}" ]; then - # it is a plain directory: do nothing - rofsstring="${image}=${roopt}:${rofsstring}" - rofslist="${image} ${rofslist}" - elif [ -f "${image}" ]; then - backdev=$(get_backing_device "$image") - fstype=$(get_fstype "${backdev}") - if [ "${fstype}" = "unknown" ]; then - panic "Unknown file system type on ${backdev} (${image})" - fi - mkdir -p "${croot}/${imagename}" - mount -t "${fstype}" -o ro "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}" - fi + # Read image names from ${MODULE}.lst if it exists + if [ -e "${image_directory}/${MODULE}.lst" ]; then + for image in $(cat "${image_directory}/${MODULE}.lst"); do + image_string="${image_string} ${image_directory}/${image}"; + done + else + # If ${MODULE}.lst does not exist, create a list of images + for image_type in "ext2" "squashfs" "dir"; do + for image in "${image_directory}"/*."${image_type}"; do + if [ -e "${image}" ]; then + image_string="${image_string} ${image}"; + fi + done done + # Now sort the list + image_string=$(echo ${image_string} | sed -e 's/ /\n/g' | sort ) + fi + + mkdir -p "${croot}" + for image in ${image_string}; do + imagename=$(basename "${image}") + if [ -d "${image}" ]; then + # it is a plain directory: do nothing + rofsstring="${image}=${roopt}:${rofsstring}" + rofslist="${image} ${rofslist}" + elif [ -f "${image}" ]; then + backdev=$(get_backing_device "$image") + fstype=$(get_fstype "${backdev}") + if [ "${fstype}" = "unknown" ]; then + panic "Unknown file system type on ${backdev} (${image})" + fi + mkdir -p "${croot}/${imagename}" + mount -t "${fstype}" -o ro "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}" + fi done rofsstring=${rofsstring%:} @@ -386,17 +503,11 @@ setup_unionfs() { ;; esac done - # shows cow fs on /cow for use by live-snapshot - mkdir -p "${rootmnt}/cow" - mount -o bind /cow "${rootmnt}/cow" fi - # 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 + # shows cow fs on /cow for use by live-snapshot + mkdir -p "${rootmnt}/cow" + mount -o bind /cow "${rootmnt}/cow" } check_dev () @@ -407,15 +518,15 @@ check_dev () devname=$(sys2dev "${sysdev}") fi - if [ -n "${LIVEMEDIA_OFFSET}" ]; then - loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_OFFSET}") - devname="${loopdevname}" + 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}; then mount -t ${fstype} -o ro "${devname}" $mountpoint || continue - if is_casper_path $mountpoint; then + if is_live_path $mountpoint; then echo $mountpoint return 0 else @@ -423,7 +534,7 @@ check_dev () fi fi - if [ -n "${LIVEMEDIA_OFFSET}" ]; then + if [ -n "${LIVE_MEDIA_OFFSET}" ]; then losetup -d "${loopdevname}" fi return 1 @@ -432,14 +543,14 @@ check_dev () find_livefs() { timeout="${1}" # first look at the one specified in the command line - if [ ! -z "${LIVEMEDIA}" ]; then - if check_dev "null" "${LIVEMEDIA}"; then + if [ ! -z "${LIVE_MEDIA}" ]; then + if check_dev "null" "${LIVE_MEDIA}"; then return 0 fi fi # don't start autodetection before timeout has expired - if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then - if [ "${timeout}" -lt "${LIVEMEDIA_TIMEOUT}" ]; then + if [ -n "${LIVE_MEDIA_TIMEOUT}" ]; then + if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]; then return 1 fi fi @@ -462,7 +573,7 @@ find_livefs() { "${fstype}" = "ext2" ]; then # This is an ugly hack situation, the block device has # an image directly on it. It's hopefully - # casper, so take it and run with it. + # live-initramfs, so take it and run with it. ln -s "${devname}" "${devname}.${fstype}" echo "${devname}.${fstype}" return 0 @@ -489,6 +600,8 @@ mountroot() { exec > live.log exec 2>&1 + parse_cmdline + set_usplash_timeout [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-premount" pulsate @@ -508,9 +621,9 @@ mountroot() { 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 + for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do livefs_root=$(find_livefs $i) - if [ "${livefs_root}" ]; then + if [ -n "${livefs_root}" ]; then break fi sleep 1 diff --git a/scripts/live-bottom/01integrity_check b/scripts/live-bottom/01integrity_check index d5bc5fe..46a5790 100755 --- a/scripts/live-bottom/01integrity_check +++ b/scripts/live-bottom/01integrity_check @@ -15,4 +15,4 @@ prereqs) ;; esac -grep integrity-check /proc/cmdline && live-md5check /cdrom /cdrom/md5sum.txt < /dev/tty8 +grep integrity-check /proc/cmdline && live-md5check /live_media /live_media/md5sum.txt < /dev/tty8 diff --git a/scripts/live-bottom/02etc_live_conf b/scripts/live-bottom/02etc_live_conf new file mode 100755 index 0000000..f0bbd96 --- /dev/null +++ b/scripts/live-bottom/02etc_live_conf @@ -0,0 +1,39 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Copying config on real root fs..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if [ -f /etc/live.conf ] ; then + if [ ! -z "${LIVECONF}" ]; then + # Updating live.conf + sed -i -e 's/\(USERNAME="\).*"/\1'"${USERNAME}"'"/g' \ + -e 's/\(USERFULLNAME="\).*"/\1'"${USERFULLNAME}"'"/g' \ + -e 's/\(HOSTNAME="\).*"/\1'"${HOSTNAME}"'"/g' /etc/live.conf + fi + cp -p /etc/live.conf /root/etc/live.conf + +else + cat <<EOF >/root/etc/live.conf +export USERNAME="$USERNAME" +export USERFULLNAME="$USERFULLNAME" +export HOSTNAME="$HOSTNAME" +EOF + +fi diff --git a/scripts/live-bottom/05mountpoints b/scripts/live-bottom/05mountpoints index 411660d..36c2972 100755 --- a/scripts/live-bottom/05mountpoints +++ b/scripts/live-bottom/05mountpoints @@ -21,7 +21,9 @@ esac log_begin_msg "$DESCRIPTION" # Move to the new root filesystem so that programs there can get at it. -mkdir -p /root/cdrom -mount -n -o move /cdrom /root/cdrom +if [ ! -d /root/live_media ]; then + mkdir -p /root/live_media + mount -n -o move /live_media /root/live_media +fi log_end_msg diff --git a/scripts/live-bottom/10adduser b/scripts/live-bottom/10adduser index 9179f1b..394f007 100755 --- a/scripts/live-bottom/10adduser +++ b/scripts/live-bottom/10adduser @@ -20,16 +20,28 @@ esac log_begin_msg "$DESCRIPTION" +if [ "${BUILD_SYSTEM}" == "Debian" ]; then + user_crypted="8Ab05sVQ4LLps" # as in `echo "live" | mkpasswd -s` +else + user_crypted="U6aMy0wojraho" # "ubuntu" +fi + # U6aMy0wojraho is just a blank password chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <<EOF set passwd/root-password-crypted * -set passwd/user-password-crypted U6aMy0wojraho -set passwd/user-fullname $USERFULLNAME +set passwd/user-password-crypted ${user_crypted} +set passwd/user-fullname $USERFULLNAME set passwd/username $USERNAME set passwd/user-uid 999 EOF -chroot /root /usr/lib/user-setup/user-setup-apply > /dev/null +if [ "${BUILD_SYSTEM}" == "Debian" ]; then + chroot /root /usr/bin/env -i HOME="/root" \ + TERM="${TERM}" PATH="/usr/sbin:/usr/bin:/sbin:/bin" \ + /usr/lib/user-setup/user-setup-apply > /dev/null +else + chroot /root /usr/lib/user-setup/user-setup-apply > /dev/null +fi # Clear out debconf database again to avoid confusing ubiquity later. chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <<EOF @@ -41,22 +53,42 @@ set passwd/user-uid EOF if [ -f /root/etc/sudoers ]; then - if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then + if [ "${BUILD_SYSTEM}" == "Ubuntu" ]; then grep -q '^%admin' /root/etc/sudoers && sed -i -e '/^%admin/s/ALL$/NOPASSWD: ALL/' /root/etc/sudoers || echo '%admin ALL=(ALL) NOPASSWD: ALL' >> /root/etc/sudoers + + # XXX - awful hack to stop xscreensaver locking the screen (#7150) + echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment + + for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do + if [ -f "/root/$file" ]; then + chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file") + break + fi + done elif [ "${BUILD_SYSTEM}" = "Debian" ]; then - echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers - fi -fi + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers + + chroot /root sudo -u "${USERNAME}" sh -c "echo 'SU_TO_ROOT_SU=sudo' >> /home/${USERNAME}/.su-to-rootrc" + + chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/sudo-mode true + chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gksu/display-no-pass-info false -# XXX - awful hack to stop xscreensaver locking the screen (#7150) -echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment +chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/config && cat > /home/${USERNAME}/.kde/share/config/kdesurc" << EOF +[super-user-command] +super-user-command=sudo +EOF + + if [ -f /root/usr/share/apps/konsole/sumc.desktop ] + then + chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/apps/konsole && sed -e's/Exec=su.*$/Exec=sudo mc -c/' /usr/share/apps/konsole/sumc.desktop > /home/${USERNAME}/.kde/share/apps/konsole/sumc.desktop" + fi -for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do - if [ -f "/root/$file" ]; then - chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file") - break + if [ -f /root/usr/share/apps/konsole/su.desktop ] + then + chroot /root sudo -u "${USERNAME}" sh -c "umask 0077 && mkdir -p /home/${USERNAME}/.kde/share/apps/konsole && sed -e's/Exec=su.*$/Exec=sudo -i/' /usr/share/apps/konsole/su.desktop > /home/${USERNAME}/.kde/share/apps/konsole/su.desktop" + fi fi -done +fi if [ -L /root/home/$USERNAME/Examples ]; then chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/ diff --git a/scripts/live-bottom/13swap b/scripts/live-bottom/13swap index fcef76c..9d762f4 100755 --- a/scripts/live-bottom/13swap +++ b/scripts/live-bottom/13swap @@ -21,6 +21,11 @@ esac log_begin_msg "$DESCRIPTION" +if [ -n "${SWAPOFF}" ] +then + exit 0 +fi + devices="" for device in /dev/[hs]d[a-z][0-9]*; do if ! [ -b "$device" ]; then @@ -28,7 +33,7 @@ for device in /dev/[hs]d[a-z][0-9]*; do fi magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue - + if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then # log "Found $device" devices="$devices $device" diff --git a/scripts/live-bottom/14locales b/scripts/live-bottom/14locales index a03e0d1..2102569 100755 --- a/scripts/live-bottom/14locales +++ b/scripts/live-bottom/14locales @@ -33,19 +33,10 @@ else grep_file=/root/etc/default/locale fi -# commandline -for x in $(cat /proc/cmdline); do - case $x in - debian-installer/locale=*) - locale=${x#debian-installer/locale=} - set_locale="true" - ;; - locale=*) - locale=${x#locale=} - set_locale="true" - ;; - esac -done +if [ -n "${LOCALE}" ]; then + locale="${LOCALE}" + set_locale="true" +fi if [ -z "${locale}" ]; then # Set a default one @@ -54,10 +45,34 @@ if [ -z "${locale}" ]; then fi if [ "${set_locale}" ]; then + if echo "${locale}" | grep -sqE '^[[:lower:]]{2}$' ; then + # input is like "locale=it", so we will convert and setup also the keyboard if not already set + if [ -z "${KBD}" ]; then + # FIXME: look if this keyb is supported + KBD="${locale}" + really_export KBD + fi + uploc=$(echo "${locale}" | tr '[a-z]' '[A-Z]') + locale="${locale}_${uploc}.UTF-8" + fi LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 |sed -e 's, .*,,' -e q) - printf 'LANG="%s"\n' "${LANG}" >> "${grep_file}" - printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen - chroot /root /usr/sbin/locale-gen "${LANG}" + if [ -z "${LANG}" ]; then + log_warning_message "Locale ${locale} is unsupported." + locale="en_US.UTF-8" + LANG="${locale}" + fi + + really_export LANG + + if [ "${BUILD_SYSTEM}" == "Ubuntu" ]; then + printf 'LANG="%s"\n' "${LANG}" > "${grep_file}" + chroot /root /usr/sbin/locale-gen "${LANG}" + live-preseed /root debian-installer/locale "${locale}" + else + printf 'LANG=%s\n' "${LANG}" > "${grep_file}" + printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen + chroot /root /usr/sbin/locale-gen + fi fi log_end_msg diff --git a/scripts/live-bottom/15autologin b/scripts/live-bottom/15autologin index 4b64dc7..6032437 100755 --- a/scripts/live-bottom/15autologin +++ b/scripts/live-bottom/15autologin @@ -27,6 +27,11 @@ else fi if chroot /root [ -f ${GDMCONF} ]; then + if [ "${BUILD_SYSTEM}" == "Debian" ]; then + # true hack ! -- nohar + chroot /root cp /usr/share/gdm/defaults.conf /etc/gdm/gdm.conf + fi + # Configure GDM autologin chroot /root sed -i \ -e "s/^AutomaticLoginEnable=.*\$/AutomaticLoginEnable=true/" \ diff --git a/scripts/live-bottom/18hostname b/scripts/live-bottom/18hostname index 591e4ec..3a54e87 100755 --- a/scripts/live-bottom/18hostname +++ b/scripts/live-bottom/18hostname @@ -20,10 +20,10 @@ esac log_begin_msg "$DESCRIPTION" -echo "$HOST" > /root/etc/hostname +echo "$HOSTNAME" > /root/etc/hostname cat > /root/etc/hosts <<EOF 127.0.0.1 localhost -127.0.1.1 $HOST +127.0.1.1 $HOSTNAME # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback diff --git a/scripts/live-bottom/19keyboard b/scripts/live-bottom/19keyboard index d43e329..31cdfaa 100755 --- a/scripts/live-bottom/19keyboard +++ b/scripts/live-bottom/19keyboard @@ -20,27 +20,29 @@ esac log_begin_msg "$DESCRIPTION" -kbd=us +kbd= cslayout= csvariant= csmodel= -for x in $(cat /proc/cmdline); do - case $x in - kbd-chooser/method=*) - kbd=${x#kbd-chooser/method=} - ;; - console-setup/layoutcode=*) - cslayout=${x#console-setup/layoutcode=} - ;; - console-setup/variantcode=*) - csvariant=${x#console-setup/variantcode=} - ;; - console-setup/modelcode=*) - csmodel=${x#console-setup/modelcode=} - ;; - esac -done +# commandline +if [ -n "${KBD}" ]; then + kbd="${KBD}" +else + kbd=us +fi + +really_export kbd + +if [ -n "${KLAYOUT}" ]; then + cslayout="${KLAYOUT}" +fi +if [ -n "${KVARIANT}" ]; then + csvariant="${KVARIANT}" +fi +if [ -n "${KMODEL}" ]; then + csmodel="${KMODEL}" +fi if [ -x /root/bin/setupcon ] && [ -f /root/etc/default/console-setup ]; then if [ "$cslayout" ]; then @@ -66,5 +68,6 @@ if [ -x /root/bin/setupcon ] && [ -f /root/etc/default/console-setup ]; then else chroot /root /usr/sbin/install-keymap $kbd live-preseed /root debian-installer/keymap "$kbd" + live-preseed /root kbd-chooser/method "$kbd" fi log_end_msg diff --git a/scripts/live-bottom/20xconfig b/scripts/live-bottom/20xconfig index 93c8722..a662333 100755 --- a/scripts/live-bottom/20xconfig +++ b/scripts/live-bottom/20xconfig @@ -28,17 +28,6 @@ fi locale=en_US.UTF-8 -for x in $(cat /proc/cmdline); do - case $x in - debian-installer/locale=*) - locale=${x#debian-installer/locale=} - ;; - locale=*) - locale=${x#locale=} - ;; - esac -done - mount -n -o bind /sys /root/sys mount -n -o bind /proc /root/proc mount -n -o bind /dev /root/dev @@ -48,12 +37,32 @@ if [ -n "${XDEBCONF}" -a -x /root/usr/sbin/xdebconfigurator ]; then chroot /root /usr/sbin/xdebconfigurator fi -chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <<EOF +if [ "${BUILD_SYSTEM}" == "Ubuntu" ]; then + chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <<EOF set xserver-xorg/autodetect_keyboard true fset xserver-xorg/autodetect_keyboard seen true EOF +else + # d-i code not present, so: + if [ -n "${KOPTIONS}" ]; then + setoptions="set xserver-xorg/config/inputdevice/keyboard/options ${KOPTIONS}" + fi + if [ -n "${KVARIANT}" ]; then + setvariant="set xserver-xorg/config/inputdevice/keyboard/variant ${KVARIANT}" + fi + if [ -n "${KMODEL}" ]; then + setmodel="set xserver-xorg/config/inputdevice/keyboard/model ${KMODEL}" + fi + + chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <<EOF +set xserver-xorg/config/inputdevice/keyboard/layout ${kbd} +${setvariant} +${setmodel} +${setoptions} +EOF +fi -DEBUG_XORG_PACKAGE=1 DEBUG_XORG_DEBCONF=1 LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 | sed -e 's, .*,,' -e q) live-reconfigure /root xserver-xorg +DEBUG_XORG_PACKAGE=1 DEBUG_XORG_DEBCONF=1 live-reconfigure /root xserver-xorg umount /root/sys umount /root/proc umount /root/dev diff --git a/scripts/live-bottom/21xvidemode b/scripts/live-bottom/21xvidemode new file mode 100755 index 0000000..27d943e --- /dev/null +++ b/scripts/live-bottom/21xvidemode @@ -0,0 +1,41 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring X kludges..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if [ -n "$XVIDEOMODE" ] +then + mount -n -o bind /sys /root/sys + mount -n -o bind /proc /root/proc + mount -n -o bind /dev /root/dev + +chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF +set xserver-xorg/config/monitor/mode-list ${XVIDEOMODE} +set xserver-xorg/config/display/modes ${XVIDEOMODE} +EOF + + chroot /root dexconf + + umount /root/sys + umount /root/proc + umount /root/dev +fi + +log_end_msg diff --git a/scripts/live-bottom/23networking b/scripts/live-bottom/23networking index 988206e..ad7ac95 100755 --- a/scripts/live-bottom/23networking +++ b/scripts/live-bottom/23networking @@ -85,7 +85,7 @@ EOF fi cat > /root/etc/resolv.conf <<EOF # /etc/resolv.conf -# Autogenerated by casper +# Autogenerated by live-initramfs search ${rc_search} domain ${rc_search} ${rc_server0} @@ -95,13 +95,13 @@ EOF fi fi -for i in eth0 eth1 eth2 ath0 wlan0; do - grep -q "iface $i" $IFFILE && continue - cat >> "$IFFILE" <<EOF -auto $i -iface $i inet dhcp - -EOF -done +#for i in eth0 eth1 eth2 ath0 wlan0; do +# grep -q "iface $i" $IFFILE && continue +# cat >> "$IFFILE" <<EOF +#auto $i +#iface $i inet dhcp +# +#EOF +#done log_end_msg diff --git a/scripts/live-bottom/24preseed b/scripts/live-bottom/24preseed index cd530ea..d71b441 100755 --- a/scripts/live-bottom/24preseed +++ b/scripts/live-bottom/24preseed @@ -20,29 +20,16 @@ esac log_begin_msg "$DESCRIPTION" -location= -for x in $(cat /proc/cmdline); do - case $x in - preseed/file=*) - location="${x#preseed/file=}" - ;; - file=*) - location="${x#file=}" - ;; - */*=*) - question="${x%%=*}" - value="${x#*=}" - live-preseed /root "$question" "$value" - ;; - locale=*) - value="${x#*=}" - live-preseed /root debian-installer/locale "$value" - ;; - esac -done - -if [ "$location" ]; then - chroot /root debconf-set-selections < "/root$location" +if [ -f "/root/${LOCATION}" ]; then + chroot /root debconf-set-selections < "/root/${LOCATION}" +fi + +if [ -n "${PRESEEDS}" ]; then + for preseed in ${PRESEEDS}; do + question="${preseed%%=*}" + value="${preseed#*=}" + live-preseed /root "${question}" "${value}" + done fi log_end_msg diff --git a/scripts/live-bottom/25configure_init b/scripts/live-bottom/25configure_init index 1274990..b3f6ebf 100755 --- a/scripts/live-bottom/25configure_init +++ b/scripts/live-bottom/25configure_init @@ -23,14 +23,42 @@ log_begin_msg "$DESCRIPTION" # Arrange for shells on virtual consoles, rather than login prompts if [ -n "$USERNAME" ]; then - if [ -f /root/etc/inittab ]; then - sed -i -e "s|^\([^:]*:[^:]*:[^:]*\):.*getty.*\<\(tty[0-9]*\).*$|\1:/bin/login -f $USERNAME </dev/\2 >/dev/\2 2>\&1|" /root/etc/inittab - fi - if [ "/root/etc/event.d/tty*" != "$(echo /root/etc/event.d/tty*)" ]; then - for f in /root/etc/event.d/tty*; do - sed -i -e "s|^exec.*|exec /bin/login -f $USERNAME </dev/$(basename $f) > /dev/$(basename $f) 2>\&1|" $f - done - fi + if [ ! -z "${LIVE_GETTY}" ]; then + if echo "${DEFCONSOLE}" | grep -qs ttyS; then + # AUTOMATIC SERIAL CONSOLE # + PORT=$(echo "${DEFCONSOLE}" | \ + sed -e 's%,.*%%') + SPEED=$(echo "${DEFCONSOLE}" | \ + sed -e 's%ttyS[0-9]\+,%%' \ + -e's%\([0-9]\+\).*%\1%') + if ! ( sed -n -e'/^[^#]/p' /root/etc/inittab | grep -qs ":respawn:/sbin/getty.*${PORT}" ) ; then + IDs="A B C D E F G H I J K L M N O P Q R S T Q U V V X Y Z 0 1 2 3 4 5 6 7 8 9" + for ID1 in $IDs; do + for ID2 in $IDs; do + ID="${ID1}${ID2}" + if ! grep "^${ID}:" /etc/inittab ; then + #make sure it is not already in use + break 2 + fi + done + done + echo "${ID}:2345:respawn:/sbin/live-getty -L ${PORT} ${SPEED} vt100" \ + >>/root/etc/inittab + fi + fi + if [ -f /root/etc/inittab ]; then + sed -i -e'/^[^#]/s%respawn:/sbin/getty%respawn:/sbin/live-getty%' /root/etc/inittab + fi + else + if [ -f /root/etc/inittab ]; then + sed -i -e "s|^\([^:]*:[^:]*:[^:]*\):.*getty.*\<\(tty[0-9]*\).*$|\1:/bin/login -f $USERNAME </dev/\2 >/dev/\2 2>\&1|" /root/etc/inittab + fi + if [ "/root/etc/event.d/tty*" != "$(echo /root/etc/event.d/tty*)" ]; then + for f in /root/etc/event.d/tty*; do + sed -i -e "s|^respawn.*|respawn /bin/login -f $USERNAME </dev/$(basename $f) > /dev/$(basename $f) 2>\&1|" $f + done + fi + fi fi # This has the nice side effect of the cron.{daily,weekly,monthly} jobs in diff --git a/scripts/live-bottom/30accessibility b/scripts/live-bottom/30accessibility index 127c48f..d8286e6 100755 --- a/scripts/live-bottom/30accessibility +++ b/scripts/live-bottom/30accessibility @@ -34,8 +34,7 @@ kderc_addtoprefixes() { fi } -for x in $(cat /proc/cmdline); do - case $x in +case ${ACCESS} in # Lesser Visual Impairment access=v1) gct -s -t string /desktop/gnome/interface/gtk_theme HighContrastLargePrint @@ -85,7 +84,7 @@ for x in $(cat /proc/cmdline); do kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/ if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then sed -i 's/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml - fi + fi ;; # Motor Difficulties - pointing devices access=m2) @@ -99,8 +98,7 @@ for x in $(cat /proc/cmdline); do kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/minor-motor-difficulties/,/usr/share/kubuntu-default-settings/kde-profile/motor-difficulties-pointing-devices/ if [ -e /root/etc/xdg/xfce4/mcs_settings/keyboard.xml ]; then sed -i '/Sticky/ s/0/1/' /root/etc/xdg/xfce4/mcs_settings/keyboard.xml - fi + fi ;; - esac -done +esac log_end_msg diff --git a/scripts/live-bottom/40install_driver_updates b/scripts/live-bottom/40install_driver_updates index 5822f8f..698ed02 100755 --- a/scripts/live-bottom/40install_driver_updates +++ b/scripts/live-bottom/40install_driver_updates @@ -30,7 +30,7 @@ mkdir "/root$install_dir" cp -a /tmp/driver-updates/*.deb "/root$install_dir/" # We cannot leave packages in a bad state. So if the install fails, remove -# it. This will get caught in casper.log. +# it. This will get caught in live.log. for deb in "/root$install_dir"/*; do if ! chroot /root dpkg -i "$install_dir/$deb"; then chroot /root dpkg -P "${deb%%_*}" diff --git a/scripts/live-functions b/scripts/live-functions index 60721b4..7100603 100644 --- a/scripts/live-functions +++ b/scripts/live-functions @@ -1,5 +1,6 @@ . /scripts/functions +. /live.vars # Override this so we don't call PROGRESS log_end_msg() @@ -19,3 +20,16 @@ log_wait_msg() fi _log_msg "Waiting: $@ ..." } + +really_export () +{ + STRING="${1}" + VALUE="$(eval echo -n \${$STRING})" + + if [ -f /live.vars ] && cat /live.vars | grep -sq "export ${STRING}" ; then + sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars + else + echo "export ${STRING}=\"${VALUE}\"" >> /live.vars + fi + eval export "${STRING}"="${VALUE}" +} diff --git a/scripts/live-helpers b/scripts/live-helpers index 8402d93..eac2175 100644 --- a/scripts/live-helpers +++ b/scripts/live-helpers @@ -1,4 +1,4 @@ -## Casper helper functions, used by casper on boot and by casper-snapshot +## live-initramfs helper functions, used by live-initramfs on boot and by live-snapshot if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then MP_QUIET="-Q" @@ -108,11 +108,20 @@ fs_size () echo "${size}" } +load_keymap() +{ + # Load custom keymap + if [ -x /bin/loadkeys -a -r /etc/boottime.kmap.gz ]; then + loadkeys /etc/boottime.kmap.gz + fi +} + setup_loop() { local fspath=$1 local module=$2 local pattern=$3 local offset=$4 + local encryption=$5 modprobe ${MP_QUIET} -b "$module" udevsettle @@ -120,10 +129,35 @@ setup_loop() { for loopdev in $pattern; do if [ "$(cat $loopdev/size)" -eq 0 ]; then dev=$(sys2dev "${loopdev}") - if [ -n "$offset" ]; then - losetup -o "$offset" "$dev" "$fspath" + options='' + if [ 0 -lt "${offset}" ]; then + options="${options} -o ${offset}" + fi + if [ -z "${encryption}" ]; then + losetup ${options} "${dev}" "${fspath}" else - losetup "$dev" "$fspath" + # Loop AES encryption + while true; do + load_keymap + echo -n "Enter passphrase for ${fspath}: " >&6 + read -s passphrase + echo "${passphrase}" > /tmp/passphrase + exec 9</tmp/passphrase + /sbin/losetup ${options} -e "${encryption}" -p 9 "${dev}" "${fspath}" + error=$? + exec 9<&- + rm -f /tmp/passphrase + if [ 0 -eq ${error} ]; then + unset error + break + fi + echo -n "Something went wrong... Retry? [YES/no] " >&6 + read answer + if [ 'no' = "${answer}" ]; then + unset answer + break + fi + done fi echo "$dev" return 0 |