From 9fc9e2a1a11b0edada38cb501fefe4f58aa414ac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 23 Sep 2007 14:46:36 +0200 Subject: Adding live-initramfs 1.87.2-1. --- scripts/casper | 549 ------------------------ scripts/casper-bottom/01integrity_check | 18 - scripts/casper-bottom/02_timezone | 21 - scripts/casper-bottom/05mountpoints | 27 -- scripts/casper-bottom/10adduser | 66 --- scripts/casper-bottom/12fstab | 31 -- scripts/casper-bottom/13swap | 44 -- scripts/casper-bottom/14locales | 63 --- scripts/casper-bottom/15autologin | 62 --- scripts/casper-bottom/18hostname | 38 -- scripts/casper-bottom/19keyboard | 70 --- scripts/casper-bottom/20xconfig | 61 --- scripts/casper-bottom/22gnome_panel_data | 34 -- scripts/casper-bottom/22screensaver | 30 -- scripts/casper-bottom/23etc_modules | 30 -- scripts/casper-bottom/23networking | 107 ----- scripts/casper-bottom/24preseed | 50 --- scripts/casper-bottom/25configure_init | 58 --- scripts/casper-bottom/30accessibility | 106 ----- scripts/casper-bottom/31disable_update_notifier | 34 -- scripts/casper-bottom/32disable_hibernation | 36 -- scripts/casper-bottom/33enable_apport_crashes | 28 -- scripts/casper-bottom/34disable_kwallet | 25 -- scripts/casper-bottom/35fix_language_selector | 32 -- scripts/casper-bottom/40install_driver_updates | 40 -- scripts/casper-bottom/41apt_cdrom | 24 -- scripts/casper-functions | 21 - scripts/casper-helpers | 197 --------- scripts/casper-premount/10driver_updates | 163 ------- scripts/live | 549 ++++++++++++++++++++++++ scripts/live-bottom/01integrity_check | 18 + scripts/live-bottom/02_timezone | 21 + scripts/live-bottom/05mountpoints | 27 ++ scripts/live-bottom/10adduser | 66 +++ scripts/live-bottom/12fstab | 31 ++ scripts/live-bottom/13swap | 44 ++ scripts/live-bottom/14locales | 63 +++ scripts/live-bottom/15autologin | 62 +++ scripts/live-bottom/18hostname | 38 ++ scripts/live-bottom/19keyboard | 70 +++ scripts/live-bottom/20xconfig | 61 +++ scripts/live-bottom/22gnome_panel_data | 34 ++ scripts/live-bottom/22screensaver | 30 ++ scripts/live-bottom/23etc_modules | 30 ++ scripts/live-bottom/23networking | 107 +++++ scripts/live-bottom/24preseed | 50 +++ scripts/live-bottom/25configure_init | 58 +++ scripts/live-bottom/30accessibility | 106 +++++ scripts/live-bottom/31disable_update_notifier | 34 ++ scripts/live-bottom/32disable_hibernation | 36 ++ scripts/live-bottom/33enable_apport_crashes | 28 ++ scripts/live-bottom/34disable_kwallet | 25 ++ scripts/live-bottom/35fix_language_selector | 32 ++ scripts/live-bottom/40install_driver_updates | 40 ++ scripts/live-bottom/41apt_cdrom | 24 ++ scripts/live-functions | 21 + scripts/live-helpers | 197 +++++++++ scripts/live-premount/10driver_updates | 163 +++++++ 58 files changed, 2065 insertions(+), 2065 deletions(-) delete mode 100755 scripts/casper delete mode 100755 scripts/casper-bottom/01integrity_check delete mode 100755 scripts/casper-bottom/02_timezone delete mode 100755 scripts/casper-bottom/05mountpoints delete mode 100755 scripts/casper-bottom/10adduser delete mode 100755 scripts/casper-bottom/12fstab delete mode 100755 scripts/casper-bottom/13swap delete mode 100755 scripts/casper-bottom/14locales delete mode 100755 scripts/casper-bottom/15autologin delete mode 100755 scripts/casper-bottom/18hostname delete mode 100755 scripts/casper-bottom/19keyboard delete mode 100755 scripts/casper-bottom/20xconfig delete mode 100755 scripts/casper-bottom/22gnome_panel_data delete mode 100755 scripts/casper-bottom/22screensaver delete mode 100755 scripts/casper-bottom/23etc_modules delete mode 100755 scripts/casper-bottom/23networking delete mode 100755 scripts/casper-bottom/24preseed delete mode 100755 scripts/casper-bottom/25configure_init delete mode 100755 scripts/casper-bottom/30accessibility delete mode 100755 scripts/casper-bottom/31disable_update_notifier delete mode 100755 scripts/casper-bottom/32disable_hibernation delete mode 100755 scripts/casper-bottom/33enable_apport_crashes delete mode 100755 scripts/casper-bottom/34disable_kwallet delete mode 100755 scripts/casper-bottom/35fix_language_selector delete mode 100755 scripts/casper-bottom/40install_driver_updates delete mode 100755 scripts/casper-bottom/41apt_cdrom delete mode 100644 scripts/casper-functions delete mode 100644 scripts/casper-helpers delete mode 100755 scripts/casper-premount/10driver_updates create mode 100755 scripts/live create mode 100755 scripts/live-bottom/01integrity_check create mode 100755 scripts/live-bottom/02_timezone create mode 100755 scripts/live-bottom/05mountpoints create mode 100755 scripts/live-bottom/10adduser create mode 100755 scripts/live-bottom/12fstab create mode 100755 scripts/live-bottom/13swap create mode 100755 scripts/live-bottom/14locales create mode 100755 scripts/live-bottom/15autologin create mode 100755 scripts/live-bottom/18hostname create mode 100755 scripts/live-bottom/19keyboard create mode 100755 scripts/live-bottom/20xconfig create mode 100755 scripts/live-bottom/22gnome_panel_data create mode 100755 scripts/live-bottom/22screensaver create mode 100755 scripts/live-bottom/23etc_modules create mode 100755 scripts/live-bottom/23networking create mode 100755 scripts/live-bottom/24preseed create mode 100755 scripts/live-bottom/25configure_init create mode 100755 scripts/live-bottom/30accessibility create mode 100755 scripts/live-bottom/31disable_update_notifier create mode 100755 scripts/live-bottom/32disable_hibernation create mode 100755 scripts/live-bottom/33enable_apport_crashes create mode 100755 scripts/live-bottom/34disable_kwallet create mode 100755 scripts/live-bottom/35fix_language_selector create mode 100755 scripts/live-bottom/40install_driver_updates create mode 100755 scripts/live-bottom/41apt_cdrom create mode 100644 scripts/live-functions create mode 100644 scripts/live-helpers create mode 100755 scripts/live-premount/10driver_updates (limited to 'scripts') diff --git a/scripts/casper b/scripts/casper deleted file mode 100755 index a4c78b3..0000000 --- a/scripts/casper +++ /dev/null @@ -1,549 +0,0 @@ -#!/bin/sh - -# set -e - -export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin - -echo "/root/lib" >> /etc/ld.so.conf -echo "/root/usr/lib" >> /etc/ld.so.conf - -mountpoint=/cdrom - -USERNAME=casper -USERFULLNAME="Live session user" -HOST=live -BUILD_SYSTEM=Custom - -mkdir -p $mountpoint - -[ -f /etc/casper.conf ] && . /etc/casper.conf -export USERNAME USERFULLNAME HOST BUILD_SYSTEM - -. /scripts/casper-helpers - -if [ ! -f /casper.vars ]; then - touch /casper.vars -fi - -is_casper_path() { - path=$1 - if [ -d "$path/casper" ]; then - if [ "$(echo $path/casper/*.squashfs)" != "$path/casper/*.squashfs" ] || - [ "$(echo $path/casper/*.ext2)" != "$path/casper/*.ext2" ] || - [ "$(echo $path/casper/*.dir)" != "$path/casper/*.dir" ]; then - return 0 - fi - fi - return 1 -} - -get_backing_device() { - case "$1" in - *.squashfs|*.ext2) - echo $(setup_loop "$1" "loop" "/sys/block/loop*") - ;; - *.dir) - echo "directory" - ;; - *) - panic "Unrecognized casper filesystem: $1" - ;; - esac -} - -match_files_in_dir() { - # Does any files match pattern $1 ? - - local pattern="$1" - if [ "$(echo $pattern)" != "$pattern" ]; then - return 0 - fi - return 1 -} - -mount_images_in_directory() { - directory="$1" - rootmnt="$2" - if match_files_in_dir "$directory/casper/*.squashfs" || - match_files_in_dir "$directory/casper/*.ext2" || - match_files_in_dir "$directory/casper/*.dir"; then - setup_unionfs "$directory/casper" "$rootmnt" - else - : - fi -} - -is_nice_device() { - sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then - return 0 - fi - return 1 -} - -is_supported_fs () { - # FIXME: do something better like the scan of supported filesystems - fstype="${1}" - case ${fstype} in - vfat|iso9660|udf|ext2|ext3|ntfs) - return 0 - ;; - esac - return 1 -} - -copy_live_to() { - copyfrom="${1}" - copytodev="${2}" - copyto="${copyfrom}_swap" - - size=$(fs_size "" ${copyfrom} "used") - - if [ "${copytodev}" = "ram" ]; then - # copying to ram: - freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) ) - mount_options="-o size=${size}k" - free_string="memory" - fstype="tmpfs" - dev="/dev/shm" - else - # it should be a writable block device - if [ -b "${copytodev}" ]; then - dev="${copytodev}" - free_string="space" - fstype=$(get_fstype "${dev}") - freespace=$(fs_size "${dev}") - else - [ "$quiet" != "y" ] && log_warning_msg "${copytodev} is not a block device." - return 1 - fi - fi - if [ "${freespace}" -lt "${size}" ] ; then - [ "$quiet" != "y" ] && log_warning_msg "Not enough free ${free_string} (${freespace}k > ${size}k) to copy live media in ${copytodev}." - return 1 - fi - - # begin copying.. - mkdir "${copyto}" - echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}" - mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}" - cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files - umount ${copyfrom} - mount -r -o move ${copyto} ${copyfrom} - rmdir ${copyto} - return 0 -} - -do_netmount() { - rc=1 - - modprobe "${MP_QUIET}" af_packet # For DHCP - - udevtrigger - udevsettle - - ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config - - if [ "${NFSROOT}" = "auto" ]; then - NFSROOT=${ROOTSERVER}:${ROOTPATH} - fi - - [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}" - - if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then - rc=0 - elif do_nfsmount ; then - NETBOOT="nfs" - export NETBOOT - rc=0 - fi - - [ "$quiet" != "y" ] && log_end_msg - return ${rc} -} - -do_nfsmount() { - rc=1 - modprobe "${MP_QUIET}" nfs - if [ -z "${NFSOPTS}" ]; then - NFSOPTS="" - fi - - [ "$quiet" != "y" ] && log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}" - # FIXME: This for loop is an ugly HACK round an nfs bug - for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do - nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break - sleep 1 - done - return ${rc} -} - -do_cifsmount() { - rc=1 - if [ -x "/sbin/mount.cifs" ]; then - if [ -z "${NFSOPTS}" ]; then - CIFSOPTS="-ouser=root,password=" - else - CIFSOPTS="${NFSOPTS}" - fi - - [ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}" - modprobe "${MP_QUIET}" cifs - - if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then - rc=0 - fi - fi - return ${rc} -} - -do_snap_copy () -{ - fromdev="${1}" - todir="${2}" - snap_type="${3}" - - size=$(fs_size "${fromdev}" "" "used") - - if [ -b "${fromdev}" ]; then - # look for free mem - if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]; then - todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' ) - freespace=$(df -k | grep -s ${todev} | awk '{print $4}') - else - freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - )) - fi - - tomount="/mnt/tmpsnap" - if [ ! -d "${tomount}" ] ; then - mkdir -p "${tomount}" - fi - - fstype=$(get_fstype "${fromdev}") - if [ -n "${fstype}" ]; then - # Copying stuff... - mount -t "${fstype}" -o ro "${fromdev}" "${tomount}" - cp -a "${tomount}"/* ${todir} - umount "${tomount}" - else - log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}" - fi - - rmdir "${tomount}" - if echo ${fromdev} | grep -qs loop; then - losetup -d "${fromdev}" - fi - return 0 - else - return 1 - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the snapshot ${snap_type} medium" - fi -} - -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 - - snap_label="${1}" - snap_mount="${2}" - snap_type="${3}" - - snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2") - if [ ! -z "${snapdata}" ]; then - snapdev="$(echo ${snapdata} | cut -f1 -d ' ')" - snapback="$(echo ${snapdata} | cut -f2 -d ' ')" - snapfile="$(echo ${snapdata} | cut -f3 -d ' ')" - if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\)'; then - # squashfs or ext2 snapshot - dev=$(get_backing_device "${snapback}/${snapfile}") - if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"; then - log_warning_msg "Impossible to include the ${snapfile} Snapshot" - return 1 - fi - else - # cpio.gz snapshot - if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i -u -d 2>/dev/null) ; then - log_warning_msg "Impossible to include the ${snapfile} Snapshot" - return 1 - fi - fi - umount "${snapback}" - else - dev=$(find_cow_device "${snap_label}") - if [ -b ${dev} ]; then - if echo "${dev}" | grep -qs loop; then - # strange things happens, user confused? - snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' ) - snapfile=$(basename ${snaploop}) - snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ') - else - snapdev="${dev}" - fi - if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" ; then - log_warning_msg "Impossible to include the ${snap_label} Snapshot" - return 1 - else - if [ -n "${snapfile}" ]; then - # it was a loop device, user confused - umount ${snapdev} - fi - fi - else - log_warning_msg "Impossible to include the ${snap_label} Snapshot" - return 1 - fi - fi - echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/casper.conf # for resync on reboot/halt - return 0 -} - -setup_unionfs() { - image_directory="$1" - rootmnt="$2" - - modprobe "${MP_QUIET}" -b unionfs - - # run-init can't deal with images in a subdir, but we're going to - # move all of these away before it runs anyway. No, we're not, - # put them in / since move-mounting them into / breaks mono and - # some other apps. - - croot="/" - - # Let's just mount the read-only file systems first - rofsstring="" - rofslist="" - if [ "${NETBOOT}" = "nfs" ] ; then - roopt="nfsro" # go aroung a bug in nfs-unionfs locking - else - 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 - done - done - rofsstring=${rofsstring%:} - - mkdir -p /cow - cowdevice="tmpfs" - cow_fstype="tmpfs" - - # Looking for "${root_persistence}" device or file - if [ -n "${PERSISTENT}" ]; then - cowprobe=$(find_cow_device "${root_persistence}") - if [ -b "${cowprobe}" ]; then - cowdevice=${cowprobe} - cow_fstype=$(get_fstype "${cowprobe}") - else - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium" - fi - fi - - mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow" - - mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs mount failed" - - # Adding other custom mounts - if [ -n "${PERSISTENT}" ]; then - # directly mount /home - # FIXME: add a custom mounts configurable system - homecow=$(find_cow_device "${home_persistence}" ) - if [ -b "${homecow}" ]; then - mount -t $(get_fstype "${homecow}") -o rw "${homecow}" "${rootmnt}/home" - export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy() - else - [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium" - fi - # Look for other snapshots to copy in - try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT" - try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME" - fi - - if [ -n "${SHOWMOUNTS}" ]; then - for d in ${rofslist}; do - mkdir -p "${rootmnt}/casper/${d##*/}" - case d in - *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/casper/${d##*/}" - ;; - *) mount -o move "${d}" "${rootmnt}/casper/${d##*/}" - ;; - esac - done - # shows cow fs on /cow for use by casper-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 -} - -check_dev () -{ - sysdev="${1}" - devname="${2}" - if [ -z "${devname}" ]; then - devname=$(sys2dev "${sysdev}") - fi - - if [ -n "${LIVEMEDIA_OFFSET}" ]; then - loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_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 - echo $mountpoint - return 0 - else - umount $mountpoint - fi - fi - - if [ -n "${LIVEMEDIA_OFFSET}" ]; then - losetup -d "${loopdevname}" - fi - return 1 -} - -find_livefs() { - timeout="${1}" - # first look at the one specified in the command line - if [ ! -z "${LIVEMEDIA}" ]; then - if check_dev "null" "${LIVEMEDIA}"; then - return 0 - fi - fi - # don't start autodetection before timeout has expired - if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then - if [ "${timeout}" -lt "${LIVEMEDIA_TIMEOUT}" ]; then - return 1 - fi - fi - # or do the scan of block devices - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do - devname=$(sys2dev "${sysblock}") - fstype=$(get_fstype "${devname}") - if /lib/udev/cdrom_id ${devname} > /dev/null; then - if check_dev "null" "${devname}" ; then - return 0 - fi - elif is_nice_device "${sysblock}" ; then - for dev in $(subdevices "${sysblock}"); do - if check_dev "${dev}" ; then - return 0 - fi - done - elif [ "${fstype}" = "squashfs" -o \ - "${fstype}" = "ext3" -o \ - "${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. - ln -s "${devname}" "${devname}.${fstype}" - echo "${devname}.${fstype}" - return 0 - fi - done - return 1 -} - -pulsate() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "PULSATE" - fi -} - -set_usplash_timeout() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "TIMEOUT 120" - fi -} - -mountroot() { - exec 6>&1 - exec 7>&2 - exec > casper.log - exec 2>&1 - - set_usplash_timeout - [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount" - pulsate - run_scripts /scripts/casper-premount - [ "$quiet" != "y" ] && log_end_msg - - # Needed here too because some things (*cough* udev *cough*) - # changes the timeout - - set_usplash_timeout - - if [ ! -z "${NETBOOT}" ]; then - if do_netmount ; then - livefs_root="${mountpoint}" - else - 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 [ "${livefs_root}" ]; then - break - fi - sleep 1 - done - fi - - if [ -z "${livefs_root}" ]; then - panic "Unable to find a medium containing a live file system" - fi - - if [ "${TORAM}" ]; then - live_dest="ram" - elif [ "${TODISK}" ]; then - live_dest="${TODISK}" - fi - if [ "${live_dest}" ]; then - log_begin_msg "Copying live_media to ${live_dest}" - copy_live_to "${livefs_root}" "${live_dest}" - log_end_msg - fi - - mount_images_in_directory "${livefs_root}" "${rootmnt}" - - log_end_msg - - maybe_break casper-bottom - [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-bottom" - - pulsate - run_scripts /scripts/casper-bottom - [ "$quiet" != "y" ] && log_end_msg - - exec 1>&6 6>&- - exec 2>&7 7>&- - cp casper.log "${rootmnt}/var/log/" -} diff --git a/scripts/casper-bottom/01integrity_check b/scripts/casper-bottom/01integrity_check deleted file mode 100755 index 637a1ff..0000000 --- a/scripts/casper-bottom/01integrity_check +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -PREREQ="" - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -grep integrity-check /proc/cmdline && casper-md5check /cdrom /cdrom/md5sum.txt < /dev/tty8 diff --git a/scripts/casper-bottom/02_timezone b/scripts/casper-bottom/02_timezone deleted file mode 100755 index 1cb6402..0000000 --- a/scripts/casper-bottom/02_timezone +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Adding APT-CDROM source..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -cp -f /root/usr/share/zoneinfo/UTC /root/etc/localtime diff --git a/scripts/casper-bottom/05mountpoints b/scripts/casper-bottom/05mountpoints deleted file mode 100755 index 7c61de3..0000000 --- a/scripts/casper-bottom/05mountpoints +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Moving mount points..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -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 - -log_end_msg diff --git a/scripts/casper-bottom/10adduser b/scripts/casper-bottom/10adduser deleted file mode 100755 index 4fe9378..0000000 --- a/scripts/casper-bottom/10adduser +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Adding live session user..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -# U6aMy0wojraho is just a blank password -chroot /root debconf-communicate -fnoninteractive casper > /dev/null < /dev/null - -# Clear out debconf database again to avoid confusing ubiquity later. -chroot /root debconf-communicate -fnoninteractive casper > /dev/null <> /root/etc/sudoers - elif [ "${BUILD_SYSTEM}" = "Debian" ]; then - echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers - fi -fi - -# 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 - -if [ -L /root/home/$USERNAME/Examples ]; then - chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/ - mv /root/home/$USERNAME/Examples /root/home/$USERNAME/Desktop/ -fi - -log_end_msg diff --git a/scripts/casper-bottom/12fstab b/scripts/casper-bottom/12fstab deleted file mode 100755 index 616216a..0000000 --- a/scripts/casper-bottom/12fstab +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring fstab..." -FSTAB=/root/etc/fstab - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -cat > $FSTAB </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" - fi -done - -for device in $devices; do - cat >> $FSTAB <> "${grep_file}" - printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen - chroot /root /usr/sbin/locale-gen "${LANG}" -fi - -log_end_msg diff --git a/scripts/casper-bottom/15autologin b/scripts/casper-bottom/15autologin deleted file mode 100755 index 81bd3a4..0000000 --- a/scripts/casper-bottom/15autologin +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Setting up automatic login..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then - GDMCONF=/etc/gdm/gdm-cdd.conf -else - GDMCONF=/etc/gdm/gdm.conf -fi - -if chroot /root [ -f ${GDMCONF} ]; then - # Configure GDM autologin - chroot /root sed -i \ - -e "s/^AutomaticLoginEnable=.*\$/AutomaticLoginEnable=true/" \ - -e "s/^AutomaticLogin=.*\$/AutomaticLogin=$USERNAME/" \ - -e "s/^TimedLoginEnable=.*\$/TimedLoginEnable=true/" \ - -e "s/^TimedLogin=.*\$/TimedLogin=$USERNAME/" \ - -e "s/^TimedLoginDelay=.*\$/TimedLoginDelay=10/" \ - ${GDMCONF} -fi - -if [ -f /root/etc/kde3/kdm/kdmrc ]; then - # Configure KDM autologin - sed -i -r \ - -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \ - -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \ - -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \ - /root/etc/kde3/kdm/kdmrc -fi - -if chroot /root /usr/bin/which kpersonalizer >/dev/null; then - # Disable first-login wizard for KDE - if [ ! -f /root/etc/kde3/kpersonalizerrc ]; then - cat > /root/etc/kde3/kpersonalizerrc <&2 - echo "Because kpersonalizerrc already exists" >&2 - fi -fi - -log_end_msg diff --git a/scripts/casper-bottom/18hostname b/scripts/casper-bottom/18hostname deleted file mode 100755 index 19ac61f..0000000 --- a/scripts/casper-bottom/18hostname +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Setting hostname..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -echo "$HOST" > /root/etc/hostname -cat > /root/etc/hosts < /dev/null </dev/null) || panel_version="" -if [ -n "$panel_version" ]; then - chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/panel/global/disable_lock_screen true -fi - -log_end_msg diff --git a/scripts/casper-bottom/22screensaver b/scripts/casper-bottom/22screensaver deleted file mode 100755 index 39c0f22..0000000 --- a/scripts/casper-bottom/22screensaver +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring screensaver..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -gnome_screensaver_version=$(chroot /root dpkg-query -W --showformat='${Version}' gnome-screensaver 2>/dev/null) || gnome_screensaver_version="" -if [ -n "$gnome_screensaver_version" ]; then - # Support legacy gconf value - chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock false - chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock_enabled false -fi - -log_end_msg diff --git a/scripts/casper-bottom/23etc_modules b/scripts/casper-bottom/23etc_modules deleted file mode 100755 index 754a832..0000000 --- a/scripts/casper-bottom/23etc_modules +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Preconfiguring /etc/modules..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -case "$DPKG_ARCH" in -# load the right modules -powerpc|ppc64) - echo snd_powermac >> /root/etc/modules - ;; -esac - -log_end_msg diff --git a/scripts/casper-bottom/23networking b/scripts/casper-bottom/23networking deleted file mode 100755 index 1b732d3..0000000 --- a/scripts/casper-bottom/23networking +++ /dev/null @@ -1,107 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Preconfiguring networking..." -IFFILE="/root/etc/network/interfaces" - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -if [ "${STATICIP}" = "frommedia" -a -e "$IFFILE" ] ; then - # will use existent /etc/network/interfaces - log_end_msg - exit 0 -fi - -cat > "$IFFILE" <> "$IFFILE" <> "$IFFILE" < /root/etc/resolv.conf <> /root/var/log/netboot.config - fi -fi - -for i in eth0 eth1 eth2 ath0 wlan0; do - grep -q "iface $i" $IFFILE && continue - cat >> "$IFFILE" </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) 2>\&1|" $f - done - fi -fi - -# This has the nice side effect of the cron.{daily,weekly,monthly} jobs in -# /etc/crontab remaining disabled, yet also not run by anacron -if [ -x /root/etc/init.d/anacron ]; then - for f in /root/etc/rc?.d/S??anacron; do - mv ${f} ${f%/*}/K00anacron - done -fi - -# No point, really -rm -f /root/etc/rc?.d/[SK]??postfix - -# Avoid clobbering the user's clock -rm -f /root/etc/rc?.d/K??hwclock.sh - -# Disable readahead since it doesn't play well with squashfs + unionfs -# use chmod instead of mv to not trigger unionfs bugs. -if [ -e /root/sbin/readahead-list ]; then - chmod -x /root/sbin/readahead-list -fi - -log_end_msg - -exit 0 diff --git a/scripts/casper-bottom/30accessibility b/scripts/casper-bottom/30accessibility deleted file mode 100755 index 01c2386..0000000 --- a/scripts/casper-bottom/30accessibility +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring accessibility options..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -gconf_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gconf2 2>/dev/null) || gconf_version="" - -gct() { - if [ "$gconf_version" ]; then - chroot /root sudo -u "$USERNAME" gconftool-2 "$@" - fi -} - -kderc_addtoprefixes() { - if [ -e "/root/etc/kderc" ]; then - sed -i "s|\\(prefixes=/usr/share/kubuntu-default-settings/kde-profile/default/\\)|\\1,$1|" /root/etc/kderc - fi -} - -for x in $(cat /proc/cmdline); do - case $x in - # Lesser Visual Impairment - access=v1) - gct -s -t string /desktop/gnome/interface/gtk_theme HighContrastLargePrint - gct -s -t string /desktop/gnome/interface/icon_theme HighContrast - gct -s -t string /desktop/gnome/interface/monospace_font_name "monospace 18" - gct -s -t string /desktop/gnome/interface/font_name "sans 18" - gct -s -t string /apps/metacity/general/theme Atlanta - gct -s -t string /desktop/gnome/background/picture_filename "" - gct -s -t string /desktop/gnome/background/picture_options none - gct -s -t string /desktop/gnome/background/primary_color \#666666 - gct -s -t string /desktop/gnome/background/secondary_color \#7F7F7F - gct -s -t string /desktop/gnome/background/color_shading_type solid - gct -s -t int /desktop/gnome/peripherals/mouse/cursor_size 48 - gct -s -t string /desktop/gnome/peripherals/mouse/cursor_theme whiteglass - - kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/ - if [ -d /root/usr/share/xubuntu-default-settings/accessibility ]; then - cp -a /root/usr/share/xubuntu-default-settings/accessibility/* /root/etc/xdg/ - fi - ;; - # Moderate Visual Impairment - access=v2) - gct -s -t bool /desktop/gnome/interface/accessibility true - gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] - if [ -e /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py ]; then - sed -i '/^enableSpeech\W/ s/True/False/;/^enableMagnifier/ s/False/True/' /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py - fi - kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/,/usr/share/kubuntu-default-settings/kde-profile/moderate-visual-impairment/ - ;; - # Blindness - access=v3) - gct -s -t bool /desktop/gnome/sound/enable_esd false - gct -s -t bool /desktop/gnome/interface/accessibility true - gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] - ;; - # Minor Motor Difficulties - access=m1) - gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/mousekeys_enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep true - gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false - gct -s -t bool /desktop/gnome/peripherals/keyboard/repeat true - gct -s -t int /desktop/gnome/peripherals/keyboard/delay 700 - gct -s -t int /desktop/gnome/peripherals/keyboard/rate 10 - - 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 - ;; - # Motor Difficulties - pointing devices - access=m2) - gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true - gct -s -t bool /desktop/gnome/interface/accessibility true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true - gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep false - gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false - gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [onboard] - - 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 - ;; - esac -done -log_end_msg diff --git a/scripts/casper-bottom/31disable_update_notifier b/scripts/casper-bottom/31disable_update_notifier deleted file mode 100755 index 2461c25..0000000 --- a/scripts/casper-bottom/31disable_update_notifier +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Disabling update-notifier..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -# For GNOME, we divert away apt-check to avoid a regular 'apt-get update' -# equivalent in the live session. We want to run update-notifier for crash -# report handling. -chroot /root dpkg-divert --add --rename --quiet \ - /usr/lib/update-notifier/apt-check -ln -s /bin/true /root/usr/lib/update-notifier/apt-check - -# For KDE, adept_notifier's only useful function at the moment is an -# 'apt-get update' equivalent, so we disable it entirely. -rm -f /root/usr/share/autostart/adept_notifier_auto.desktop - -log_end_msg diff --git a/scripts/casper-bottom/32disable_hibernation b/scripts/casper-bottom/32disable_hibernation deleted file mode 100755 index ae4badd..0000000 --- a/scripts/casper-bottom/32disable_hibernation +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Configuring power management..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - - -gpm_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-power-manager 2>/dev/null) || panel_version="" -if [ -n "$gpm_version" ]; then -# casper-reconfigure /root gnome-power-manager - chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_hibernate false - chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_suspend false -fi - -if [ -d /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config ]; then - echo "disableSuspend=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc - echo "disableHibernate=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc -fi - -log_end_msg diff --git a/scripts/casper-bottom/33enable_apport_crashes b/scripts/casper-bottom/33enable_apport_crashes deleted file mode 100755 index d1c8829..0000000 --- a/scripts/casper-bottom/33enable_apport_crashes +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -PREREQ="" -DESCRIPTION="Enabling notifications about program crashes..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -update_notifier_version=$(chroot /root dpkg-query -W --showformat='${Version}' update-notifier 2>/dev/null) || update_notifier_version="" -if [ -n "$update_notifier_version" ]; then - chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/update-notifier/show_apport_crashes true -fi - -log_end_msg diff --git a/scripts/casper-bottom/34disable_kwallet b/scripts/casper-bottom/34disable_kwallet deleted file mode 100755 index add7cca..0000000 --- a/scripts/casper-bottom/34disable_kwallet +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Disabling kwallet..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -rm -f /root/usr/share/services/kded/kwalletd.desktop - -log_end_msg \ No newline at end of file diff --git a/scripts/casper-bottom/35fix_language_selector b/scripts/casper-bottom/35fix_language_selector deleted file mode 100755 index 3a22602..0000000 --- a/scripts/casper-bottom/35fix_language_selector +++ /dev/null @@ -1,32 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Fixing language selector..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -log_begin_msg "$DESCRIPTION" - -if [ -e /root/usr/share/applications/language-selector.desktop ]; then - sed -i '/^Exec/ s|/usr/bin/gnome-language-selector|"& -n"|' /root/usr/share/applications/language-selector.desktop - -fi - -if [ -x /root/usr/bin/fontconfig-voodoo ]; then - chroot /root fontconfig-voodoo --auto --quiet || true -fi - -log_end_msg diff --git a/scripts/casper-bottom/40install_driver_updates b/scripts/casper-bottom/40install_driver_updates deleted file mode 100755 index 272a0ed..0000000 --- a/scripts/casper-bottom/40install_driver_updates +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Installing driver updates..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -if [ ! -d /tmp/driver-updates ]; then - exit 0 -fi - -log_begin_msg "$DESCRIPTION" - -install_dir=/var/cache/driver-updates - -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. -for deb in "/root$install_dir"/*; do - if ! chroot /root dpkg -i "$install_dir/$deb"; then - chroot /root dpkg -P "${deb%%_*}" - fi -done - -log_end_msg diff --git a/scripts/casper-bottom/41apt_cdrom b/scripts/casper-bottom/41apt_cdrom deleted file mode 100755 index b4ab643..0000000 --- a/scripts/casper-bottom/41apt_cdrom +++ /dev/null @@ -1,24 +0,0 @@ -#! /bin/sh - -PREREQ="" -DESCRIPTION="Adding APT-CDROM source..." - -. /scripts/casper-functions - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -mkdir -p /root/cdrom -mount -n -o bind /cdrom /root/cdrom -chroot /root apt-cdrom -m add -umount /root/cdrom diff --git a/scripts/casper-functions b/scripts/casper-functions deleted file mode 100644 index 60721b4..0000000 --- a/scripts/casper-functions +++ /dev/null @@ -1,21 +0,0 @@ - -. /scripts/functions - -# Override this so we don't call PROGRESS -log_end_msg() -{ - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "SUCCESS ok" - fi - _log_msg "Done." -} - -# Print a message and wait for enter -log_wait_msg() -{ - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "INPUTENTER $@" - read nunya < /dev/.initramfs/usplash_outfifo - fi - _log_msg "Waiting: $@ ..." -} diff --git a/scripts/casper-helpers b/scripts/casper-helpers deleted file mode 100644 index 8402d93..0000000 --- a/scripts/casper-helpers +++ /dev/null @@ -1,197 +0,0 @@ -## Casper helper functions, used by casper on boot and by casper-snapshot - -if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then - MP_QUIET="-Q" -elif [ "${BUILD_SYSTEM}" = "Debian" ]; then - MP_QUIET="-q" -else - MP_QUIET="" -fi - -if [ ! -x "/bin/fstype" ]; then - # klibc not in path -> not in initramfs - export PATH="${PATH}:/usr/lib/klibc/bin" -fi - -sys2dev() { - sysdev=${1#/sys} - echo "/dev/$(udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})" -} - -subdevices() { - sysblock=$1 - r="" - for dev in "${sysblock}" "${sysblock}"/*; do - if [ -e "${dev}/dev" ]; then - r="${r} ${dev}" - fi - done - echo ${r} -} - -get_fstype() { - local FSTYPE - local FSSIZE - eval $(fstype < $1) - if [ "$FSTYPE" != "unknown" ]; then - echo $FSTYPE - return 0 - fi - /lib/udev/vol_id -t $1 2>/dev/null -} - -where_is_mounted() { - device=$1 - if grep -q "^$device " /proc/mounts; then - grep "^$device " /proc/mounts | read d mountpoint rest - echo $mountpoint - return 0 - fi - return 1 -} - -lastline() { - while read lines ; do - line=${lines} - done - echo "${line}" -} - -base_path () -{ - testpath="${1}" - mounts="$(awk '{print $2}' /proc/mounts)" - testpath="$(busybox realpath ${testpath})" - - while true ; do - if echo "${mounts}" | grep -qs "^${testpath}" ; then - set -- `echo "${mounts}" | grep "^${testpath}" | lastline` - echo ${1} - break - else - testpath=`dirname $testpath` - fi - done -} - -fs_size () -{ - # Returns used/free fs kbytes + 5% more - # You could pass a block device as $1 or the mount point as $2 - - dev="${1}" - mountp="${2}" - used="${3}" - - if [ -z "${mountp}" ]; then - mountp=$(where_is_mounted "${dev}") - if [ "$?" -gt 0 ]; then - mountp="/mnt/tmp_fs_size" - mkdir -p "${mountp}" - mount -t $(get_fstype "${dev}") -o ro "${dev}" "${mountp}" - doumount=1 - fi - fi - - if [ "${used}" = "used" ]; then - size=$(du -ks ${mountp} | cut -f1) - size=$(expr ${size} + ${size} / 20 ) # FIXME: 5% more to be sure - else - # free space - size="$(df -k | grep -s ${mountp} | awk '{print $4}')" - fi - - if [ -n "${doumount}" ]; then - umount "${mountp}" - rmdir "${mountp}" - fi - echo "${size}" -} - -setup_loop() { - local fspath=$1 - local module=$2 - local pattern=$3 - local offset=$4 - - modprobe ${MP_QUIET} -b "$module" - udevsettle - - for loopdev in $pattern; do - if [ "$(cat $loopdev/size)" -eq 0 ]; then - dev=$(sys2dev "${loopdev}") - if [ -n "$offset" ]; then - losetup -o "$offset" "$dev" "$fspath" - else - losetup "$dev" "$fspath" - fi - echo "$dev" - return 0 - fi - done - panic "No loop devices available" -} - -try_mount () -{ - dev="${1}" - mountp="${2}" - opts="${3}" - - if where_is_mounted ${dev} > /dev/null; then - mount -o remount,"${opts}" ${dev} $(where_is_mounted ${dev}) || panic "Remounting failed" - mount -o bind $(where_is_mounted ${dev}) ${mountp} || panic "Cannot bind-mount" - else - mount -t $(get_fstype "${dev}") -o "${opts}" "${dev}" "${mountp}" || panic "Cannot mount ${dev} on ${mountp}" - fi -} - -find_cow_device() { - pers_label="${1}" - cow_backing="/${pers_label}-backing" - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do - for dev in $(subdevices "${sysblock}"); do - devname=$(sys2dev "${dev}") - if [ "$(/lib/udev/vol_id -l $devname 2>/dev/null)" = "${pers_label}" ]; then - echo "$devname" - return - elif [ "$(get_fstype ${devname})" = "vfat" ]; then # FIXME: all supported block devices should be scanned - mkdir -p "${cow_backing}" - try_mount "${devname}" "${cow_backing}" "rw" - if [ -e "${cow_backing}/${pers_label}" ]; then - echo $(setup_loop "${cow_backing}/${pers_label}" "loop" "/sys/block/loop*") - return 0 - else - umount ${cow_backing} - fi - fi - done - done -} - -find_files() -# return the first of $filenames found on vfat and ext2 devices -# FIXME: merge with above function -{ - filenames="${1}" - snap_backing="/snap-backing" - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do - for dev in $(subdevices "${sysblock}"); do - devname=$(sys2dev "${dev}") - devfstype="$(get_fstype ${devname})" - if [ "${devfstype}" = "vfat" ] || [ "${devfstype}" = "ext2" ] ; then # FIXME: all supported block devices should be scanned - mkdir -p "${snap_backing}" - try_mount "${devname}" "${snap_backing}" "ro" - for filename in ${filenames}; do - if [ -e "${snap_backing}/${filename}" ]; then - echo "${devname} ${snap_backing} ${filename}" - return 0 - fi - done - umount ${snap_backing} - fi - done - done -} - - diff --git a/scripts/casper-premount/10driver_updates b/scripts/casper-premount/10driver_updates deleted file mode 100755 index 8009849..0000000 --- a/scripts/casper-premount/10driver_updates +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/sh - -PREREQ="" -. /scripts/casper-functions -. /scripts/casper-helpers - -prereqs() -{ - echo "$PREREQ" -} - -case $1 in -# get pre-requisites -prereqs) - prereqs - exit 0 - ;; -esac - -mountpoint=/cdrom - -is_updates_path() { - # Driver packages are stored in ubuntu-drivers// - # subdirectory. Each package contains a module for a specific - # kernel flavour. - path=$1 - kbase=$(uname -r | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)-.*/\1/') - update_dir="$path/ubuntu-drivers/$kbase" - if [ -d "$update_dir" ]; then - if [ "$(echo $update_dir/*_$DPKG_ARCH.deb)" != \ - "$update_dir/*_$DPKG_ARCH.deb" ]; then - echo "$update_dir" - return 0; - fi - fi - return 1; -} - -is_nice_device() { - sysfs_path="${1#/sys}" - if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then - return 0 - fi - return 1 -} - -is_supported_fs () { - # FIXME: do something better like the scan of supported filesystems - fstype="${1}" - case ${fstype} in - vfat|iso9660|udf|ext2|ext3|ntfs) - return 0 - ;; - esac - return 1 -} - -check_dev_updates () -{ - sysdev="${1}" - devname="${2}" - if [ -z "${devname}" ]; then - devname=$(sys2dev "${sysdev}") - fi - - fstype=$(get_fstype "${devname}") - if is_supported_fs ${fstype}; then - mount -t ${fstype} -o ro "${devname}" $mountpoint || continue - if is_updates_path $mountpoint; then - return 0 - else - umount $mountpoint - fi - fi - - return 1 -} - -find_driver_updates() { - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do - devname=$(sys2dev "${sysblock}") - fstype=$(get_fstype "${devname}") - if /lib/udev/cdrom_id ${devname} > /dev/null; then - if check_dev_updates "null" "${devname}" ; then - return 0 - fi - elif is_nice_device "${sysblock}" ; then - for dev in $(subdevices "${sysblock}"); do - if check_dev_updates "${dev}" ; then - return 0 - fi - done - fi - done - return 1 -} - -pulsate() { - if [ -x /sbin/usplash_write ]; then - /sbin/usplash_write "PULSATE" - fi -} - - -updates="false" - -for x in $(cat /proc/cmdline); do - case $x in - debian-installer/driver-update=*) - updates=${x#debian-installer/driver-update=} - ;; - esac -done - -if [ "$updates" != "true" ]; then - log_end_msg - exit 0 -fi - -# Not sure what to do for network installs. I assume there isn't even a CD -# for this anyway, so fail. -if [ -n "${NETBOOT}" ]; then - log_end_msg - exit 0; -fi - -#if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then -# GDMCONF=/etc/gdm/gdm-cdd.conf -#else -# GDMCONF=/etc/gdm/gdm.conf -#fi - -eject -log_wait_msg "Insert a driver CD and press ENTER ($DPKG_ARCH)" - -log_begin_msg "Looking for driver update CD" - -for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do - updates_root=$(find_driver_updates) - if [ "${updates_root}" ]; then - break; - fi - sleep 1 -done - -log_end_msg - -if [ -z "${updates_root}" ]; then - log_begin_msg "Could not find driver updates" - log_wait_msg "Re-insert install CD and press ENTER" - exit 0 -fi - -log_begin_msg "Copying driver updates to temporary location" - -mkdir -p /tmp/driver-updates -cp $updates_root/*_$DPKG_ARCH.deb /tmp/driver-updates/ -umount $mountpoint -eject - -log_end_msg - -log_wait_msg "Re-insert install CD and press ENTER." diff --git a/scripts/live b/scripts/live new file mode 100755 index 0000000..9ab1ac5 --- /dev/null +++ b/scripts/live @@ -0,0 +1,549 @@ +#!/bin/sh + +# set -e + +export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin + +echo "/root/lib" >> /etc/ld.so.conf +echo "/root/usr/lib" >> /etc/ld.so.conf + +mountpoint=/cdrom + +USERNAME=user +USERFULLNAME="Live session user" +HOST=live +BUILD_SYSTEM=Custom + +mkdir -p $mountpoint + +[ -f /etc/live.conf ] && . /etc/live.conf +export USERNAME USERFULLNAME HOST BUILD_SYSTEM + +. /scripts/live-helpers + +if [ ! -f /live.vars ]; then + touch /live.vars +fi + +is_casper_path() { + path=$1 + if [ -d "$path/live" ]; then + if [ "$(echo $path/live/*.squashfs)" != "$path/live/*.squashfs" ] || + [ "$(echo $path/live/*.ext2)" != "$path/live/*.ext2" ] || + [ "$(echo $path/live/*.dir)" != "$path/live/*.dir" ]; then + return 0 + fi + fi + return 1 +} + +get_backing_device() { + case "$1" in + *.squashfs|*.ext2) + echo $(setup_loop "$1" "loop" "/sys/block/loop*") + ;; + *.dir) + echo "directory" + ;; + *) + panic "Unrecognized live filesystem: $1" + ;; + esac +} + +match_files_in_dir() { + # Does any files match pattern $1 ? + + local pattern="$1" + if [ "$(echo $pattern)" != "$pattern" ]; then + return 0 + fi + return 1 +} + +mount_images_in_directory() { + directory="$1" + rootmnt="$2" + if match_files_in_dir "$directory/live/*.squashfs" || + match_files_in_dir "$directory/live/*.ext2" || + match_files_in_dir "$directory/live/*.dir"; then + setup_unionfs "$directory/live" "$rootmnt" + else + : + fi +} + +is_nice_device() { + sysfs_path="${1#/sys}" + if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then + return 0 + fi + return 1 +} + +is_supported_fs () { + # FIXME: do something better like the scan of supported filesystems + fstype="${1}" + case ${fstype} in + vfat|iso9660|udf|ext2|ext3|ntfs) + return 0 + ;; + esac + return 1 +} + +copy_live_to() { + copyfrom="${1}" + copytodev="${2}" + copyto="${copyfrom}_swap" + + size=$(fs_size "" ${copyfrom} "used") + + if [ "${copytodev}" = "ram" ]; then + # copying to ram: + freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) ) + mount_options="-o size=${size}k" + free_string="memory" + fstype="tmpfs" + dev="/dev/shm" + else + # it should be a writable block device + if [ -b "${copytodev}" ]; then + dev="${copytodev}" + free_string="space" + fstype=$(get_fstype "${dev}") + freespace=$(fs_size "${dev}") + else + [ "$quiet" != "y" ] && log_warning_msg "${copytodev} is not a block device." + return 1 + fi + fi + if [ "${freespace}" -lt "${size}" ] ; then + [ "$quiet" != "y" ] && log_warning_msg "Not enough free ${free_string} (${freespace}k > ${size}k) to copy live media in ${copytodev}." + return 1 + fi + + # begin copying.. + mkdir "${copyto}" + echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}" + mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}" + cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files + umount ${copyfrom} + mount -r -o move ${copyto} ${copyfrom} + rmdir ${copyto} + return 0 +} + +do_netmount() { + rc=1 + + modprobe "${MP_QUIET}" af_packet # For DHCP + + udevtrigger + udevsettle + + ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config + + if [ "${NFSROOT}" = "auto" ]; then + NFSROOT=${ROOTSERVER}:${ROOTPATH} + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}" + + if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then + rc=0 + elif do_nfsmount ; then + NETBOOT="nfs" + export NETBOOT + rc=0 + fi + + [ "$quiet" != "y" ] && log_end_msg + return ${rc} +} + +do_nfsmount() { + rc=1 + modprobe "${MP_QUIET}" nfs + if [ -z "${NFSOPTS}" ]; then + NFSOPTS="" + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}" + # FIXME: This for loop is an ugly HACK round an nfs bug + for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do + nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break + sleep 1 + done + return ${rc} +} + +do_cifsmount() { + rc=1 + if [ -x "/sbin/mount.cifs" ]; then + if [ -z "${NFSOPTS}" ]; then + CIFSOPTS="-ouser=root,password=" + else + CIFSOPTS="${NFSOPTS}" + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}" + modprobe "${MP_QUIET}" cifs + + if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then + rc=0 + fi + fi + return ${rc} +} + +do_snap_copy () +{ + fromdev="${1}" + todir="${2}" + snap_type="${3}" + + size=$(fs_size "${fromdev}" "" "used") + + if [ -b "${fromdev}" ]; then + # look for free mem + if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]; then + todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' ) + freespace=$(df -k | grep -s ${todev} | awk '{print $4}') + else + freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - )) + fi + + tomount="/mnt/tmpsnap" + if [ ! -d "${tomount}" ] ; then + mkdir -p "${tomount}" + fi + + fstype=$(get_fstype "${fromdev}") + if [ -n "${fstype}" ]; then + # Copying stuff... + mount -t "${fstype}" -o ro "${fromdev}" "${tomount}" + cp -a "${tomount}"/* ${todir} + umount "${tomount}" + else + log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}" + fi + + rmdir "${tomount}" + if echo ${fromdev} | grep -qs loop; then + losetup -d "${fromdev}" + fi + return 0 + else + return 1 + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the snapshot ${snap_type} medium" + fi +} + +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 + + snap_label="${1}" + snap_mount="${2}" + snap_type="${3}" + + snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2") + if [ ! -z "${snapdata}" ]; then + snapdev="$(echo ${snapdata} | cut -f1 -d ' ')" + snapback="$(echo ${snapdata} | cut -f2 -d ' ')" + snapfile="$(echo ${snapdata} | cut -f3 -d ' ')" + if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\)'; then + # squashfs or ext2 snapshot + dev=$(get_backing_device "${snapback}/${snapfile}") + if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"; then + log_warning_msg "Impossible to include the ${snapfile} Snapshot" + return 1 + fi + else + # cpio.gz snapshot + if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i -u -d 2>/dev/null) ; then + log_warning_msg "Impossible to include the ${snapfile} Snapshot" + return 1 + fi + fi + umount "${snapback}" + else + dev=$(find_cow_device "${snap_label}") + if [ -b ${dev} ]; then + if echo "${dev}" | grep -qs loop; then + # strange things happens, user confused? + snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' ) + snapfile=$(basename ${snaploop}) + snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ') + else + snapdev="${dev}" + fi + if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" ; then + log_warning_msg "Impossible to include the ${snap_label} Snapshot" + return 1 + else + if [ -n "${snapfile}" ]; then + # it was a loop device, user confused + umount ${snapdev} + fi + fi + else + log_warning_msg "Impossible to include the ${snap_label} Snapshot" + return 1 + fi + fi + echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt + return 0 +} + +setup_unionfs() { + image_directory="$1" + rootmnt="$2" + + modprobe "${MP_QUIET}" -b unionfs + + # run-init can't deal with images in a subdir, but we're going to + # move all of these away before it runs anyway. No, we're not, + # put them in / since move-mounting them into / breaks mono and + # some other apps. + + croot="/" + + # Let's just mount the read-only file systems first + rofsstring="" + rofslist="" + if [ "${NETBOOT}" = "nfs" ] ; then + roopt="nfsro" # go aroung a bug in nfs-unionfs locking + else + 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 + done + done + rofsstring=${rofsstring%:} + + mkdir -p /cow + cowdevice="tmpfs" + cow_fstype="tmpfs" + + # Looking for "${root_persistence}" device or file + if [ -n "${PERSISTENT}" ]; then + cowprobe=$(find_cow_device "${root_persistence}") + if [ -b "${cowprobe}" ]; then + cowdevice=${cowprobe} + cow_fstype=$(get_fstype "${cowprobe}") + else + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium" + fi + fi + + mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow" + + mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs mount failed" + + # Adding other custom mounts + if [ -n "${PERSISTENT}" ]; then + # directly mount /home + # FIXME: add a custom mounts configurable system + homecow=$(find_cow_device "${home_persistence}" ) + if [ -b "${homecow}" ]; then + mount -t $(get_fstype "${homecow}") -o rw "${homecow}" "${rootmnt}/home" + export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy() + else + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium" + fi + # Look for other snapshots to copy in + try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT" + try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME" + fi + + if [ -n "${SHOWMOUNTS}" ]; then + for d in ${rofslist}; do + mkdir -p "${rootmnt}/live/${d##*/}" + case d in + *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}" + ;; + *) mount -o move "${d}" "${rootmnt}/live/${d##*/}" + ;; + 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 +} + +check_dev () +{ + sysdev="${1}" + devname="${2}" + if [ -z "${devname}" ]; then + devname=$(sys2dev "${sysdev}") + fi + + if [ -n "${LIVEMEDIA_OFFSET}" ]; then + loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_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 + echo $mountpoint + return 0 + else + umount $mountpoint + fi + fi + + if [ -n "${LIVEMEDIA_OFFSET}" ]; then + losetup -d "${loopdevname}" + fi + return 1 +} + +find_livefs() { + timeout="${1}" + # first look at the one specified in the command line + if [ ! -z "${LIVEMEDIA}" ]; then + if check_dev "null" "${LIVEMEDIA}"; then + return 0 + fi + fi + # don't start autodetection before timeout has expired + if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then + if [ "${timeout}" -lt "${LIVEMEDIA_TIMEOUT}" ]; then + return 1 + fi + fi + # or do the scan of block devices + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do + devname=$(sys2dev "${sysblock}") + fstype=$(get_fstype "${devname}") + if /lib/udev/cdrom_id ${devname} > /dev/null; then + if check_dev "null" "${devname}" ; then + return 0 + fi + elif is_nice_device "${sysblock}" ; then + for dev in $(subdevices "${sysblock}"); do + if check_dev "${dev}" ; then + return 0 + fi + done + elif [ "${fstype}" = "squashfs" -o \ + "${fstype}" = "ext3" -o \ + "${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. + ln -s "${devname}" "${devname}.${fstype}" + echo "${devname}.${fstype}" + return 0 + fi + done + return 1 +} + +pulsate() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "PULSATE" + fi +} + +set_usplash_timeout() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "TIMEOUT 120" + fi +} + +mountroot() { + exec 6>&1 + exec 7>&2 + exec > live.log + exec 2>&1 + + set_usplash_timeout + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-premount" + pulsate + run_scripts /scripts/live-premount + [ "$quiet" != "y" ] && log_end_msg + + # Needed here too because some things (*cough* udev *cough*) + # changes the timeout + + set_usplash_timeout + + if [ ! -z "${NETBOOT}" ]; then + if do_netmount ; then + livefs_root="${mountpoint}" + else + 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 [ "${livefs_root}" ]; then + break + fi + sleep 1 + done + fi + + if [ -z "${livefs_root}" ]; then + panic "Unable to find a medium containing a live file system" + fi + + if [ "${TORAM}" ]; then + live_dest="ram" + elif [ "${TODISK}" ]; then + live_dest="${TODISK}" + fi + if [ "${live_dest}" ]; then + log_begin_msg "Copying live_media to ${live_dest}" + copy_live_to "${livefs_root}" "${live_dest}" + log_end_msg + fi + + mount_images_in_directory "${livefs_root}" "${rootmnt}" + + log_end_msg + + maybe_break live-bottom + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/live-bottom" + + pulsate + run_scripts /scripts/live-bottom + [ "$quiet" != "y" ] && log_end_msg + + exec 1>&6 6>&- + exec 2>&7 7>&- + cp live.log "${rootmnt}/var/log/" +} diff --git a/scripts/live-bottom/01integrity_check b/scripts/live-bottom/01integrity_check new file mode 100755 index 0000000..d5bc5fe --- /dev/null +++ b/scripts/live-bottom/01integrity_check @@ -0,0 +1,18 @@ +#!/bin/sh + +PREREQ="" + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +grep integrity-check /proc/cmdline && live-md5check /cdrom /cdrom/md5sum.txt < /dev/tty8 diff --git a/scripts/live-bottom/02_timezone b/scripts/live-bottom/02_timezone new file mode 100755 index 0000000..873c1da --- /dev/null +++ b/scripts/live-bottom/02_timezone @@ -0,0 +1,21 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Setting timezone..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +cp -f /root/usr/share/zoneinfo/UTC /root/etc/localtime diff --git a/scripts/live-bottom/05mountpoints b/scripts/live-bottom/05mountpoints new file mode 100755 index 0000000..411660d --- /dev/null +++ b/scripts/live-bottom/05mountpoints @@ -0,0 +1,27 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Moving mount points..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +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 + +log_end_msg diff --git a/scripts/live-bottom/10adduser b/scripts/live-bottom/10adduser new file mode 100755 index 0000000..9179f1b --- /dev/null +++ b/scripts/live-bottom/10adduser @@ -0,0 +1,66 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Adding live session user..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +# U6aMy0wojraho is just a blank password +chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null < /dev/null + +# Clear out debconf database again to avoid confusing ubiquity later. +chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null <> /root/etc/sudoers + elif [ "${BUILD_SYSTEM}" = "Debian" ]; then + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers + fi +fi + +# 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 + +if [ -L /root/home/$USERNAME/Examples ]; then + chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/ + mv /root/home/$USERNAME/Examples /root/home/$USERNAME/Desktop/ +fi + +log_end_msg diff --git a/scripts/live-bottom/12fstab b/scripts/live-bottom/12fstab new file mode 100755 index 0000000..fa9c642 --- /dev/null +++ b/scripts/live-bottom/12fstab @@ -0,0 +1,31 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring fstab..." +FSTAB=/root/etc/fstab + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +cat > $FSTAB </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" + fi +done + +for device in $devices; do + cat >> $FSTAB <> "${grep_file}" + printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen + chroot /root /usr/sbin/locale-gen "${LANG}" +fi + +log_end_msg diff --git a/scripts/live-bottom/15autologin b/scripts/live-bottom/15autologin new file mode 100755 index 0000000..4b64dc7 --- /dev/null +++ b/scripts/live-bottom/15autologin @@ -0,0 +1,62 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Setting up automatic login..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then + GDMCONF=/etc/gdm/gdm-cdd.conf +else + GDMCONF=/etc/gdm/gdm.conf +fi + +if chroot /root [ -f ${GDMCONF} ]; then + # Configure GDM autologin + chroot /root sed -i \ + -e "s/^AutomaticLoginEnable=.*\$/AutomaticLoginEnable=true/" \ + -e "s/^AutomaticLogin=.*\$/AutomaticLogin=$USERNAME/" \ + -e "s/^TimedLoginEnable=.*\$/TimedLoginEnable=true/" \ + -e "s/^TimedLogin=.*\$/TimedLogin=$USERNAME/" \ + -e "s/^TimedLoginDelay=.*\$/TimedLoginDelay=10/" \ + ${GDMCONF} +fi + +if [ -f /root/etc/kde3/kdm/kdmrc ]; then + # Configure KDM autologin + sed -i -r \ + -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \ + -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \ + -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \ + /root/etc/kde3/kdm/kdmrc +fi + +if chroot /root /usr/bin/which kpersonalizer >/dev/null; then + # Disable first-login wizard for KDE + if [ ! -f /root/etc/kde3/kpersonalizerrc ]; then + cat > /root/etc/kde3/kpersonalizerrc <&2 + echo "Because kpersonalizerrc already exists" >&2 + fi +fi + +log_end_msg diff --git a/scripts/live-bottom/18hostname b/scripts/live-bottom/18hostname new file mode 100755 index 0000000..591e4ec --- /dev/null +++ b/scripts/live-bottom/18hostname @@ -0,0 +1,38 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Setting hostname..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +echo "$HOST" > /root/etc/hostname +cat > /root/etc/hosts < /dev/null </dev/null) || panel_version="" +if [ -n "$panel_version" ]; then + chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/panel/global/disable_lock_screen true +fi + +log_end_msg diff --git a/scripts/live-bottom/22screensaver b/scripts/live-bottom/22screensaver new file mode 100755 index 0000000..6193a41 --- /dev/null +++ b/scripts/live-bottom/22screensaver @@ -0,0 +1,30 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring screensaver..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +gnome_screensaver_version=$(chroot /root dpkg-query -W --showformat='${Version}' gnome-screensaver 2>/dev/null) || gnome_screensaver_version="" +if [ -n "$gnome_screensaver_version" ]; then + # Support legacy gconf value + chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock false + chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/gnome-screensaver/lock_enabled false +fi + +log_end_msg diff --git a/scripts/live-bottom/23etc_modules b/scripts/live-bottom/23etc_modules new file mode 100755 index 0000000..6eec342 --- /dev/null +++ b/scripts/live-bottom/23etc_modules @@ -0,0 +1,30 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Preconfiguring /etc/modules..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +case "$DPKG_ARCH" in +# load the right modules +powerpc|ppc64) + echo snd_powermac >> /root/etc/modules + ;; +esac + +log_end_msg diff --git a/scripts/live-bottom/23networking b/scripts/live-bottom/23networking new file mode 100755 index 0000000..988206e --- /dev/null +++ b/scripts/live-bottom/23networking @@ -0,0 +1,107 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Preconfiguring networking..." +IFFILE="/root/etc/network/interfaces" + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if [ "${STATICIP}" = "frommedia" -a -e "$IFFILE" ] ; then + # will use existent /etc/network/interfaces + log_end_msg + exit 0 +fi + +cat > "$IFFILE" <> "$IFFILE" <> "$IFFILE" < /root/etc/resolv.conf <> /root/var/log/netboot.config + fi +fi + +for i in eth0 eth1 eth2 ath0 wlan0; do + grep -q "iface $i" $IFFILE && continue + cat >> "$IFFILE" </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) 2>\&1|" $f + done + fi +fi + +# This has the nice side effect of the cron.{daily,weekly,monthly} jobs in +# /etc/crontab remaining disabled, yet also not run by anacron +if [ -x /root/etc/init.d/anacron ]; then + for f in /root/etc/rc?.d/S??anacron; do + mv ${f} ${f%/*}/K00anacron + done +fi + +# No point, really +rm -f /root/etc/rc?.d/[SK]??postfix + +# Avoid clobbering the user's clock +rm -f /root/etc/rc?.d/K??hwclock.sh + +# Disable readahead since it doesn't play well with squashfs + unionfs +# use chmod instead of mv to not trigger unionfs bugs. +if [ -e /root/sbin/readahead-list ]; then + chmod -x /root/sbin/readahead-list +fi + +log_end_msg + +exit 0 diff --git a/scripts/live-bottom/30accessibility b/scripts/live-bottom/30accessibility new file mode 100755 index 0000000..127c48f --- /dev/null +++ b/scripts/live-bottom/30accessibility @@ -0,0 +1,106 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring accessibility options..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +gconf_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gconf2 2>/dev/null) || gconf_version="" + +gct() { + if [ "$gconf_version" ]; then + chroot /root sudo -u "$USERNAME" gconftool-2 "$@" + fi +} + +kderc_addtoprefixes() { + if [ -e "/root/etc/kderc" ]; then + sed -i "s|\\(prefixes=/usr/share/kubuntu-default-settings/kde-profile/default/\\)|\\1,$1|" /root/etc/kderc + fi +} + +for x in $(cat /proc/cmdline); do + case $x in + # Lesser Visual Impairment + access=v1) + gct -s -t string /desktop/gnome/interface/gtk_theme HighContrastLargePrint + gct -s -t string /desktop/gnome/interface/icon_theme HighContrast + gct -s -t string /desktop/gnome/interface/monospace_font_name "monospace 18" + gct -s -t string /desktop/gnome/interface/font_name "sans 18" + gct -s -t string /apps/metacity/general/theme Atlanta + gct -s -t string /desktop/gnome/background/picture_filename "" + gct -s -t string /desktop/gnome/background/picture_options none + gct -s -t string /desktop/gnome/background/primary_color \#666666 + gct -s -t string /desktop/gnome/background/secondary_color \#7F7F7F + gct -s -t string /desktop/gnome/background/color_shading_type solid + gct -s -t int /desktop/gnome/peripherals/mouse/cursor_size 48 + gct -s -t string /desktop/gnome/peripherals/mouse/cursor_theme whiteglass + + kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/ + if [ -d /root/usr/share/xubuntu-default-settings/accessibility ]; then + cp -a /root/usr/share/xubuntu-default-settings/accessibility/* /root/etc/xdg/ + fi + ;; + # Moderate Visual Impairment + access=v2) + gct -s -t bool /desktop/gnome/interface/accessibility true + gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] + if [ -e /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py ]; then + sed -i '/^enableSpeech\W/ s/True/False/;/^enableMagnifier/ s/False/True/' /root/usr/share/pycentral/gnome-orca/site-packages/orca/settings.py + fi + kderc_addtoprefixes /usr/share/kubuntu-default-settings/kde-profile/lesser-visual-impairment/,/usr/share/kubuntu-default-settings/kde-profile/moderate-visual-impairment/ + ;; + # Blindness + access=v3) + gct -s -t bool /desktop/gnome/sound/enable_esd false + gct -s -t bool /desktop/gnome/interface/accessibility true + gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [orca] + ;; + # Minor Motor Difficulties + access=m1) + gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/mousekeys_enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep true + gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false + gct -s -t bool /desktop/gnome/peripherals/keyboard/repeat true + gct -s -t int /desktop/gnome/peripherals/keyboard/delay 700 + gct -s -t int /desktop/gnome/peripherals/keyboard/rate 10 + + 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 + ;; + # Motor Difficulties - pointing devices + access=m2) + gct -s -t bool /desktop/gnome/accessibility/keyboard/enable true + gct -s -t bool /desktop/gnome/interface/accessibility true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_enable true + gct -s -t bool /desktop/gnome/accessibility/keyboard/stickykeys_modifier_beep false + gct -s -t bool /desktop/accessibility/gnome/keyboard/stickykeys_two_key_off false + gct -s -t list --list-type=string /desktop/gnome/accessibility/startup/exec_ats [onboard] + + 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 + ;; + esac +done +log_end_msg diff --git a/scripts/live-bottom/31disable_update_notifier b/scripts/live-bottom/31disable_update_notifier new file mode 100755 index 0000000..6c8b96f --- /dev/null +++ b/scripts/live-bottom/31disable_update_notifier @@ -0,0 +1,34 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Disabling update-notifier..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +# For GNOME, we divert away apt-check to avoid a regular 'apt-get update' +# equivalent in the live session. We want to run update-notifier for crash +# report handling. +chroot /root dpkg-divert --add --rename --quiet \ + /usr/lib/update-notifier/apt-check +ln -s /bin/true /root/usr/lib/update-notifier/apt-check + +# For KDE, adept_notifier's only useful function at the moment is an +# 'apt-get update' equivalent, so we disable it entirely. +rm -f /root/usr/share/autostart/adept_notifier_auto.desktop + +log_end_msg diff --git a/scripts/live-bottom/32disable_hibernation b/scripts/live-bottom/32disable_hibernation new file mode 100755 index 0000000..813abed --- /dev/null +++ b/scripts/live-bottom/32disable_hibernation @@ -0,0 +1,36 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Configuring power management..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + + +gpm_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-power-manager 2>/dev/null) || panel_version="" +if [ -n "$gpm_version" ]; then +# live-reconfigure /root gnome-power-manager + chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_hibernate false + chroot /root sudo -u "$USERNAME" gconftool-2 -s -t bool /apps/gnome-power-manager/can_suspend false +fi + +if [ -d /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config ]; then + echo "disableSuspend=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc + echo "disableHibernate=1" >> /root/usr/share/kubuntu-default-settings/kde-profile/default/share/config/power-managerrc +fi + +log_end_msg diff --git a/scripts/live-bottom/33enable_apport_crashes b/scripts/live-bottom/33enable_apport_crashes new file mode 100755 index 0000000..1fb1145 --- /dev/null +++ b/scripts/live-bottom/33enable_apport_crashes @@ -0,0 +1,28 @@ +#!/bin/sh + +PREREQ="" +DESCRIPTION="Enabling notifications about program crashes..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +update_notifier_version=$(chroot /root dpkg-query -W --showformat='${Version}' update-notifier 2>/dev/null) || update_notifier_version="" +if [ -n "$update_notifier_version" ]; then + chroot /root sudo -u "$USERNAME" gconftool-2 -t bool -s /apps/update-notifier/show_apport_crashes true +fi + +log_end_msg diff --git a/scripts/live-bottom/34disable_kwallet b/scripts/live-bottom/34disable_kwallet new file mode 100755 index 0000000..9fd0c26 --- /dev/null +++ b/scripts/live-bottom/34disable_kwallet @@ -0,0 +1,25 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Disabling kwallet..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +rm -f /root/usr/share/services/kded/kwalletd.desktop + +log_end_msg diff --git a/scripts/live-bottom/35fix_language_selector b/scripts/live-bottom/35fix_language_selector new file mode 100755 index 0000000..1fb78e5 --- /dev/null +++ b/scripts/live-bottom/35fix_language_selector @@ -0,0 +1,32 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Fixing language selector..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +log_begin_msg "$DESCRIPTION" + +if [ -e /root/usr/share/applications/language-selector.desktop ]; then + sed -i '/^Exec/ s|/usr/bin/gnome-language-selector|"& -n"|' /root/usr/share/applications/language-selector.desktop + +fi + +if [ -x /root/usr/bin/fontconfig-voodoo ]; then + chroot /root fontconfig-voodoo --auto --quiet || true +fi + +log_end_msg diff --git a/scripts/live-bottom/40install_driver_updates b/scripts/live-bottom/40install_driver_updates new file mode 100755 index 0000000..5822f8f --- /dev/null +++ b/scripts/live-bottom/40install_driver_updates @@ -0,0 +1,40 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Installing driver updates..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +if [ ! -d /tmp/driver-updates ]; then + exit 0 +fi + +log_begin_msg "$DESCRIPTION" + +install_dir=/var/cache/driver-updates + +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. +for deb in "/root$install_dir"/*; do + if ! chroot /root dpkg -i "$install_dir/$deb"; then + chroot /root dpkg -P "${deb%%_*}" + fi +done + +log_end_msg diff --git a/scripts/live-bottom/41apt_cdrom b/scripts/live-bottom/41apt_cdrom new file mode 100755 index 0000000..97b2cdc --- /dev/null +++ b/scripts/live-bottom/41apt_cdrom @@ -0,0 +1,24 @@ +#! /bin/sh + +PREREQ="" +DESCRIPTION="Adding APT-CDROM source..." + +. /scripts/live-functions + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +mkdir -p /root/cdrom +mount -n -o bind /cdrom /root/cdrom +chroot /root apt-cdrom -m add +umount /root/cdrom diff --git a/scripts/live-functions b/scripts/live-functions new file mode 100644 index 0000000..60721b4 --- /dev/null +++ b/scripts/live-functions @@ -0,0 +1,21 @@ + +. /scripts/functions + +# Override this so we don't call PROGRESS +log_end_msg() +{ + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "SUCCESS ok" + fi + _log_msg "Done." +} + +# Print a message and wait for enter +log_wait_msg() +{ + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "INPUTENTER $@" + read nunya < /dev/.initramfs/usplash_outfifo + fi + _log_msg "Waiting: $@ ..." +} diff --git a/scripts/live-helpers b/scripts/live-helpers new file mode 100644 index 0000000..8402d93 --- /dev/null +++ b/scripts/live-helpers @@ -0,0 +1,197 @@ +## Casper helper functions, used by casper on boot and by casper-snapshot + +if [ "${BUILD_SYSTEM}" = "Ubuntu" ]; then + MP_QUIET="-Q" +elif [ "${BUILD_SYSTEM}" = "Debian" ]; then + MP_QUIET="-q" +else + MP_QUIET="" +fi + +if [ ! -x "/bin/fstype" ]; then + # klibc not in path -> not in initramfs + export PATH="${PATH}:/usr/lib/klibc/bin" +fi + +sys2dev() { + sysdev=${1#/sys} + echo "/dev/$(udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})" +} + +subdevices() { + sysblock=$1 + r="" + for dev in "${sysblock}" "${sysblock}"/*; do + if [ -e "${dev}/dev" ]; then + r="${r} ${dev}" + fi + done + echo ${r} +} + +get_fstype() { + local FSTYPE + local FSSIZE + eval $(fstype < $1) + if [ "$FSTYPE" != "unknown" ]; then + echo $FSTYPE + return 0 + fi + /lib/udev/vol_id -t $1 2>/dev/null +} + +where_is_mounted() { + device=$1 + if grep -q "^$device " /proc/mounts; then + grep "^$device " /proc/mounts | read d mountpoint rest + echo $mountpoint + return 0 + fi + return 1 +} + +lastline() { + while read lines ; do + line=${lines} + done + echo "${line}" +} + +base_path () +{ + testpath="${1}" + mounts="$(awk '{print $2}' /proc/mounts)" + testpath="$(busybox realpath ${testpath})" + + while true ; do + if echo "${mounts}" | grep -qs "^${testpath}" ; then + set -- `echo "${mounts}" | grep "^${testpath}" | lastline` + echo ${1} + break + else + testpath=`dirname $testpath` + fi + done +} + +fs_size () +{ + # Returns used/free fs kbytes + 5% more + # You could pass a block device as $1 or the mount point as $2 + + dev="${1}" + mountp="${2}" + used="${3}" + + if [ -z "${mountp}" ]; then + mountp=$(where_is_mounted "${dev}") + if [ "$?" -gt 0 ]; then + mountp="/mnt/tmp_fs_size" + mkdir -p "${mountp}" + mount -t $(get_fstype "${dev}") -o ro "${dev}" "${mountp}" + doumount=1 + fi + fi + + if [ "${used}" = "used" ]; then + size=$(du -ks ${mountp} | cut -f1) + size=$(expr ${size} + ${size} / 20 ) # FIXME: 5% more to be sure + else + # free space + size="$(df -k | grep -s ${mountp} | awk '{print $4}')" + fi + + if [ -n "${doumount}" ]; then + umount "${mountp}" + rmdir "${mountp}" + fi + echo "${size}" +} + +setup_loop() { + local fspath=$1 + local module=$2 + local pattern=$3 + local offset=$4 + + modprobe ${MP_QUIET} -b "$module" + udevsettle + + for loopdev in $pattern; do + if [ "$(cat $loopdev/size)" -eq 0 ]; then + dev=$(sys2dev "${loopdev}") + if [ -n "$offset" ]; then + losetup -o "$offset" "$dev" "$fspath" + else + losetup "$dev" "$fspath" + fi + echo "$dev" + return 0 + fi + done + panic "No loop devices available" +} + +try_mount () +{ + dev="${1}" + mountp="${2}" + opts="${3}" + + if where_is_mounted ${dev} > /dev/null; then + mount -o remount,"${opts}" ${dev} $(where_is_mounted ${dev}) || panic "Remounting failed" + mount -o bind $(where_is_mounted ${dev}) ${mountp} || panic "Cannot bind-mount" + else + mount -t $(get_fstype "${dev}") -o "${opts}" "${dev}" "${mountp}" || panic "Cannot mount ${dev} on ${mountp}" + fi +} + +find_cow_device() { + pers_label="${1}" + cow_backing="/${pers_label}-backing" + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do + for dev in $(subdevices "${sysblock}"); do + devname=$(sys2dev "${dev}") + if [ "$(/lib/udev/vol_id -l $devname 2>/dev/null)" = "${pers_label}" ]; then + echo "$devname" + return + elif [ "$(get_fstype ${devname})" = "vfat" ]; then # FIXME: all supported block devices should be scanned + mkdir -p "${cow_backing}" + try_mount "${devname}" "${cow_backing}" "rw" + if [ -e "${cow_backing}/${pers_label}" ]; then + echo $(setup_loop "${cow_backing}/${pers_label}" "loop" "/sys/block/loop*") + return 0 + else + umount ${cow_backing} + fi + fi + done + done +} + +find_files() +# return the first of $filenames found on vfat and ext2 devices +# FIXME: merge with above function +{ + filenames="${1}" + snap_backing="/snap-backing" + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do + for dev in $(subdevices "${sysblock}"); do + devname=$(sys2dev "${dev}") + devfstype="$(get_fstype ${devname})" + if [ "${devfstype}" = "vfat" ] || [ "${devfstype}" = "ext2" ] ; then # FIXME: all supported block devices should be scanned + mkdir -p "${snap_backing}" + try_mount "${devname}" "${snap_backing}" "ro" + for filename in ${filenames}; do + if [ -e "${snap_backing}/${filename}" ]; then + echo "${devname} ${snap_backing} ${filename}" + return 0 + fi + done + umount ${snap_backing} + fi + done + done +} + + diff --git a/scripts/live-premount/10driver_updates b/scripts/live-premount/10driver_updates new file mode 100755 index 0000000..55aece5 --- /dev/null +++ b/scripts/live-premount/10driver_updates @@ -0,0 +1,163 @@ +#!/bin/sh + +PREREQ="" +. /scripts/live-functions +. /scripts/live-helpers + +prereqs() +{ + echo "$PREREQ" +} + +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +mountpoint=/cdrom + +is_updates_path() { + # Driver packages are stored in ubuntu-drivers// + # subdirectory. Each package contains a module for a specific + # kernel flavour. + path=$1 + kbase=$(uname -r | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)-.*/\1/') + update_dir="$path/ubuntu-drivers/$kbase" + if [ -d "$update_dir" ]; then + if [ "$(echo $update_dir/*_$DPKG_ARCH.deb)" != \ + "$update_dir/*_$DPKG_ARCH.deb" ]; then + echo "$update_dir" + return 0; + fi + fi + return 1; +} + +is_nice_device() { + sysfs_path="${1#/sys}" + if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then + return 0 + fi + return 1 +} + +is_supported_fs () { + # FIXME: do something better like the scan of supported filesystems + fstype="${1}" + case ${fstype} in + vfat|iso9660|udf|ext2|ext3|ntfs) + return 0 + ;; + esac + return 1 +} + +check_dev_updates () +{ + sysdev="${1}" + devname="${2}" + if [ -z "${devname}" ]; then + devname=$(sys2dev "${sysdev}") + fi + + fstype=$(get_fstype "${devname}") + if is_supported_fs ${fstype}; then + mount -t ${fstype} -o ro "${devname}" $mountpoint || continue + if is_updates_path $mountpoint; then + return 0 + else + umount $mountpoint + fi + fi + + return 1 +} + +find_driver_updates() { + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do + devname=$(sys2dev "${sysblock}") + fstype=$(get_fstype "${devname}") + if /lib/udev/cdrom_id ${devname} > /dev/null; then + if check_dev_updates "null" "${devname}" ; then + return 0 + fi + elif is_nice_device "${sysblock}" ; then + for dev in $(subdevices "${sysblock}"); do + if check_dev_updates "${dev}" ; then + return 0 + fi + done + fi + done + return 1 +} + +pulsate() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "PULSATE" + fi +} + + +updates="false" + +for x in $(cat /proc/cmdline); do + case $x in + debian-installer/driver-update=*) + updates=${x#debian-installer/driver-update=} + ;; + esac +done + +if [ "$updates" != "true" ]; then + log_end_msg + exit 0 +fi + +# Not sure what to do for network installs. I assume there isn't even a CD +# for this anyway, so fail. +if [ -n "${NETBOOT}" ]; then + log_end_msg + exit 0; +fi + +#if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]; then +# GDMCONF=/etc/gdm/gdm-cdd.conf +#else +# GDMCONF=/etc/gdm/gdm.conf +#fi + +eject +log_wait_msg "Insert a driver CD and press ENTER ($DPKG_ARCH)" + +log_begin_msg "Looking for driver update CD" + +for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do + updates_root=$(find_driver_updates) + if [ "${updates_root}" ]; then + break; + fi + sleep 1 +done + +log_end_msg + +if [ -z "${updates_root}" ]; then + log_begin_msg "Could not find driver updates" + log_wait_msg "Re-insert install CD and press ENTER" + exit 0 +fi + +log_begin_msg "Copying driver updates to temporary location" + +mkdir -p /tmp/driver-updates +cp $updates_root/*_$DPKG_ARCH.deb /tmp/driver-updates/ +umount $mountpoint +eject + +log_end_msg + +log_wait_msg "Re-insert install CD and press ENTER." -- cgit v1.2.3