aboutsummaryrefslogtreecommitdiff
path: root/tools/XBMCLive/live-initramfs/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'tools/XBMCLive/live-initramfs/scripts')
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live1725
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/02etc_live_conf51
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/02timezone60
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/05mountpoints36
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/06hostname62
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/08persistence_excludes77
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/10adduser120
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/12fstab102
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/14locales131
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/15autologin89
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/16umountfs38
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/19keyboard103
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/20xconfig92
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/21xdriver51
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/21xvidemode68
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/22gnome_panel_data49
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/22screensaver43
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/23etc_modules36
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/23networking157
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/24preseed68
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/25configure_init114
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/30accessibility181
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/31disable_update_notifier49
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/32disable_hibernation45
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/33enable_apport_crashes39
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/34disable_kpersonalizer51
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/35fix_language_selector44
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/36disable_trackerd38
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/38jockey_disable_check29
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/41apt_cdrom39
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/42disable_apparmor39
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/43disable_updateinitramfs41
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/44pk_allow65
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-bottom/99hook43
-rw-r--r--tools/XBMCLive/live-initramfs/scripts/live-functions113
-rw-r--r--tools/XBMCLive/live-initramfs/scripts/live-helpers501
-rwxr-xr-xtools/XBMCLive/live-initramfs/scripts/live-premount/modules32
37 files changed, 4621 insertions, 0 deletions
diff --git a/tools/XBMCLive/live-initramfs/scripts/live b/tools/XBMCLive/live-initramfs/scripts/live
new file mode 100755
index 0000000000..4472f2ad6d
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live
@@ -0,0 +1,1725 @@
+#!/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="/live/image"
+LIVE_MEDIA_PATH="live"
+
+root_persistence="live-rw"
+home_persistence="home-rw"
+root_snapshot_label="live-sn"
+home_snapshot_label="home-sn"
+
+USERNAME="user"
+USERFULLNAME="Live user"
+HOSTNAME="host"
+
+mkdir -p "${mountpoint}"
+
+# Create /etc/mtab for debug purpose and future syncs
+if [ ! -d /etc ]
+then
+ mkdir /etc/
+fi
+
+if [ ! -f /etc/mtab ]
+then
+ touch /etc/mtab
+fi
+
+[ -f /etc/live.conf ] && . /etc/live.conf
+export USERNAME USERFULLNAME HOSTNAME
+
+. /scripts/live-helpers
+
+if [ ! -f /live.vars ]
+then
+ touch /live.vars
+fi
+
+Arguments ()
+{
+ PRESEEDS=""
+
+ for ARGUMENT in $(cat /proc/cmdline)
+ do
+ case "${ARGUMENT}" in
+ access=*)
+ ACCESS="${ARGUMENT#access=}"
+ export ACCESS
+ ;;
+
+ console=*)
+ DEFCONSOLE="${ARGUMENT#*=}"
+ export DEFCONSOLE
+ ;;
+
+ debug)
+ DEBUG="Yes"
+ export DEBUG
+
+ set -x
+ ;;
+
+ fetch=*)
+ FETCH="${ARGUMENT#fetch=}"
+ export FETCH
+ ;;
+
+ hook=*)
+ HOOK="${ARGUMENT#hook=}"
+ export HOOK
+ ;;
+
+ ftpfs=*)
+ FTPFS="${ARGUMENT#ftpfs=}"
+ export FTPFS
+ ;;
+
+ httpfs=*)
+ HTTPFS="${ARGUMENT#httpfs=}"
+ export HTTPFS
+ ;;
+
+ hostname=*)
+ HOSTNAME="${ARGUMENT#hostname=}"
+ LIVECONF="changed"
+ export HOSTNAME LIVECONF
+ ;;
+
+ username=*)
+ USERNAME="${ARGUMENT#username=}"
+ LIVECONF="changed"
+ export USERNAME LIVECONF
+ ;;
+
+ userfullname=*)
+ USERFULLNAME="${ARGUMENT#userfullname=}"
+ LIVECONF="changed"
+ export USERFULLNAME LIVECONF
+ ;;
+
+ ignore_uuid)
+ IGNORE_UUID="Yes"
+ export IGNORE_UUID
+ ;;
+
+ integrity-check)
+ INTEGRITY_CHECK="Yes"
+ export INTEGRITY_CHECK
+ ;;
+
+ ip=*)
+ STATICIP="${ARGUMENT#ip=}"
+
+ if [ -z "${STATICIP}" ]
+ then
+ STATICIP="frommedia"
+ fi
+
+ export STATICIP
+ ;;
+
+ keyb=*|kbd-chooser/method=*)
+ KBD="${ARGUMENT#*=}"
+ export KBD
+ ;;
+
+ klayout=*|console-setup/layoutcode=*)
+ KLAYOUT="${ARGUMENT#*=}"
+ export KLAYOUT
+ ;;
+
+ kvariant=*|console-setup/variantcode=*)
+ KVARIANT="${ARGUMENT#*=}"
+ export KVARIANT
+ ;;
+
+ kmodel=*|console-setup/modelcode=*)
+ KMODEL="${ARGUMENT#*=}"
+ export KMODEL
+ ;;
+
+ koptions=*)
+ KOPTIONS="${ARGUMENT#koptions=}"
+ export KOPTIONS
+ ;;
+
+ live-getty)
+ LIVE_GETTY="1"
+ export LIVE_GETTY
+ ;;
+
+ live-media=*|bootfrom=*)
+ LIVE_MEDIA="${ARGUMENT#*=}"
+ export LIVE_MEDIA
+ ;;
+
+ live-media-encryption=*|encryption=*)
+ LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
+ export LIVE_MEDIA_ENCRYPTION
+ ;;
+
+ live-media-offset=*)
+ LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
+ export LIVE_MEDIA_OFFSET
+ ;;
+
+ live-media-path=*)
+ LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
+ export LIVE_MEDIA_PATH
+ ;;
+
+ live-media-timeout=*)
+ LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
+ export LIVE_MEDIA_TIMEOUT
+ ;;
+
+ language=*|debian-installer/language=*)
+ language=${x#debian-installer/language=}
+ locale="$(lang2locale "$language")"
+ set_locale="true"
+ ;;
+
+ locale=*|debian-installer/locale=*)
+ LOCALE="${ARGUMENT#*=}"
+ export LOCALE
+ ;;
+
+ module=*)
+ MODULE="${ARGUMENT#module=}"
+ export MODULE
+ ;;
+
+ netboot=*)
+ NETBOOT="${ARGUMENT#netboot=}"
+ export NETBOOT
+ ;;
+
+ nfsopts=*)
+ NFSOPTS="${ARGUMENT#nfsopts=}"
+ export NFSOPTS
+ ;;
+
+ nfscow=*)
+ NFS_COW="${ARGUMENT#nfscow=}"
+ export NFS_COW
+ ;;
+
+ noaccessibility)
+ NOACCESSIBILITY="Yes"
+ export NOACCESSIBILITY
+ ;;
+
+ noapparmor)
+ NOAPPARMOR="Yes"
+ export NOAPPARMOR
+ ;;
+
+ noaptcdrom)
+ NOAPTCDROM="Yes"
+ export NOAPTCDROM
+ ;;
+
+ noautologin)
+ NOAUTOLOGIN="Yes"
+ export NOAUTOLOGIN
+ ;;
+
+ noxautologin)
+ NOXAUTOLOGIN="Yes"
+ export NOXAUTOLOGIN
+ ;;
+
+ noconsolekeyboard)
+ NOCONSOLEKEYBOARD="Yes"
+ export NOCONSOLEKEYBOARD
+ ;;
+
+ nofastboot)
+ NOFASTBOOT="Yes"
+ export NOFASTBOOT
+ ;;
+
+ nofstab)
+ NOFSTAB="Yes"
+ export NOFSTAB
+ ;;
+
+ nognomepanel)
+ NOGNOMEPANEL="Yes"
+ export NOGNOMEPANEL
+ ;;
+
+ nohosts)
+ NOHOSTS="Yes"
+ export NOHOSTS
+ ;;
+
+ nokpersonalizer)
+ NOKPERSONALIZER="Yes"
+ export NOKPERSONALIZER
+ ;;
+
+ nolanguageselector)
+ NOLANGUAGESELECTOR="Yes"
+ export NOLANGUAGESELECTOR
+ ;;
+
+ nolocales)
+ NOLOCALES="Yes"
+ export NOLOCALES
+ ;;
+
+ nonetworking)
+ NONETWORKING="Yes"
+ export NONETWORKING
+ ;;
+
+ nopowermanagement)
+ NOPOWERMANAGEMENT="Yes"
+ export NOPOWERMANAGEMENT
+ ;;
+
+ noprogramcrashes)
+ NOPROGRAMCRASHES="Yes"
+ export NOPROGRAMCRASHES
+ ;;
+
+ nojockey)
+ NOJOCKEY="Yes"
+ export NOJOCKEY
+ ;;
+
+ nosudo)
+ NOSUDO="Yes"
+ export NOSUDO
+ ;;
+
+ swapon)
+ SWAPON="Yes"
+ export SWAPON
+ ;;
+
+ noupdatenotifier)
+ NOUPDATENOTIFIER="Yes"
+ export NOUPDATENOTIFIER
+ ;;
+
+ nouser)
+ NOUSER="Yes"
+ export NOUSER
+ ;;
+
+ nopolkitconf)
+ NOPOLKITCONF="Yes"
+ export NOPOLKITCONF
+ ;;
+
+ noxautoconfig)
+ NOXAUTOCONFIG="Yes"
+ export NOXAUTOCONFIG
+ ;;
+
+ noxscreensaver)
+ NOXSCREENSAVER="Yes"
+ export NOXSCREENSAVER
+ ;;
+
+ persistent)
+ PERSISTENT="Yes"
+ export PERSISTENT
+ ;;
+
+ persistent=*)
+ PERSISTENT="${ARGUMENT#persistent=}"
+ if [ -z "${PERSISTENT}" ]
+ then
+ PERSISTENT="Yes"
+ fi
+ export PERSISTENT
+ ;;
+
+ persistent-path=*)
+ PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
+ export PERSISTENT_PATH
+ ;;
+
+ nopersistent)
+ NOPERSISTENT="Yes"
+ export NOPERSISTENT
+ ;;
+
+ quickusbmodules)
+ QUICKUSBMODULES="Yes"
+ export QUICKUSBMODULES
+ ;;
+
+ preseed/file=*|file=*)
+ LOCATION="${ARGUMENT#*=}"
+ export LOCATION
+ ;;
+
+ nopreseed)
+ NOPRESEED="Yes"
+ export NOPRESEED
+ ;;
+
+ url=*)
+ location="${ARGUMENT#url=}"
+
+ mount -o bind /sys /root/sys
+ mount -o bind /proc /root/proc
+ mount -o bind /dev /root/dev
+
+ mkdir -p /root/var/run/network
+ chroot /root dhclient eth0
+ chroot /root wget -P /tmp "${location}"
+ chroot /root ifconfig eth0 down
+
+ umount /root/sys
+ umount /root/proc
+ umount /root/dev
+
+ LOCATION="/tmp/$(basename "${location}")"
+ ;;
+
+ skipconfig)
+ NOTIMEZONE="Yes"
+ export NOTIMEZONE
+ NOACCESSIBILITY="Yes"
+ export NOACCESSIBILITY
+ NOAPPARMOR="Yes"
+ export NOAPPARMOR
+ NOAPTCDROM="Yes"
+ export NOAPTCDROM
+ NOAUTOLOGIN="Yes"
+ export NOAUTOLOGIN
+ NOXAUTOLOGIN="Yes"
+ export NOXAUTOLOGIN
+ NOCONSOLEKEYBOARD="Yes"
+ export NOCONSOLEKEYBOARD
+ NOFASTBOOT="Yes"
+ export NOFASTBOOT
+ NOFSTAB="Yes"
+ export NOFSTAB
+ NOGNOMEPANEL="Yes"
+ export NOGNOMEPANEL
+ NOHOSTS="Yes"
+ export NOHOSTS
+ NOKPERSONALIZER="Yes"
+ export NOKPERSONALIZER
+ NOLANGUAGESELECTOR="Yes"
+ export NOLANGUAGESELECTOR
+ NOLOCALES="Yes"
+ export NOLOCALES
+ NONETWORKING="Yes"
+ export NONETWORKING
+ NOPOWERMANAGEMENT="Yes"
+ export NOPOWERMANAGEMENT
+ NOPROGRAMCRASHES="Yes"
+ export NOPROGRAMCRASHES
+ NOJOCKEY="Yes"
+ export NOJOCKEY
+ NOSUDO="Yes"
+ export NOSUDO
+ NOUPDATENOTIFIER="Yes"
+ export NOUPDATENOTIFIER
+ NOUSER="Yes"
+ export NOUSER
+ NOPOLKITCONF="Yes"
+ export NOPOLKITCONF
+ NOXAUTOCONFIG="Yes"
+ export NOXAUTOCONFIG
+ NOXSCREENSAVER="Yes"
+ export NOXSCREENSAVER
+ ;;
+
+ */*=*)
+ question="${ARGUMENT%%=*}"
+ value="${ARGUMENT#*=}"
+ PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
+ export PRESEEDS
+ ;;
+
+ showmounts)
+ SHOWMOUNTS="Yes"
+ export SHOWMOUNTS
+ ;;
+
+ silent)
+ SILENT="Yes"
+ export SILENT
+ ;;
+
+ textonly)
+ TEXTONLY="Yes"
+ export TEXTONLY
+ ;;
+
+ timezone=*)
+ TIMEZONE="${ARGUMENT#timezone=}"
+ export TIMEZONE
+ ;;
+
+ notimezone)
+ NOTIMEZONE="Yes"
+ export NOTIMEZONE
+ ;;
+
+ todisk=*)
+ TODISK="${ARGUMENT#todisk=}"
+ export TODISK
+ ;;
+
+ toram)
+ TORAM="Yes"
+ export TORAM
+ ;;
+
+ toram=*)
+ TORAM="Yes"
+ MODULETORAM="${ARGUMENT#toram=}"
+ export TORAM MODULETORAM
+ ;;
+
+ exposedroot)
+ EXPOSED_ROOT="Yes"
+ export EXPOSED_ROOT
+ ;;
+
+ plainroot)
+ PLAIN_ROOT="Yes"
+ export PLAIN_ROOT
+ ;;
+
+ skipunion)
+ SKIP_UNION_MOUNTS="Yes"
+ export SKIP_UNION_MOUNTS
+ ;;
+
+ root=*)
+ ROOT="${ARGUMENT#root=}"
+ export ROOT
+ ;;
+
+ union=*)
+ UNIONTYPE="${ARGUMENT#union=}"
+ export UNIONTYPE
+ ;;
+
+ utc=*)
+ UTC="${ARGUMENT#utc=}"
+ export UTC
+ ;;
+
+ xdebconf)
+ XDEBCONF="Yes"
+ export XDEBCONF
+ ;;
+
+ xdriver=*)
+ XDRIVER="${ARGUMENT#xdriver=}"
+ export XDRIVER
+ ;;
+
+ xvideomode=*)
+ XVIDEOMODE="${ARGUMENT#xvideomode=}"
+ export XVIDEOMODE
+ ;;
+ 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="filesystem"
+ export MODULE
+ fi
+
+ if [ -z "${UNIONTYPE}" ]
+ then
+ UNIONTYPE="aufs"
+ export UNIONTYPE
+ fi
+}
+
+is_live_path ()
+{
+ DIRECTORY="${1}"
+
+ if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
+ then
+ for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
+ do
+ if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
+ then
+ return 0
+ fi
+ done
+ fi
+
+ return 1
+}
+
+matches_uuid ()
+{
+ if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
+ then
+ return 0
+ fi
+
+ path="${1}"
+ uuid="$(cat /conf/uuid.conf)"
+
+ for try_uuid_file in "${path}/.disk/live-uuid"*
+ do
+ [ -e "${try_uuid_file}" ] || continue
+
+ try_uuid="$(cat "${try_uuid_file}")"
+
+ if [ "${uuid}" = "${try_uuid}" ]
+ then
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+get_backing_device ()
+{
+ case "${1}" in
+ *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
+ echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
+ ;;
+
+ *.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}"
+ mac="${3}"
+
+
+ if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
+ match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
+ match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
+ match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
+ match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
+ match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
+ then
+ [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
+ setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
+ else
+ panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
+ 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
+ elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
+ then
+ return 0
+ fi
+
+ return 1
+}
+
+copy_live_to ()
+{
+ copyfrom="${1}"
+ copytodev="${2}"
+ copyto="${copyfrom}_swap"
+
+ if [ -z "${MODULETORAM}" ]
+ then
+ size=$(fs_size "" ${copyfrom} "used")
+ else
+ MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
+
+ if [ -f "${MODULETORAMFILE}" ]
+ then
+ size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
+ else
+ log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
+ return 1
+ fi
+ fi
+
+ if [ "${copytodev}" = "ram" ]
+ then
+ # copying to ram:
+ freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
+ 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
+ log_warning_msg "${copytodev} is not a block device."
+ return 1
+ fi
+ fi
+
+ if [ "${freespace}" -lt "${size}" ]
+ then
+ log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
+ return 1
+ fi
+
+ # begin copying (or uncompressing)
+ mkdir "${copyto}"
+ echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
+ mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
+
+ if [ "${extension}" = "tgz" ]
+ then
+ cd "${copyto}"
+ tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
+ rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
+ mount -r -o move "${copyto}" "${rootmnt}"
+ cd "${OLDPWD}"
+ else
+ if [ -n "${MODULETORAMFILE}" ]
+ then
+ cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
+ else
+ cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
+ fi
+
+ umount ${copyfrom}
+ mount -r -o move ${copyto} ${copyfrom}
+ fi
+
+ rmdir ${copyto}
+ return 0
+}
+
+do_netmount ()
+{
+ rc=1
+
+ modprobe -q af_packet # For DHCP
+
+ if [ -x /sbin/udevadm ]
+ then
+ # lenny
+ udevadm trigger
+ udevadm settle
+ else
+ # etch
+ udevtrigger
+ udevsettle
+ fi
+
+ ipconfig ${DEVICE} | tee /netboot.config
+
+ # source relevant ipconfig output
+ OLDHOSTNAME=${HOSTNAME}
+ . /tmp/net-${DEVICE}.conf
+ [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
+ export HOSTNAME
+
+ # Check if we have a network device at all
+ if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
+ ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
+ ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
+ ! ls /sys/class/net/ra0 > /dev/null 2>&1
+ then
+ panic "No supported network device found, maybe a non-mainline driver is required."
+ fi
+
+ if [ "${NFSROOT}" = "auto" ]
+ then
+ NFSROOT=${ROOTSERVER}:${ROOTPATH}
+ fi
+
+ if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
+ then
+ rc=0
+ return ${rc}
+ fi
+
+ if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
+ then
+ NFSROOT=${ROOTSERVER}:${NFSROOT}
+ fi
+
+ 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
+
+ log_end_msg
+ return ${rc}
+}
+
+do_httpmount ()
+{
+ rc=1
+ dest="${mountpoint}/${LIVE_MEDIA_PATH}"
+ mount -t ramfs ram "${mountpoint}"
+ mkdir -p "${dest}"
+
+ for webfile in HTTPFS FTPFS FETCH
+ do
+ url="$(eval echo \"\$\{${webfile}\}\")"
+ extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
+
+ if [ -n "$url" ]
+ then
+ case "${extension}" in
+ squashfs|tgz|tar)
+ if [ "${webfile}" = "FETCH" ]
+ then
+ case "$url" in
+ tftp*)
+ ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
+ rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
+ lfile="$(basename $url)"
+ log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
+ tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
+ ;;
+
+ *)
+ log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
+ wget "${url}" -O "${dest}/$(basename ${url})"
+ ;;
+ esac
+ else
+ log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
+ if [ "${webfile}" = "FTPFS" ]
+ then
+ FUSE_MOUNT="curlftpfs"
+ url="$(dirname ${url})"
+ else
+ FUSE_MOUNT="httpfs"
+ fi
+ modprobe fuse
+ $FUSE_MOUNT "${url}" "${dest}"
+ fi
+ [ ${?} -eq 0 ] && rc=0
+ [ "${extension}" = "tgz" ] && live_dest="ram"
+ break
+ ;;
+
+ *)
+ log_begin_msg "Unrecognized archive extension for ${url}"
+ ;;
+ esac
+ fi
+ done
+
+ if [ ${rc} != 0 ]
+ then
+ umount "${mountpoint}"
+ fi
+
+ return ${rc}
+}
+
+do_nfsmount ()
+{
+ rc=1
+
+ modprobe -q nfs
+
+ if [ -z "${NFSOPTS}" ]
+ then
+ NFSOPTS=""
+ fi
+
+ log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
+
+ # FIXME: This while loop is an ugly HACK round an nfs bug
+ i=0
+ while [ "$i" -lt 60 ]
+ do
+ nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
+ sleep 1
+ i="$(($i + 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
+
+ log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
+ modprobe -q 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=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
+ freespace=$(df -k | awk '/'${todev}'/{print $4}')
+ else
+ freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
+ fi
+
+ tomount="/mnt/tmpsnap"
+
+ if [ ! -d "${tomount}" ]
+ then
+ mkdir -p "${tomount}"
+ fi
+
+ fstype=$(get_fstype "${fromdev}")
+
+ if [ -n "${fstype}" ]
+ then
+ # Copying stuff...
+ mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in 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
+
+ log_warning_msg "Unable to find the snapshot ${snap_type} medium"
+ fi
+}
+
+find_snap ()
+{
+ # Look for ${snap_label}.* in block devices
+ snap_label="${1}"
+
+ if [ "${PERSISTENT}" != "nofiles" ]
+ then
+ # search for image files
+ snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.ext4 ${snap_label}.jffs2")
+ fi
+
+ if [ -z "${snapdata}" ]
+ then
+ snapdata=$(find_cow_device "${snap_label}")
+ fi
+ echo "${snapdata}"
+}
+
+try_snap ()
+{
+ # copy the contents of previously found snapshot to ${snap_mount}
+ # and remember the device and filename for resync on exit in live-initramfs.init
+
+ snapdata="${1}"
+ snap_mount="${2}"
+ snap_type="${3}"
+
+ if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
+ then
+ log_success_msg "found snapshot: ${snapdata}"
+ snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
+ snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
+ snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
+
+ RES=""
+ if ! try_mount "${snapdev}" "${snapback}" "ro"
+ then
+ break
+ fi
+
+ if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
+ then
+ # squashfs, jffs2 or ext2/ext3/ext4 snapshot
+ dev=$(get_backing_device "${snapback}/${snapfile}")
+
+ do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
+ RES=$?
+ else
+ # cpio.gz snapshot
+ cd "${snap_mount}"
+ zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
+ RES=$?
+ if [ "${RES}" != "0" ]
+ then
+ log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
+ fi
+ cd "${OLDPWD}"
+ fi
+
+ umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
+
+ if [ "${RES}" != "0" ]
+ then
+ log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
+ fi
+
+ elif [ -b "${snapdata}" ]
+ then
+ # Try to find if it could be a snapshot partition
+ dev="${snapdata}"
+ log_success_msg "found snapshot ${snap_type} device on ${dev}"
+ if echo "${dev}" | grep -qs loop
+ then
+ # strange things happens, user confused?
+ snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
+ snapfile=$(basename ${snaploop})
+ snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
+ else
+ snapdev="${dev}"
+ fi
+
+ if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
+ then
+ log_warning_msg "Impossible to include the ${snap_type} 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_type} Snapshot"
+ return 1
+ 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}"
+ addimage_directory="${3}"
+ modprobe -q -b ${UNIONTYPE}
+
+ # 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=""
+ minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
+
+ if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
+ then
+ # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
+ roopt="nfsro"
+ elif [ "${UNIONTYPE}" = "aufs" ]
+ then
+ roopt="rr"
+ else
+ roopt="ro"
+ fi
+
+ if [ -z "${PLAIN_ROOT}" ]
+ then
+ # Read image names from ${MODULE}.module if it exists
+ if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
+ then
+ for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
+ do
+ image_string="${image_string} ${image_directory}/${IMAGE}"
+ done
+ elif [ -e "${image_directory}/${MODULE}.module" ]
+ then
+ for IMAGE in $(cat ${image_directory}/${MODULE}.module)
+ do
+ image_string="${image_string} ${image_directory}/${IMAGE}"
+ done
+ else
+ # ${MODULE}.module does not exist, create a list of images
+ for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
+ do
+ for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
+ do
+ if [ -e "${IMAGE}" ]
+ then
+ image_string="${image_string} ${IMAGE}"
+ fi
+ done
+ done
+
+ if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
+ then
+ for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
+ do
+ for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
+ do
+ if [ -e "${IMAGE}" ]
+ then
+ image_string="${image_string} ${IMAGE}"
+ fi
+ done
+ done
+ fi
+
+ # Now sort the list
+ image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
+ fi
+
+ [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
+
+ mkdir -p "${croot}"
+
+ for image in ${image_string}
+ do
+ imagename=$(basename "${image}")
+
+ export image devname
+ maybe_break live-realpremount
+ log_begin_msg "Running /scripts/live-realpremount"
+ run_scripts /scripts/live-realpremount
+ log_end_msg
+
+ if [ -d "${image}" ]
+ then
+ # it is a plain directory: do nothing
+ rofsstring="${image}=${roopt}:${rofsstring}"
+ rofslist="${image} ${rofslist}"
+ elif [ -f "${image}" ]
+ then
+ if losetup --help 2>&1 | grep -q -- "-r\b"
+ then
+ backdev=$(get_backing_device "${image}" "-r")
+ else
+ backdev=$(get_backing_device "${image}")
+ fi
+ fstype=$(get_fstype "${backdev}")
+
+ if [ "${fstype}" = "unknown" ]
+ then
+ panic "Unknown file system type on ${backdev} (${image})"
+ fi
+
+ if [ -z "${fstype}" ]
+ then
+ fstype="${imagename##*.}"
+ log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
+ fi
+
+ mkdir -p "${croot}/${imagename}"
+ log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
+ mount -t "${fstype}" -o ro,noatime "${backdev}" "${croot}/${imagename}" || panic "Can not mount ${backdev} (${image}) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}"
+ log_end_msg
+ fi
+ done
+ else
+ # we have a plain root system
+ mkdir -p "${croot}/filesystem"
+ log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
+ mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || panic "Can not mount ${image_directory} on ${croot}/filesystem" && rofsstring="${croot}/filesystem=${roopt}:${rofsstring}" && rofslist="${croot}/filesystem ${rofslist}"
+ # probably broken:
+ mount -o bind ${croot}/filesystem $mountpoint
+ log_end_msg
+ fi
+
+ rofsstring=${rofsstring%:}
+
+ mkdir -p /cow
+
+ # Looking for "${root_persistence}" device or file
+ if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
+ then
+ if [ -z "${QUICKUSBMODULES}" ]
+ then
+ # Load USB modules
+ num_block=$(wordCount "ls /sys/block")
+
+ for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
+ do
+ modprobe -q -b ${module}
+ done
+
+ if [ -x /sbin/udevadm ]
+ then
+ # lenny
+ udevadm trigger
+ udevadm settle
+ else
+ # etch
+ udevtrigger
+ udevsettle
+ fi
+
+ # For some reason, udevsettle does not block in this scenario,
+ # so we sleep for a little while.
+ #
+ # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
+ for timeout in 5 4 3 2 1
+ do
+ sleep 1
+
+ num_curr_block=$(wordCount "ls /sys/block")
+
+ if [ ${num_curr_block} -gt ${num_block} ]
+ then
+ break
+ fi
+ done
+ fi
+
+ # search for label and files (this could be hugely optimized)
+ cowprobe=$(find_cow_device "${root_persistence}")
+ if [ -b "${cowprobe}" ]
+ then
+ # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
+ # makes sense to have both persistence for /cow and /home mounted, maybe also with
+ # snapshots to be sure to really store some e.g key config files,
+ # but not on the same media
+ blacklistdev="${cowprobe}"
+ PERSISTENCE_IS_ON="1"
+ export PERSISTENCE_IS_ON
+ fi
+ # homecow just mount something on /home, this should be generalized some way
+ homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
+ if [ -b "${homecow}" ]
+ then
+ PERSISTENCE_IS_ON="1"
+ export PERSISTENCE_IS_ON
+ fi
+ root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
+ # This second type should be removed when snapshot will get smarter,
+ # hence when "/etc/live-snapshot*list" will be supported also by
+ # ext2|ext3|ext4|jffs2 snapshot types.
+ home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
+
+ if [ -b "${cowprobe}" ]
+ then
+ cowdevice=${cowprobe}
+ cow_fstype=$(get_fstype "${cowprobe}")
+ cow_mountopt="rw,noatime"
+ else
+ log_warning_msg "Unable to find the persistent medium"
+ cowdevice="tmpfs"
+ cow_fstype="tmpfs"
+ cow_mountopt="rw,noatime,mode=755"
+ fi
+ elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
+ then
+ # check if there are any nfs options
+ if echo ${NFS_COW}|grep -q ','
+ then
+ nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
+ nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
+ else
+ nfs_cow_opts="-o nolock"
+ nfs_cow=${NFS_COW}
+ fi
+ mac="$(get_mac)"
+ if [ -n "${mac}" ]
+ then
+ cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
+ cow_fstype="nfs"
+ else
+ panic "unable to determine mac address"
+ fi
+ else
+ cowdevice="tmpfs"
+ cow_fstype="tmpfs"
+ cow_mountopt="rw,noatime,mode=755"
+ fi
+
+ if [ "${cow_fstype}" = "nfs" ]
+ then
+ log_begin_msg \
+ "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
+ nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
+ panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
+ else
+ mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
+ panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
+ fi
+
+ rofscount=$(wordCount "echo ${rofslist}")
+
+ if [ -n "${EXPOSED_ROOT}" ]
+ then
+ if [ ${rofscount} -ne 1 ]
+ then
+ panic "only one RO file system supported with exposedroot: ${rofslist}"
+ fi
+ exposedrootfs=${rofslist%% }
+
+ mount --bind ${exposedrootfs} ${rootmnt} || \
+ panic "bind mount of ${exposedrootfs} failed"
+
+ if [ -z "${SKIP_UNION_MOUNTS}" ]
+ then
+ cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
+ else
+ cow_dirs=''
+ fi
+
+ for dir in ${cow_dirs}; do
+ mkdir -p /cow${dir}
+ mount -t ${UNIONTYPE} \
+ -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
+ ${UNIONTYPE} "${rootmnt}${dir}" || \
+ panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
+ rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
+ done
+ else
+ mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
+ ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
+ ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
+ fi
+
+ # Correct the permissions of /:
+ chmod 0755 "${rootmnt}"
+
+ # tmpfs file systems
+ touch /etc/fstab
+ mkdir -p "${rootmnt}/live"
+ mount -t tmpfs tmpfs ${rootmnt}/live
+
+ # Adding other custom mounts
+ if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
+ then
+ # directly mount /home
+ # FIXME: add a custom mounts configurable system
+
+ if [ -b "${homecow}" ]
+ then
+ mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
+ export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
+ else
+ log_warning_msg "Unable to find the persistent home medium"
+ fi
+
+ # Look for other snapshots to copy in
+ try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
+ # This second type should be removed when snapshot grow smarter
+ try_snap "${home_snapdata}" "${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
+ fi
+
+ # shows cow fs on /cow for use by live-snapshot
+ mkdir -p "${rootmnt}/live/cow"
+ mount -o move /cow "${rootmnt}/live/cow" >/dev/null 2>&1 || mount -o bind /cow "${rootmnt}/live/cow" || log_warning_msg "Unable to move or bind /cow to ${rootmnt}/live/cow"
+}
+
+check_dev ()
+{
+ sysdev="${1}"
+ devname="${2}"
+ skip_uuid_check="${3}"
+
+ if [ -z "${devname}" ]
+ then
+ devname=$(sys2dev "${sysdev}")
+ fi
+
+ if [ -d "${devname}" ]
+ then
+ mount -o bind "${devname}" $mountpoint || continue
+
+ if is_live_path $mountpoint
+ then
+ echo $mountpoint
+ return 0
+ else
+ umount $mountpoint
+ fi
+ fi
+
+ if [ -n "${LIVE_MEDIA_OFFSET}" ]
+ then
+ loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
+ devname="${loopdevname}"
+ fi
+
+ fstype=$(get_fstype "${devname}")
+
+ if is_supported_fs ${fstype}
+ then
+ mountOpt="rw,noatime"
+ test "$fstype" = "vfat" && mountOpt="$mountOpt,umask=000"
+ mount -t ${fstype} -o ${mountOpt} "${devname}" ${mountpoint} || continue
+
+ if is_live_path ${mountpoint} && \
+ ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
+ then
+ echo ${mountpoint}
+ return 0
+ else
+ umount ${mountpoint}
+ fi
+ fi
+
+ if [ -n "${LIVE_MEDIA_OFFSET}" ]
+ then
+ losetup -d "${loopdevname}"
+ fi
+
+ return 1
+}
+
+find_livefs ()
+{
+ timeout="${1}"
+
+ # don't start autodetection before timeout has expired
+ if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
+ then
+ if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
+ then
+ return 1
+ fi
+ fi
+
+ # first look at the one specified in the command line
+ case "${LIVE_MEDIA}" in
+ removable-usb)
+ for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+ do
+ if [ "$(cat ${sysblock}/removable)" = "1" ]
+ then
+ if readlink ${sysblock} | grep -q usb ||
+ readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
+ then
+ for dev in $(subdevices "${sysblock}")
+ do
+ if check_dev "${dev}"
+ then
+ return 0
+ fi
+ done
+ fi
+ fi
+ done
+ ;;
+
+ removable)
+ for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+ do
+ if [ "$(cat ${sysblock}/removable)" = "1" ]
+ then
+ for dev in $(subdevices "${sysblock}")
+ do
+ if check_dev "${dev}"
+ then
+ return 0
+ fi
+ done
+ fi
+ done
+ ;;
+
+ *)
+ if [ ! -z "${LIVE_MEDIA}" ]
+ then
+ if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
+ then
+ return 0
+ fi
+ fi
+ ;;
+ esac
+
+ # or do the scan of block devices
+ for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
+ do
+ devname=$(sys2dev "${sysblock}")
+ fstype=$(get_fstype "${devname}")
+
+ cdrom="1"
+ if [ -x /lib/udev/cdrom_id ]
+ then
+ /lib/udev/cdrom_id ${devname} > /dev/null
+ cdrom=$?
+ fi
+
+ if [ "$cdrom" -eq "0" ]
+ 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}" = "ext2" -o \
+ "${fstype}" = "ext3" -o \
+ "${fstype}" = "ext4" -o \
+ "${fstype}" = "jffs2" ]
+ then
+ # This is an ugly hack situation, the block device has
+ # an image directly on it. It's hopefully
+ # live-initramfs, so take it and run with it.
+ ln -s "${devname}" "${devname}.${fstype}"
+ echo "${devname}.${fstype}"
+ return 0
+ fi
+ done
+
+ return 1
+}
+
+set_usplash_timeout ()
+{
+ if [ -x /sbin/usplash_write ]
+ then
+ /sbin/usplash_write "TIMEOUT 120"
+ else if [ -x /sbin/splashy_update ] ; then
+ /sbin/splashy_update "TIMEOUT 120"
+ fi ; fi
+}
+
+integrity_check ()
+{
+ media_mountpoint="${1}"
+
+ log_begin_msg "Checking media integrity"
+
+ cd ${media_mountpoint}
+ /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
+ RC="${?}"
+
+ log_end_msg
+
+ if [ "${RC}" -eq 0 ]
+ then
+ log_success_msg "Everything ok, will reboot in 10 seconds."
+ sleep 10
+ cd /
+ umount ${media_mountpoint}
+ sync
+ echo u > /proc/sysrq-trigger
+ echo b > /proc/sysrq-trigger
+ else
+ panic "Not ok, a media defect is likely, switch to VT8 for details."
+ fi
+}
+
+mountroot ()
+{
+ if [ -x /scripts/local-top/cryptroot ]; then
+ /scripts/local-top/cryptroot
+ fi
+
+ exec 6>&1
+ exec 7>&2
+ exec > live.log
+ exec 2>&1
+ tail -f live.log >&7 &
+ tailpid="${!}"
+
+ # Ensure 'panic' function is overridden
+ . /scripts/live-functions
+
+ Arguments
+
+ set_usplash_timeout
+
+ maybe_break live-premount
+ log_begin_msg "Running /scripts/live-premount"
+ run_scripts /scripts/live-premount
+ log_end_msg
+
+ # Needed here too because some things (*cough* udev *cough*)
+ # changes the timeout
+
+ set_usplash_timeout
+
+ if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
+ then
+ if do_netmount
+ then
+ livefs_root="${mountpoint}"
+ else
+ panic "Unable to find a live file system on the network"
+ fi
+ else
+ if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
+ then
+ # Do a local boot from hd
+ livefs_root=${ROOT}
+ else
+ # Scan local devices for the image
+ i=0
+ while [ "$i" -lt 60 ]
+ do
+ livefs_root=$(find_livefs ${i})
+
+ if [ -n "${livefs_root}" ]
+ then
+ break
+ fi
+
+ sleep 1
+ i="$(($i + 1))"
+ done
+ fi
+ fi
+
+ if [ -z "${livefs_root}" ]
+ then
+ panic "Unable to find a medium containing a live file system"
+ fi
+
+ if [ "${INTEGRITY_CHECK}" ]
+ then
+ integrity_check "${livefs_root}"
+ 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
+
+ if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
+ then
+ setup_unionfs "${livefs_root}" "${rootmnt}"
+ else
+ mac="$(get_mac)"
+ mac="$(echo ${mac} | sed 's/-//g')"
+ mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
+ fi
+
+ log_end_msg
+
+ maybe_break live-bottom
+ log_begin_msg "Running /scripts/live-bottom\n"
+
+ run_scripts /scripts/live-bottom
+ log_end_msg
+
+ exec 1>&6 6>&-
+ exec 2>&7 7>&-
+ kill ${tailpid}
+ [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null
+}
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/02etc_live_conf b/tools/XBMCLive/live-initramfs/scripts/live-bottom/02etc_live_conf
new file mode 100755
index 0000000000..815e37971a
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/02etc_live_conf
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /scripts/live-functions
+
+log_begin_msg "Copying config on real root fs"
+
+# live-initramfs script
+
+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 > /root/etc/live.conf << EOF
+export USERNAME="${USERNAME}"
+export USERFULLNAME="${USERFULLNAME}"
+export HOSTNAME="${HOSTNAME}"
+EOF
+
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/02timezone b/tools/XBMCLive/live-initramfs/scripts/live-bottom/02timezone
new file mode 100755
index 0000000000..64faf3b8de
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/02timezone
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOTIMEZONE}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Setting timezone"
+
+# live-initramfs script
+
+if [ -n "${TIMEZONE}" ]
+then
+ area="$(echo ${TIMEZONE} | cut -f1 -d '/')"
+ zone="$(echo ${TIMEZONE} | cut -f2 -d '/')"
+
+chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
+set tzdata/Areas ${area}
+set tzdata/Zones/${area} ${zone}
+EOF
+
+ cp -f /root/usr/share/zoneinfo/${area}/${zone} /root/etc/localtime
+else
+
+chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
+set tzdata/Areas Etc
+set tzdata/Zones/Etc UTC
+EOF
+
+ cp -f /root/usr/share/zoneinfo/UTC /root/etc/localtime
+fi
+
+if [ -n "${UTC}" ]
+then
+ sed -i -e "s/UTC=.*/UTC=${UTC}/" /root/etc/default/rcS
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/05mountpoints b/tools/XBMCLive/live-initramfs/scripts/live-bottom/05mountpoints
new file mode 100755
index 0000000000..ce151e19e8
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/05mountpoints
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /scripts/live-functions
+
+log_begin_msg "Moving mount points"
+
+# live-initramfs script
+
+# Move to the new root filesystem so that programs there can get at it.
+if [ ! -d /root/live/image ]
+then
+ mkdir -p /root/live/image
+ mount --move /live/image /root/live/image
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/06hostname b/tools/XBMCLive/live-initramfs/scripts/live-bottom/06hostname
new file mode 100755
index 0000000000..b14703a98c
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/06hostname
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOHOSTS}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Setting hostname"
+
+# live-initramfs script
+
+# Change hostname only if it is not set
+if [ ! -f /root/etc/hostname ] || grep -qs localhost\.localdomain /root/etc/hostname
+then
+ echo "${HOSTNAME}" > /root/etc/hostname
+else
+ HOSTNAME="$(cat /root/etc/hostname)"
+ really_export HOSTNAME
+fi
+
+# Create /etc/hosts only if it is not present or empty
+if [ ! -s /root/etc/hosts ]
+then
+ cat > /root/etc/hosts << EOF
+127.0.0.1 localhost
+127.0.1.1 ${HOSTNAME}
+
+# The following lines are desirable for IPv6 capable hosts
+::1 ip6-localhost ip6-loopback
+fe00::0 ip6-localnet
+ff00::0 ip6-mcastprefix
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
+ff02::3 ip6-allhosts
+EOF
+fi
+
+hostname "${HOSTNAME}"
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/08persistence_excludes b/tools/XBMCLive/live-initramfs/scripts/live-bottom/08persistence_excludes
new file mode 100755
index 0000000000..b7aac9226e
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/08persistence_excludes
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+# Persistence enhancer script
+# This script saves precious time on slow persistence devices/image files
+# and writes on flash based device.
+# a tmpfs on $PERSTMP is mounted and directories listed in
+# /etc/live-persistence.binds will be copied there and then bind mounted back.
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -z "${PERSISTENT}" ] || [ -n "${NOPERSISTENT}" ] || [ -z "${PERSISTENCE_IS_ON}" ] || [ ! -f /root/etc/live-persistence.binds ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+# live-initramfs script
+
+dirs="$(sed -e '/^ *$/d' -e '/^#.*$/d' /root/etc/live-persistence.binds | tr '\n' '\0')"
+if [ -z "${dirs}" ]
+then
+ exit 0
+fi
+
+log_begin_msg "Moving persistence bind mounts"
+
+PERSTMP="/root/live/persistence-binds"
+CPIO="/bin/cpio"
+
+if [ ! -d "${PERSTMP}" ]
+then
+ mkdir -p "${PERSTMP}"
+fi
+
+mount -t tmpfs tmpfs "${PERSTMP}"
+
+for dir in $(echo "${dirs}" | tr '\0' '\n')
+do
+ if [ ! -e "/root/${dir}" ] && [ ! -L "/root/${dir}" ]
+ then
+ # directory do not exists, create it
+ mkdir -p "/root/${dir}"
+ elif [ ! -d "/root/${dir}" ]
+ then
+ # it is not a directory, skip it
+ break
+ fi
+
+ # Copy previous content if any
+ cd "/root/${dir}"
+ find . -print0 | ${CPIO} -pumd0 "${PERSTMP}/${dir}"
+ cd "${OLDPWD}"
+
+ # Bind mount it to origin
+ mount -o bind "${PERSTMP}/${dir}" "/root/${dir}"
+done
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/10adduser b/tools/XBMCLive/live-initramfs/scripts/live-bottom/10adduser
new file mode 100755
index 0000000000..92950707e7
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/10adduser
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOUSER}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Adding live session user"
+
+# live-initramfs script
+
+user_crypted="8Ab05sVQ4LLps" # as in $(echo "live" | mkpasswd -s)
+
+# U6aMy0wojraho is just a blank password
+chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
+set passwd/make-user true
+set passwd/root-password-crypted *
+set passwd/user-password-crypted ${user_crypted}
+set passwd/user-fullname ${USERFULLNAME}
+set passwd/username ${USERNAME}
+set passwd/user-uid 1000
+EOF
+
+chroot /root /usr/bin/env -i HOME="/root" \
+ TERM="${TERM}" PATH="/usr/sbin:/usr/bin:/sbin:/bin" \
+ /usr/lib/user-setup/user-setup-apply 2>&1 \
+ | grep -v "Shadow passwords are now on"
+
+# Clear out debconf database again to avoid confusing ubiquity later.
+chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
+set passwd/make-user
+set passwd/root-password-crypted
+set passwd/user-password-crypted
+set passwd/user-fullname
+set passwd/username
+set passwd/user-uid
+EOF
+
+if ! grep -qs "${USERNAME}" /root/etc/passwd
+then
+ echo "The default user (${USERNAME}) is not present,"
+ first_user=$(grep '^[^:]*:[^:]*:[12]\?[0-9][0-9][0-9][0-9]:' /root/etc/passwd | head -1 | cut -f1 -d ':')
+ if [ -n "${first_user}" ];
+ then
+ echo "setting default user to: ${first_user}."
+ USERNAME="${first_user}"
+ really_export USERNAME
+ else
+ echo "no other valid users found, disabling autologin."
+ NOAUTOLOGIN="Yes"
+ NOXAUTOLOGIN="Yes"
+ USERNAME=""
+ really_export NOAUTOLOGIN
+ really_export NOXAUTOLOGIN
+ really_export USERNAME
+ log_end_msg
+ exit 0
+ fi
+fi
+
+if [ -z "${NOSUDO}" ]
+then
+ if ! grep -q "${USERNAME}" /root/etc/sudoers
+ then
+ 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"
+
+ if [ -x /root/usr/bin/gconftool-2 ]
+ then
+ 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
+ fi
+
+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
+
+ 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
+fi
+
+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/tools/XBMCLive/live-initramfs/scripts/live-bottom/12fstab b/tools/XBMCLive/live-initramfs/scripts/live-bottom/12fstab
new file mode 100755
index 0000000000..701ed1edeb
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/12fstab
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+FSTAB=/root/etc/fstab
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /scripts/live-functions
+
+if [ -n "${NOFSTAB}" ]
+then
+ exit 0
+fi
+
+log_begin_msg "Configuring fstab"
+
+# live-initramfs script
+
+# Create a fake fstab only if it doesn't exist or if its the debootstrap template
+if [ ! -f "${FSTAB}" ] || grep -qs 'UNCONFIGURED FSTAB FOR BASE SYSTEM' "${FSTAB}"
+then
+
+cat > ${FSTAB} << EOF
+# /etc/fstab: static file system information.
+#
+# <file system> <mount point> <type> <options> <dump> <pass>
+
+EOF
+
+fi
+
+if ! grep -qs "^${UNIONTYPE}" "${FSTAB}"
+then
+ echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> "${FSTAB}"
+fi
+
+if ! grep -qs "^tmpfs /tmp" "${FSTAB}"
+then
+ echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> "${FSTAB}"
+fi
+
+if [ -z "${NOSWAP}" ]
+then
+ devices=""
+
+ for device in /dev/[hs]d[a-z][0-9]*
+ do
+ if ! [ -b "${device}" ]
+ then
+ continue
+ fi
+
+ /lib/udev/blkid ${device%%[0-9]*} 2>/dev/null | grep -q "^ID_FS_USAGE=raid" && continue
+
+ 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}"
+ fi
+ done
+
+ # Remove all auto swap entries
+ if grep -qs "swap swap" "${FSTAB}"
+ then
+ grep -v "swap swap" "${FSTAB}" > "${FSTAB}".tmp
+ mv "${FSTAB}".tmp "${FSTAB}"
+ fi
+
+ # Add new swap entries
+ for device in ${devices}
+ do
+ echo "${device} swap swap defaults 0 0" >> "${FSTAB}"
+ done
+fi
+
+# disabled for now
+#rm -f /root/etc/rcS.d/S*checkroot.sh
+
+if [ "${NOFASTBOOT}" != "Yes" ]
+then
+ touch root/fastboot
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/14locales b/tools/XBMCLive/live-initramfs/scripts/live-bottom/14locales
new file mode 100755
index 0000000000..022a605626
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/14locales
@@ -0,0 +1,131 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOLOCALES}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Setting up locales"
+
+# Cosmetic line wrapping for output of local-gen
+echo
+
+# live-initramfs script
+
+if [ -e /root/etc/default/locale ]
+then
+ grep_file=/root/etc/default/locale
+elif [ -e /root/etc/environment ]
+then
+ # Old locales policy
+ grep_file=/root/etc/environment
+fi
+
+if [ -n "${grep_file}" ]
+then
+ # use rootfs configured locale
+ locale=$(grep -s 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' )
+fi
+
+if [ -n "${LOCALE}" ]
+then
+ locale="${LOCALE}"
+ set_locale="true"
+fi
+
+if [ -z "${locale}" ]
+then
+ # Set a default one
+ locale=en_US.UTF-8
+ set_locale="true"
+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=
+ language="$(echo ${locale} | cut -d. -f1)"
+ eval $(awk '/^'"${locale}"'/ { print "LANG=" $1 " codepage=" $2; exit; }' /root/usr/share/i18n/SUPPORTED)
+
+ if [ -z "${LANG}" ]
+ then
+ # Try and fallback to another codepage for this language.
+ eval $(awk '/^'"${language}"'/ { print "LANG=" $1 " codepage=" $2; exit; }' /root/usr/share/i18n/SUPPORTED)
+
+ if [ -n "${LANG}" ]
+ then
+ log_warning_msg "Choosing locale '${LANG}' as '${locale}' is unsupported."
+ fi
+ fi
+
+ if [ -z "${LANG}" ]
+ then
+ log_warning_msg "Locale '${locale}' is unsupported."
+ codepage="UTF-8"
+ language="en_US"
+ locale="${language}.${codepage}"
+ LANG="${language}.${codepage}"
+ fi
+
+ if [ -d /root/etc/default/kdm.d/ ]
+ then
+ if ! grep -qs "^LANGUAGE" "${LANG}"
+ then
+ printf 'LANGUAGE=%s\n' "${LANG}" >> /root/etc/default/kdm.d/live-autologin
+ fi
+ elif [ -f /root/etc/kde3/kdm/kdmrc ]
+ then
+ sed -i -r -e "s/#Language=.*/Language=${language}/" \
+ /root/etc/kde3/kdm/kdmrc
+ fi
+
+ really_export LANG
+
+ printf 'LANG="%s"\n' "${LANG}" > /root/etc/default/locale
+ printf 'LANG="%s"\n' "${LANG}" > /root/etc/environment
+ printf '%s %s\n' "${LANG}" "${codepage}" > /root/etc/locale.gen
+
+ if [ -z "${SILENT}" ]
+ then
+ chroot /root /usr/sbin/locale-gen
+ else
+ chroot /root /usr/sbin/locale-gen > /dev/null 2>&1
+ fi
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/15autologin b/tools/XBMCLive/live-initramfs/scripts/live-bottom/15autologin
new file mode 100755
index 0000000000..38c3a8f32d
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/15autologin
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /live.vars
+
+if [ -n "${NOXAUTOLOGIN}" ] || [ -z "${USERNAME}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Setting up automatic login"
+
+# live-initramfs script
+
+# chroot needed to handle symlinks correctly
+if chroot /root [ -f /etc/gdm/gdm-cdd.conf ]
+then
+ GDMCONF=/etc/gdm/gdm-cdd.conf
+else
+ GDMCONF=/etc/gdm/gdm.conf
+fi
+
+# chroot needed to handle symlinks correctly
+if chroot /root [ -f ${GDMCONF} ]
+then
+ # true hack ! -- nohar
+ chroot /root cp /usr/share/gdm/defaults.conf /etc/gdm/gdm.conf
+
+ # 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 [ -d /root/etc/default/kdm.d/ ]
+then
+ if ! grep -qs "^AUTOLOGIN" /root/etc/default/kdm.d/live-autologin
+ then
+
+cat >> /root/etc/default/kdm.d/live-autologin << EOF
+AUTOLOGINUSER=${USERNAME}
+AUTOLOGINAGAIN=true
+AUTOLOGINDELAY=0
+EOF
+
+ fi
+
+elif [ -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
+elif [ -f /root/etc/kde4/kdm/kdmrc ]
+then
+ # Configure KDM-KDE4 autologin
+ sed -i -r -e "s/^#?AutoLoginEnable=.*\$/AutoLoginEnable=true/" \
+ -e "s/^#?AutoLoginUser=.*\$/AutoLoginUser=$USERNAME/" \
+ -e "s/^#?AutoReLogin=.*\$/AutoReLogin=true/" \
+ /root/etc/kde4/kdm/kdmrc
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/16umountfs b/tools/XBMCLive/live-initramfs/scripts/live-bottom/16umountfs
new file mode 100755
index 0000000000..64ad99da0a
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/16umountfs
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /live.vars
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling umountfs for live specific filesystems"
+
+# live-initramfs script
+
+if [ -e /root/etc/init.d/umountfs ]
+then
+ sed -i -e 's#pioodl $TMPFS_MTPTS)#pioodl $TMPFS_MTPTS | sed -e "s@\\ @\\n@" | grep -v ^/live)#' \
+ -e 's#pioodl $REG_MTPTS)#pioodl $REG_MTPTS | sed -e "s@\\ @\\n@" | grep -v ^/live | grep -v ^/filesystem) /#' \
+ /root/etc/init.d/umountfs
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/19keyboard b/tools/XBMCLive/live-initramfs/scripts/live-bottom/19keyboard
new file mode 100755
index 0000000000..d465698da8
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/19keyboard
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOCONSOLEKEYBOARD}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Setting up console keyboard"
+
+# live-initramfs script
+
+kbd=
+cslayout=
+csvariant=
+csmodel=
+
+# 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
+ chroot /root sed -i "s/^XKBLAYOUT=.*/XKBLAYOUT=\"${cslayout}\"/" \
+ /etc/default/console-setup
+
+ if [ "${csvariant}" ]
+ then
+ chroot /root sed -i "s/^XKBVARIANT=.*/XKBVARIANT=\"${csvariant}\"/" \
+ /etc/default/console-setup
+ else
+ live-preseed /root console-setup/variantcode '' false
+ fi
+
+ if [ "${csmodel}" ]
+ then
+ chroot /root sed -i "s/^XKBMODEL=.*/XKBMODEL=\"${csmodel}\"/" \
+ /etc/default/console-setup
+ else
+ live-preseed /root console-setup/modelcode '' false
+ fi
+ else
+ live-preseed /root console-setup/layoutcode '' false
+ live-preseed /root console-setup/variantcode '' false
+ live-preseed /root console-setup/modelcode '' false
+ fi
+
+ live-preseed /root console-setup/optionscode '' false
+ live-preseed /root console-setup/codesetcode '' false
+
+ sed -i 's/CONSOLE_SCREEN=$/CONSOLE_SCREEN=setupcon/; t END; b; : END; n; b END' /root/etc/init.d/usplash
+elif [ -e /root/usr/sbin/install-keymap ]
+then
+ 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/tools/XBMCLive/live-initramfs/scripts/live-bottom/20xconfig b/tools/XBMCLive/live-initramfs/scripts/live-bottom/20xconfig
new file mode 100755
index 0000000000..f6a3f8d58c
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/20xconfig
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOXAUTOCONFIG}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+# live-initramfs script
+
+if [ "${TERM_TYPE}" = "serial" ]
+then
+ # Don't bother trying to configure or start X on a serial console
+ rm -f /root/etc/rc?.d/S??[gkx]dm
+ exit 0
+fi
+
+if [ -n "${TEXTONLY}" ]
+then
+ exit 0
+fi
+
+if [ ! -x /root/usr/bin/X ]
+then
+ exit 0
+fi
+
+log_begin_msg "Configuring X"
+
+locale=en_US.UTF-8
+
+mount -o bind /sys /root/sys
+mount -o bind /proc /root/proc
+mount -o bind /dev /root/dev
+
+if [ -n "${XDEBCONF}" -a -x /root/usr/sbin/xdebconfigurator ]
+then
+ # xdebconfigurator
+ chroot /root /usr/sbin/xdebconfigurator
+fi
+
+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
+
+live-reconfigure /root xserver-xorg 2>&1 \
+ | grep -v "overwriting possibly-customised configuration" \
+ | grep -v "file; backup in /etc/X11/xorg.conf"
+umount /root/sys
+umount /root/proc
+umount /root/dev
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/21xdriver b/tools/XBMCLive/live-initramfs/scripts/live-bottom/21xdriver
new file mode 100755
index 0000000000..105f5b24d3
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/21xdriver
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOXAUTOCONFIG}" ] || [ ! -x /root/usr/bin/X ] || [ -z "${XDRIVER}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Configuring X video driver"
+
+# live-initramfs script
+
+. /live.vars
+
+mount -o bind /sys /root/sys
+mount -o bind /proc /root/proc
+mount -o bind /dev /root/dev
+
+chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
+set xserver-xorg/autodetect_video_card false
+set xserver-xorg/config/device/driver ${XDRIVER}
+EOF
+
+chroot /root dexconf
+
+umount /root/sys
+umount /root/proc
+umount /root/dev
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/21xvidemode b/tools/XBMCLive/live-initramfs/scripts/live-bottom/21xvidemode
new file mode 100755
index 0000000000..489fc5c6ac
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/21xvidemode
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOXAUTOCONFIG}" ]
+then
+ exit 0
+fi
+
+if [ ! -x /root/usr/bin/X ]
+then
+ exit 0
+fi
+
+[ -n "$XVIDEOMODE" ] || exit
+
+. /scripts/live-functions
+
+log_begin_msg "Configuring X video modes"
+
+# live-initramfs script
+
+. /live.vars
+
+if [ $(cat /root/etc/debian_version | sed 's|\..*$||') -ge 4 ]
+then
+ # lenny or newer
+ if [ -x "$(which xrandr 2>/dev/null)" ]
+ then
+ echo "xrandr -s ${XVIDEOMODE} || /bin/true" >> /root/etc/X11/Xsession.d/21xvidemode
+ fi
+else
+ # etch
+ mount -o bind /sys /root/sys
+ mount -o bind /proc /root/proc
+ mount -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/tools/XBMCLive/live-initramfs/scripts/live-bottom/22gnome_panel_data b/tools/XBMCLive/live-initramfs/scripts/live-bottom/22gnome_panel_data
new file mode 100755
index 0000000000..bd0be26d9b
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/22gnome_panel_data
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOGNOMEPANEL}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Configuring gnome-panel-data"
+
+# live-initramfs script
+
+if [ -x /root/usr/sbin/laptop-detect ]
+then
+ if chroot /root laptop-detect
+ then
+ live-reconfigure /root gnome-panel-data
+ fi
+fi
+
+panel_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-panel-data 2>/dev/null) || panel_version=""
+
+if [ -n "${panel_version}" ] && [ -n "${USERNAME}" ]
+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/tools/XBMCLive/live-initramfs/scripts/live-bottom/22screensaver b/tools/XBMCLive/live-initramfs/scripts/live-bottom/22screensaver
new file mode 100755
index 0000000000..584d234c45
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/22screensaver
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOXSCREENSAVER}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Configuring screensaver"
+
+# live-initramfs script
+
+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/tools/XBMCLive/live-initramfs/scripts/live-bottom/23etc_modules b/tools/XBMCLive/live-initramfs/scripts/live-bottom/23etc_modules
new file mode 100755
index 0000000000..2240a1bab5
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/23etc_modules
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /scripts/live-functions
+
+log_begin_msg "Preconfiguring /etc/modules"
+
+# live-initramfs script
+
+# load the right modules
+case "${DPKG_ARCH}" in
+ powerpc|ppc64)
+ echo snd_powermac >> /root/etc/modules
+ ;;
+esac
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/23networking b/tools/XBMCLive/live-initramfs/scripts/live-bottom/23networking
new file mode 100755
index 0000000000..72aaf12e25
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/23networking
@@ -0,0 +1,157 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NONETWORKING}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Preconfiguring networking"
+
+# live-initramfs script
+
+IFFILE="/root/etc/network/interfaces"
+
+if [ "${STATICIP}" = "frommedia" -a -e "${IFFILE}" ]
+then
+ # will use existent /etc/network/interfaces
+ log_end_msg
+ exit 0
+fi
+
+cat > "${IFFILE}" << EOF
+auto lo
+iface lo inet loopback
+
+EOF
+
+if [ -x /sbin/udevadm ]
+then
+ # lenny
+ udevadm trigger
+ udevadm settle
+else
+ # etch
+ udevtrigger
+ udevsettle
+fi
+
+if [ -z "${NETBOOT}" -a -n "${STATICIP}" -a "${STATICIP}" != "frommedia" ]
+then
+ parsed=$(echo "${STATICIP}" | sed -e 's/:/ /g')
+
+ for ifline in ${parsed}
+ do
+ ifname="$(echo ${ifline} | cut -f1 -d ',')"
+ ifaddress="$(echo ${ifline} | cut -f2 -d ',')"
+ ifnetmask="$(echo ${ifline} | cut -f3 -d ',')"
+ ifgateway="$(echo ${ifline} | cut -f4 -d ',')"
+
+cat >> "${IFFILE}" << EOF
+auto ${ifname}
+iface ${ifname} inet static
+ address ${ifaddress}
+ netmask ${ifnetmask}
+ gateway ${ifgateway}
+
+EOF
+
+ done
+else
+ if [ -z "${NETBOOT}" ]
+ then
+ # default, dhcp assigned
+ method="dhcp"
+ else
+ # make sure that the preconfigured interface would not get reassigned by dhcp
+ # on startup by ifup script - otherwise our root fs might be disconnected!
+ method="manual"
+ fi
+
+ # iterate the physical interfaces and add them to the interfaces list
+ if [ "${method}" != dhcp ] || ([ ! -x /root/usr/sbin/NetworkManager ] && [ ! -x /root/usr/sbin/wicd ])
+ then
+ for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*
+ do
+ [ -e ${interface} ] || continue
+ i="$(basename ${interface})"
+
+cat >> "${IFFILE}" << EOF
+auto ${i}
+iface ${i} inet ${method}
+
+EOF
+
+ done
+ fi
+
+ if [ ! -f /root/etc/resolv.conf ] || [ -z "$(cat /root/etc/resolv.conf)" ]
+ then
+ if [ -f /netboot.config ]
+ then
+ # create a resolv.conf if it is not present or empty
+ cp /netboot.config /root/var/log/netboot.config
+
+ rc_search=$(cat netboot.config | awk '/domain/{print $3}')
+ rc_server0=$(cat netboot.config | awk '/dns0/{print $5}')
+ rc_server1=$(cat netboot.config | awk '/dns0/{print $8}')
+ rc_server0="nameserver ${rc_server0}"
+
+ if [ "${rc_server1}" = "0.0.0.0" ]
+ then
+ rc_server1=""
+ else
+ rc_server1="nameserver ${rc_server1}"
+ fi
+
+cat > /root/etc/resolv.conf << EOF
+# /etc/resolv.conf
+# Autogenerated by live-initramfs
+search ${rc_search}
+domain ${rc_search}
+${rc_server0}
+${rc_server1}
+EOF
+
+ cat /root/etc/resolv.conf >> /root/var/log/netboot.config
+ fi
+ fi
+fi
+
+#if [ ! -x /root/usr/sbin/NetworkManager ]
+#then
+# 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
+#fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/24preseed b/tools/XBMCLive/live-initramfs/scripts/live-bottom/24preseed
new file mode 100755
index 0000000000..2536bd0a34
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/24preseed
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOPRESEED}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Loading preseed file"
+
+# live-initramfs script
+
+if [ -e /preseed.cfg ]
+then
+ chroot /root debconf-set-selections < /preseed.cfg
+fi
+
+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
+
+reply="$(echo "GET preseed/early_command" | chroot /root debconf-communicate -fnoninteractive live-initramfs)"
+
+if [ "${reply#0 }" != "${reply}" ]
+then
+ reply="${reply#0 }"
+ sh -c "${reply}"
+fi
+
+# Clear out debconf database backup files to save memory.
+rm -f /root/var/cache/debconf/*.dat-old
+
+log_end_msg
+
+exit 0
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/25configure_init b/tools/XBMCLive/live-initramfs/scripts/live-bottom/25configure_init
new file mode 100755
index 0000000000..f55dd0e0c7
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/25configure_init
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /scripts/live-functions
+
+log_begin_msg "Setting up init"
+
+# live-initramfs script
+
+# Arrange for shells on virtual consoles, rather than login prompts
+
+if [ -z "${NOAUTOLOGIN}" ] && [ -n "${USERNAME}" ]
+then
+ 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 "/^respawn$/!s|^respawn.*|respawn /bin/login -f ${USERNAME} </dev/$(basename ${f}) > /dev/$(basename ${f}) 2>\&1|" ${f}
+ sed -i -e "s|^exec.*|exec /bin/login -f ${USERNAME} </dev/$(basename ${f}) > /dev/$(basename ${f}) 2>\&1|" ${f}
+ done
+ fi
+ fi
+
+ # Since we use autologin, lastlog doesn't make sense on the console.
+ sed -i '/^[^#].*pam_lastlog\.so/s/^/# /' /root/etc/pam.d/login
+fi
+
+# do not try to remove files if using file-rc
+if [ -d /root/etc/rc0.d ]
+then
+ # 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/usr/sbin/anacron ]
+ then
+ chroot /root dpkg-divert --add --rename --quiet /usr/sbin/anacron
+ ln -s /bin/true /root/usr/sbin/anacron
+ fi
+
+ # Avoid clobbering the user's clock
+ rm -f /root/etc/rc?.d/K??hwclock.sh
+fi
+
+# 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/tools/XBMCLive/live-initramfs/scripts/live-bottom/30accessibility b/tools/XBMCLive/live-initramfs/scripts/live-bottom/30accessibility
new file mode 100755
index 0000000000..3ff3fda0d8
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/30accessibility
@@ -0,0 +1,181 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOACCESSIBILITY}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+if [ -z "${USERNAME}" ]
+then
+ echo "No default user for accessibility options."
+ exit 0
+fi
+
+log_begin_msg "Configuring accessibility options"
+
+# live-initramfs script
+
+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
+}
+
+laptop_detect ()
+{
+ if chroot /root /usr/sbin/laptop-detect
+ then
+ echo "orca.settings.orcaModifierKeys = orca.settings.LAPTOP_MODIFIER_KEYS" >> /root/home/$USERNAME/.orca/user-settings.py
+ echo "orca.settings.keyboardLayout = orca.settings.GENERAL_KEYBOARD_LAYOUT_LAPTOP" >> /root/home/$USERNAME/.orca/user-settings.py
+ fi
+}
+
+remove_applet ()
+{
+ # Code to remove an applet from the default panel setup
+ # This is rather hacky, but I can't think of a one or two line regular
+ # expression to do this any more efficiently. Patches welcome. In
+ # addition, setting these via gconf also doesn't work for some reason.
+
+ local line_no prior_line next_line
+
+ line_no="$(grep -n "<string>$1</string>" /root/usr/share/gconf/defaults/05_panel-default-setup.entries | cut -f 1 -d :)"
+ prior_line="$((line_no-1))"
+ next_line="$((line_no+1))"
+
+ sed -i -n "${prior_line},${next_line}!p" /root/usr/share/gconf/defaults/05_panel-default-setup.entries
+
+ chroot /root update-gconf-defaults
+}
+
+case ${ACCESS} in
+ access=v1)
+ # Lesser Visual Impairment
+ 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
+ ;;
+
+ access=v2)
+ # Moderate Visual Impairment
+ gct -s -t bool /desktop/gnome/interface/accessibility true
+ gct -s -t bool /desktop/gnome/applications/at/visual/startup true
+ gct -s -t string /desktop/gnome/applications/at/visual/exec orca
+ gct -s -t bool /apps/gksu/disable-grab true
+ gct -s -t string /desktop/gnome/applications/window_manager/default /usr/bin/metacity
+
+ if [ -x /root/usr/bin/orca ]
+ then
+ mkdir -p /root/home/${USERNAME}/.orca
+ echo "import orca.settings" >> /root/home/${USERNAME}/.orca/user-settings.py
+ echo "orca.settings.enableSpeech = False" >> /root/home/${USERNAME}/.orca/user-settings.py
+ echo "orca.settings.enableMagnifier = True" >> /root/home/${USERNAME}/.orca/user-settings.py
+ laptop_detect
+ chroot /root chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.orca
+ fi
+ ;;
+
+ access=v3)
+ # Blindness
+ # Disabled for now, until we know eSpeak works.
+ #gct -s -t bool /desktop/gnome/sound/enable_esd false
+ gct -s -t bool /desktop/gnome/interface/accessibility true
+ gct -s -t bool /desktop/gnome/applications/at/visual/startup true
+ gct -s -t string /desktop/gnome/applications/at/visual/exec orca
+ gct -s -t bool /apps/gksu/disable-grab true
+ gct -s -t string /desktop/gnome/applications/window_manager/default /usr/bin/metacity
+
+ remove_applet fast_user_switch
+ ;;
+
+ braille=ask)
+ # Braille
+ gct -s -t bool /desktop/gnome/interface/accessibility true
+ gct -s -t bool /desktop/gnome/applications/at/visual/startup true
+ gct -s -t string /desktop/gnome/applications/at/visual/exec orca
+ gct -s -t bool /apps/gksu/disable-grab true
+ gct -s -t string /desktop/gnome/applications/window_manager/default /usr/bin/metacity
+
+ if [ -x /root/usr/bin/orca ]
+ then
+ mkdir -p /root/home/${USERNAME}/.orca
+ echo "import orca.settings" >> /root/home/${USERNAME}/.orca/user-settings.py
+ echo "orca.settings.enableSpeech = False" >> /root/home/${USERNAME}/.orca/user-settings.py
+ echo "orca.settings.enableBraille = True" >> /root/home/${USERNAME}/.orca/user-settings.py
+ laptop_detect
+ chroot /root chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.orca
+ fi
+
+ remove_applet fast_user_switch
+ ;;
+
+ access=m1)
+ # Minor Motor Difficulties
+ 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
+ gct -s -t bool /apps/gksu/disable-grab true
+
+ 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
+ ;;
+
+ access=m2)
+ # Motor Difficulties - pointing devices
+ 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]
+
+ 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
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/31disable_update_notifier b/tools/XBMCLive/live-initramfs/scripts/live-bottom/31disable_update_notifier
new file mode 100755
index 0000000000..e3630495d8
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/31disable_update_notifier
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOUPDATENOTIFIER}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling update-notifier"
+
+# live-initramfs script
+
+# 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
+
+if [ -e /root/usr/lib/update-notifier/apt-check ]
+then
+ ln -s /bin/true /root/usr/lib/update-notifier/apt-check
+fi
+
+# 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/tools/XBMCLive/live-initramfs/scripts/live-bottom/32disable_hibernation b/tools/XBMCLive/live-initramfs/scripts/live-bottom/32disable_hibernation
new file mode 100755
index 0000000000..f4960e645a
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/32disable_hibernation
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOPOWERMANAGEMENT}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Configuring power management"
+
+# live-initramfs script
+
+gpm_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-power-manager 2>/dev/null) || panel_version=""
+
+if [ -n "${gpm_version}" ] && [ -n "${USERNAME}" ]
+then
+ #live-reconfigure /root gnome-power-manager
+ # Gnome < 2.20
+ chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gnome-power-manager/can_hibernate false
+ # Gnome >= 2.20
+ chroot /root sudo -u "${USERNAME}" gconftool-2 -s -t bool /apps/gnome-power-manager/general/can_hibernate false
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/33enable_apport_crashes b/tools/XBMCLive/live-initramfs/scripts/live-bottom/33enable_apport_crashes
new file mode 100755
index 0000000000..47e650d2fc
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/33enable_apport_crashes
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOPROGRAMCRASHES}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Enabling detection of crashes"
+
+# live-initramfs script
+
+if [ -e /root/etc/default/apport ]
+then
+ sed -i 's/enabled=0/enabled=1/' /root/etc/default/apport
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/34disable_kpersonalizer b/tools/XBMCLive/live-initramfs/scripts/live-bottom/34disable_kpersonalizer
new file mode 100755
index 0000000000..d61c8798de
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/34disable_kpersonalizer
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOKPERSONALIZER}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling kpersonalizer"
+
+# live-initramfs script
+
+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 << EOF
+[General]
+FirstLogin=false
+EOF
+
+ else
+ echo "I'm not smart enough to disable kpersonalizer startup" >&2
+ echo "Because kpersonalizerrc already exists" >&2
+ fi
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/35fix_language_selector b/tools/XBMCLive/live-initramfs/scripts/live-bottom/35fix_language_selector
new file mode 100755
index 0000000000..8452d12000
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/35fix_language_selector
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOLANGUAGESELECTOR}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Fixing language selector"
+
+# live-initramfs script
+
+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/tools/XBMCLive/live-initramfs/scripts/live-bottom/36disable_trackerd b/tools/XBMCLive/live-initramfs/scripts/live-bottom/36disable_trackerd
new file mode 100755
index 0000000000..667131d86d
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/36disable_trackerd
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOTIMEZONE}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling trackerd"
+
+# live-initramfs script
+
+rm -f /root/etc/xdg/autostart/tracker-applet.desktop \
+ /root/etc/xdg/autostart/trackerd.desktop \
+ /root/usr/share/autostart/trackerd.desktop
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/38jockey_disable_check b/tools/XBMCLive/live-initramfs/scripts/live-bottom/38jockey_disable_check
new file mode 100755
index 0000000000..1a642e195f
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/38jockey_disable_check
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+PREREQ=""
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+if [ -n "${NOJOCKEY}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling jockey driver check"
+
+rm -f /root/etc/xdg/autostart/jockey*.desktop
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/41apt_cdrom b/tools/XBMCLive/live-initramfs/scripts/live-bottom/41apt_cdrom
new file mode 100755
index 0000000000..00606d5006
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/41apt_cdrom
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOAPTCDROM}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Adding APT-CDROM source"
+
+# live-initramfs script
+
+if [ -d /root/cdrom ]
+then
+ chroot /root apt-cdrom -m add
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/42disable_apparmor b/tools/XBMCLive/live-initramfs/scripts/live-bottom/42disable_apparmor
new file mode 100755
index 0000000000..f87cab4fdd
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/42disable_apparmor
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOAPPARMOR}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling AppArmor (does not work with stacked file systems)"
+
+# live-initramfs script
+
+if [ -x /root/etc/init.d/apparmor ]
+then
+ chroot /root update-rc.d -f apparmor remove
+fi
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/43disable_updateinitramfs b/tools/XBMCLive/live-initramfs/scripts/live-bottom/43disable_updateinitramfs
new file mode 100755
index 0000000000..0a434ed05b
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/43disable_updateinitramfs
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+. /scripts/live-functions
+
+log_begin_msg "Disabling update-initramfs"
+
+# live-initramfs script
+
+chroot /root dpkg-divert --add --rename --quiet \
+ /usr/sbin/update-initramfs
+
+cat > /root/usr/sbin/update-initramfs <<EOF
+#!/bin/sh
+
+echo "update-initramfs is disabled since running on a live CD"
+exit 0
+EOF
+
+chmod 0755 /root/usr/sbin/update-initramfs
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/44pk_allow b/tools/XBMCLive/live-initramfs/scripts/live-bottom/44pk_allow
new file mode 100755
index 0000000000..ccdd7cec5e
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/44pk_allow
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -n "${NOPOLKITCONF}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Grant administrative PolicyKit privilieges to default user"
+
+# live-initramfs script
+
+# configure PolicyKit in live session
+mkdir -p /root/etc/PolicyKit
+cat << EOF > /root/etc/PolicyKit/PolicyKit.conf
+<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
+
+<!DOCTYPE pkconfig PUBLIC "-//freedesktop//DTD PolicyKit Configuration 1.0//EN"
+"http://hal.freedesktop.org/releases/PolicyKit/1.0/config.dtd">
+
+<!-- See the manual page PolicyKit.conf(5) for file format -->
+
+<config version="0.1">
+ <match user="root">
+ <return result="yes"/>
+ </match>
+EOF
+
+if [ -n "${USERNAME}" ]
+then
+ cat << EOF >> /root/etc/PolicyKit/PolicyKit.conf
+ <!-- don't ask password for user in live session -->
+ <match user="$USERNAME">
+ <return result="yes"/>
+ </match>
+EOF
+fi
+
+cat << EOF >> /root/etc/PolicyKit/PolicyKit.conf
+ <define_admin_auth group="admin"/>
+</config>
+EOF
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-bottom/99hook b/tools/XBMCLive/live-initramfs/scripts/live-bottom/99hook
new file mode 100755
index 0000000000..17895ca103
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-bottom/99hook
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ=""
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs header
+
+if [ -z "${HOOK}" ]
+then
+ exit 0
+fi
+
+. /scripts/live-functions
+
+log_begin_msg "Executing custom hook script"
+
+# live-initramfs script
+
+cd /root
+chroot /root wget "${HOOK}"
+
+FILE="$(basename ${HOOK})"
+
+chmod 0755 "${FILE}"
+./"${FILE}"
+rm -f "${FILE}"
+
+log_end_msg
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-functions b/tools/XBMCLive/live-initramfs/scripts/live-functions
new file mode 100644
index 0000000000..8bf9c38e7a
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-functions
@@ -0,0 +1,113 @@
+
+. /scripts/functions
+. /live.vars
+
+log_wait_msg ()
+{
+ # Print a message and wait for enter
+ if [ -x /sbin/usplash_write ]
+ then
+ /sbin/usplash_write "INPUTENTER ${@}"
+ read nunya < /dev/.initramfs/usplash_outfifo
+ else if [ -x /sbin/splashy_update ] ; then
+ /sbin/splashy_update "getstring ${@}" | read nunya
+ fi ; fi
+
+ _log_msg "Waiting: ${@} ... \n"
+}
+
+really_export ()
+{
+ STRING="${1}"
+ VALUE="$(eval echo -n \${$STRING})"
+
+ if [ -f /live.vars ] && grep -sq "export ${STRING}" /live.vars
+ then
+ sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars
+ else
+ echo "export ${STRING}=\"${VALUE}\"" >> /live.vars
+ fi
+
+ eval export "${STRING}"="${VALUE}"
+}
+
+lang2locale() {
+ langpart="${1%%_*}"
+ if [ "$1" != "C" ]; then
+ # Match the language code with 3rd field in languagelist
+ line=$(grep -v "^#" /root/usr/share/live-initramfs/languagelist | cut -f3,4,5 -d\; | grep -v ';C$' | grep "^$langpart;")
+ if [ -n "$line" ]; then
+ if [ "$(echo "$line" | grep -c '')" -gt 1 ]; then
+ # More than one match; try matching the
+ # country as well.
+ countrypart="${1#*_}"
+ if [ "$countrypart" = "$1" ]; then
+ countryline="$(echo "$line" | head -n1)"
+ echo "${countryline##*;}"
+ return
+ fi
+ countrypart="${countrypart%%[@.]*}"
+ countryline="$(echo "$line" | grep ";$countrypart;" | head -n1 || true)"
+ if [ "$countryline" ]; then
+ echo "${countryline##*;}"
+ return
+ fi
+ fi
+ echo "${line##*;}"
+ fi
+ else
+ echo "C"
+ fi
+}
+
+# Override maybe_break from scripts/functions
+maybe_break()
+{
+ if [ "${break}" = "$1" ]; then
+ # Call original panic
+ . /scripts/functions
+ panic "Spawning shell within the initramfs"
+ fi
+}
+
+# Override panic from scripts/functions
+panic() {
+
+ DEB_1="\033[1;31m .''\`. \033[0m"
+ DEB_2="\033[1;31m: :' : \033[0m"
+ DEB_3="\033[1;31m\`. \`'\` \033[0m"
+ DEB_4="\033[1;31m \`- \033[0m"
+
+ LIVELOG="\033[1;37m/live.log\033[0m"
+ DEBUG="\033[1;37mdebug\033[0m"
+
+ # Reset redirections to avoid buffering
+ exec 1>&6 6>&-
+ exec 2>&7 7>&-
+ kill ${tailpid}
+
+ printf "\n\n"
+ printf " ${DEB_1}\n"
+ printf " ${DEB_2} \033[1;37mBOOT FAILED!\033[0m\n"
+ printf " ${DEB_3}\n"
+ printf " ${DEB_4} This Debian Live image failed to boot.\n\n"
+
+ printf " Please file a bug against the 'live-initramfs' package or email the Debian\n"
+ printf " Live mailing list at <debian-live@lists.debian.org>, making sure to note the\n"
+ printf " exact version, name and distribution of the image you were attempting to boot.\n\n"
+
+ printf " The file ${LIVELOG} contains some debugging information but booting with the\n"
+ printf " ${DEBUG} command-line parameter will greatly increase its verbosity which is\n"
+ printf " extremely useful when diagnosing issues.\n\n"
+
+ if [ -n "${panic}" ]; then
+ printf " live-initramfs will now restart your system. "
+ else
+ printf " live-initramfs will now start a shell. "
+ fi
+ printf "The error message was:\n\n "
+
+ # Call original panic
+ . /scripts/functions
+ panic "$@"
+}
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-helpers b/tools/XBMCLive/live-initramfs/scripts/live-helpers
new file mode 100644
index 0000000000..8e1c0feaf3
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-helpers
@@ -0,0 +1,501 @@
+# live-initramfs helper functions, used by live-initramfs on boot and by live-snapshot
+
+if [ ! -x "/bin/fstype" ]
+then
+ # klibc not in path -> not in initramfs
+ export PATH="${PATH}:/usr/lib/klibc/bin"
+fi
+
+# handle upgrade path from old udev (using udevinfo) to
+# recent versions of udev (using udevadm info)
+if [ -x /sbin/udevadm ]
+then
+ udevinfo='/sbin/udevadm info'
+else
+ udevinfo='udevinfo'
+fi
+
+# handle cases with partial udev (Ubuntu)
+if [ -x /lib/udev/vol_id ]
+then
+ volume_label='/lib/udev/vol_id -l'
+ volume_fstype='/lib/udev/vol_id -t'
+else
+ volume_label='/lib/udev/blkid -s LABEL -o value'
+ volume_fstype='/lib/udev/blkid -s TYPE -o value'
+fi
+
+!(wc --version > /dev/null 2>&1) || wcIsAvailable=1
+
+wordCount()
+{
+ cmdLine=${1}
+ if [ -n "${wcIsAvailable}" ];
+ then
+ num=$($cmdLine | wc -w)
+ else
+ num=0
+ for word in $($cmdLine);
+ do
+ num=$(( $num + 1 ))
+ done
+ fi
+ echo $num
+}
+
+
+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}
+}
+
+is_supported_fs ()
+{
+ fstype="${1}"
+
+ # Validate input first
+ if [ -z "${fstype}" ]
+ then
+ return 1
+ fi
+
+ # Try to look if it is already supported by the kernel
+ if grep -q ${fstype} /proc/filesystems
+ then
+ return 0
+ else
+ # Then try to add support for it the gentle way using the initramfs capabilities
+ modprobe ${fstype}
+ if grep -q ${fstype} /proc/filesystems
+ then
+ return 0
+ # Then try the hard way if /root is already reachable
+ else
+ kmodule="/root/lib/modules/`uname -r`/${fstype}/${fstype}.ko"
+ if [ -e "${kmodule}" ]
+ then
+ insmod "${kmodule}"
+ if grep -q ${fstype} /proc/filesystems
+ then
+ return 0
+ fi
+ fi
+ fi
+ fi
+
+ return 1
+}
+
+get_fstype ()
+{
+ local FSTYPE
+ local FSSIZE
+
+ # fstype misreports LUKS devices
+ if is_luks "${1}"
+ then
+ $volume_fstype ${1} 2>/dev/null
+ return
+ fi
+
+
+ eval $(fstype ${1} 2>/dev/null)
+
+ if [ "${FSTYPE}" != "unknown" ]
+ then
+ echo ${FSTYPE}
+ return 0
+ fi
+
+ $volume_fstype ${1}
+}
+
+where_is_mounted ()
+{
+ device=${1}
+
+ if grep -q "^${device} " /proc/mounts
+ then
+ # return the first found
+ grep -m1 "^${device} " /proc/mounts | cut -f2 -d ' '
+ fi
+}
+
+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 [ -z "${mountp}" ]
+ then
+ mountp="/mnt/tmp_fs_size"
+
+ mkdir -p "${mountp}"
+ mount -t $(get_fstype "${dev}") -o ro "${dev}" "${mountp}" || log_warning_msg "cannot 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}" || log_warning_msg "cannot umount ${mountp}"
+ rmdir "${mountp}"
+ fi
+
+ 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}
+ local readonly=${6}
+
+ modprobe -q -b "${module}"
+
+ if [ -x /sbin/udevadm ]
+ then
+ # lenny
+ udevadm settle
+ else
+ # etch
+ udevsettle
+ fi
+
+ for loopdev in ${pattern}
+ do
+ if [ "$(cat ${loopdev}/size)" -eq 0 ]
+ then
+ dev=$(sys2dev "${loopdev}")
+ options=''
+
+ if [ -n "${readonly}" ]
+ then
+ if losetup --help 2>&1 | grep -q -- "-r\b"
+ then
+ options="${options} -r"
+ fi
+ fi
+
+ if [ 0 -lt "${offset}" ]
+ then
+ options="${options} -o ${offset}"
+ fi
+
+ if [ -z "${encryption}" ]
+ then
+ losetup ${options} "${dev}" "${fspath}"
+ else
+ # Loop AES encryption
+ while true
+ do
+ load_keymap
+
+ echo -n "Enter passphrase for root filesystem: " >&6
+ read -s passphrase
+ echo "${passphrase}" > /tmp/passphrase
+ unset 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
+ echo -n "There was an error decrypting the root filesystem ... Retry? [Y/n] " >&6
+ read answer
+
+ if [ "$(echo "${answer}" | cut -b1 | tr A-Z a-z)" = "n" ]
+ then
+ unset answer
+ break
+ fi
+ done
+ fi
+
+ echo "${dev}"
+ return 0
+ fi
+ done
+
+ panic "No loop devices available"
+}
+
+try_mount ()
+{
+ dev="${1}"
+ mountp="${2}"
+ opts="${3}"
+ fstype="${4}"
+
+ old_mountp="$(where_is_mounted ${dev})"
+
+ if [ -n "${old_mountp}" ]
+ then
+ if [ "${opts}" != "ro" ]
+ then
+ mount -o remount,"${opts}" "${dev}" "${old_mountp}" || panic "Remounting ${dev} ${opts} on ${old_mountp} failed"
+ fi
+
+ mount -o bind "${old_mountp}" "${mountp}" || panic "Cannot bind-mount ${old_mountp} on ${mountp}"
+ else
+ if [ -z "${fstype}" ]
+ then
+ fstype=$(get_fstype "${dev}")
+ fi
+ mount -t "${fstype}" -o "${opts}" "${dev}" "${mountp}" || panic "Cannot mount ${dev} on ${mountp}, fstype=${fstype}, options=${opts}"
+ fi
+}
+
+find_cow_device ()
+{
+ # Returns a device containing a partition labeled "${pers_label}" or containing a file named the same way
+ # in the latter case the partition containing the file is left mounted
+ # if is not in black_listed_devices
+ pers_label="${1}"
+ cow_backing="/${pers_label}-backing"
+ black_listed_devices="${2}"
+
+ if [ -z "${PERSISTENT_PATH}" ]
+ then
+ pers_fpath=${cow_backing}/${pers_label}
+ else
+ pers_fpath=${cow_backing}/${PERSISTENT_PATH}/${pers_label}
+ fi
+
+ for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram | grep -v fd)
+ do
+ for dev in $(subdevices "${sysblock}")
+ do
+ devname=$(sys2dev "${dev}")
+
+ if echo "${black_listed_devices}" | grep -q "${devname}"
+ then
+ # skip this device enterely
+ break
+ fi
+
+ # Checking for a luks device
+ if [ -e /sbin/cryptsetup ] && /sbin/cryptsetup isLuks ${devname}
+ then
+ while true
+ do
+ load_keymap
+
+ /lib/cryptsetup/askpass "Enter passphrase for ${pers_label} on ${devname}: " /sbin/cryptsetup -T 1 luksOpen ${devname} $(basename ${devname}) --key-file=-
+ error=${?}
+
+ devname="/dev/mapper/$(basename ${devname})"
+
+ if [ 0 -eq ${error} ]
+ then
+ unset error
+ break
+ fi
+
+ echo
+ echo -n "There was an error decrypting ${devname} ... Retry? [Y/n] " >&6
+ read answer
+
+ if [ "$(echo "${answer}" | cut -b1 | tr A-Z a-z)" = "n" ]
+ then
+ unset answer
+ break
+ fi
+ done
+ fi
+
+ if [ "$($volume_label -l ${devname} 2>/dev/null)" = "${pers_label}" ]
+ then
+ echo "${devname}"
+ return 0
+ fi
+
+ if [ "${PERSISTENT}" = "nofiles" ]
+ then
+ # do not mount the device to find for image files
+ # just skip this
+ break
+ fi
+
+ case "$(get_fstype ${devname})" in
+ vfat|ext2|ext3|ext4|jffs2)
+ mkdir -p "${cow_backing}"
+ if ! try_mount "${devname}" "${cow_backing}" "rw"
+ then
+ break
+ fi
+
+ if [ -f "${pers_fpath}" ]
+ then
+ echo $(setup_loop "${pers_fpath}" "loop" "/sys/block/loop*")
+ return 0
+ else
+ umount ${cow_backing}
+ fi
+ ;;
+ *)
+ ;;
+ esac
+ done
+ done
+ return 1
+}
+
+find_files ()
+{
+ # return the a string composed by device name, mountpoint an the first of ${filenames} found on a supported partition
+ # FIXME: merge with above function
+
+ filenames="${1}"
+ snap_backing="/snap-backing"
+ black_listed_devices="${2}"
+
+ for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram | grep -v fd)
+ do
+ for dev in $(subdevices "${sysblock}")
+ do
+ devname=$(sys2dev "${dev}")
+ devfstype="$(get_fstype ${devname})"
+
+ if echo "${black_listed_devices}" | grep -q "${devname}"
+ then
+ # skip this device enterely
+ break
+ fi
+
+ if is_supported_fs ${devfstype}
+ then
+ mkdir -p "${snap_backing}"
+
+ if try_mount "${devname}" "${snap_backing}" "ro" "${devfstype}"
+ then
+ for filename in ${filenames}
+ do
+ if [ -f "${snap_backing}/${filename}" ]
+ then
+ echo "${devname} ${snap_backing} ${filename}"
+ umount ${snap_backing}
+ return 0
+ fi
+ done
+ fi
+
+ umount ${snap_backing}
+ fi
+ done
+ done
+}
+
+get_mac ()
+{
+ mac=""
+
+ for adaptor in /sys/class/net/*
+ do
+ status="$(cat ${adaptor}/iflink)"
+
+ if [ "${status}" -eq 2 ]
+ then
+ mac="$(cat ${adaptor}/address)"
+ mac="$(echo ${mac} | sed 's/:/-/g' | tr '[a-z]' '[A-Z]')"
+ fi
+ done
+
+ echo ${mac}
+}
+
+is_luks()
+{
+ devname="${1}"
+ if [ -x /sbin/cryptsetup ]
+ then
+ /sbin/cryptsetup isLuks "${devname}" 2>/dev/null || ret=${?}
+ return ${ret}
+ else
+ return 1
+ fi
+
+}
diff --git a/tools/XBMCLive/live-initramfs/scripts/live-premount/modules b/tools/XBMCLive/live-initramfs/scripts/live-premount/modules
new file mode 100755
index 0000000000..408e873848
--- /dev/null
+++ b/tools/XBMCLive/live-initramfs/scripts/live-premount/modules
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#set -e
+
+# initramfs-tools header
+
+PREREQ="udev"
+
+prereqs()
+{
+ echo "${PREREQ}"
+}
+
+case "${1}" in
+ prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# live-initramfs script
+
+# The following modprobe entry is a workaround to live-initramfs not
+# finding the root filesytem.
+#
+# See also:
+# * http://lists.alioth.debian.org/pipermail/debian-live-devel/2007-May/001459.html
+# * http://lists.alioth.debian.org/pipermail/debian-live-devel/2007-June/001517.html
+# * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=363047
+
+modprobe -q ide-generic
+modprobe -q esp