mountpoint=/live_media
-# Will be mounted if found as copy on write instead of tmpfs
root_persistence="casper-rw"
-
-# TODO
-## Each file found with this pattern will be mounted directly in the
-## mountpoint extracted from file name "${other_mounts_pattern}<mountpoint>"
-#other_mounts_pattern="casper-mount-"
home_persistence="home-rw"
-#overlay_method=unionfs
-#if [ "${DPKG_ARCH}" = "ia64" ] || [ "${DPKG_ARCH}" = "hppa" ] || [ "${DPKG_ARCH}" = "sparc" ]; then
-# overlay_method=devmapper
-#fi
-
USERNAME="casper"
USERFULLNAME="Live session user"
HOST="live"
+BUILD_SYSTEM="Debian"
mkdir -p $mountpoint
[ -f /etc/casper.conf ] && . /etc/casper.conf
-export USERNAME USERFULLNAME HOST
+export USERNAME USERFULLNAME HOST BUILD_SYSTEM
+
+if [ "${BUILD_SYSTEM}" == "Ubuntu" ]; then
+ MP_QUIET="-Q"
+else
+ MP_QUIET="-q"
+fi
# looking for casper specifics options as kernel parameters
for x in $(cat /proc/cmdline); do
case $x in
+ userfullname*)
+ export USERFULLNAME=${x#userfullname=}
+ export CASPERCONF="changed"
+ ;;
+ host*)
+ export HOST=${x#host=}
+ export CASPERCONF="changed"
+ ;;
+ username*)
+ export USERNAME=${x#username=}
+ export CASPERCONF="changed"
+ ;;
netboot*)
export NETBOOT=${x#netboot=} ;;
toram)
export TORAM=1 ;;
- show-cow)
- export SHOWCOW=1 ;;
+ showmounts)
+ export SHOWMOUNTS=1 ;;
persistent)
export PERSISTENT=1 ;;
+ ip*)
+ STATICIP=${x#ip=}
+ if [ "${STATICIP}" == "" ]; then
+ STATICIP="frommedia"
+ fi
+ export STATICIP ;;
casper-getty)
export CASPERGETTY=1 ;;
esac
local module=$2
local pattern=$3
- modprobe -qb "$module"
+ modprobe "${MP_QUIET}" -b "$module"
udevsettle
for loopdev in $pattern; do
}
get_fstype() {
- #FIXME# one use of this function expects "unknown" another does not!
- # which is it???
local FSTYPE
local FSSIZE
eval $(fstype < $1)
backdev="$1"
rootmnt="$2"
- modprobe -qb dm-mod
+ modprobe "${MP_QUIET}" -b dm-mod
COW_DEVICE=/dev/ram1
COW_NAME="casper-cow"
size=$(expr ${size} + ${size}/20 ) # Fixme: 5% more to be sure
needed_space=$(expr ${size} * 1024)
freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ))
-
+
if [ ! ${freespace} -lt ${needed_space} ] ; then
[ "$quiet" != "y" ] && log_begin_msg "Not enough free memory to copy to ram"
[ "$quiet" != "y" ] && log_end_msg
do_netmount() {
rc=1
- modprobe -q af_packet # For DHCP
+ modprobe "${MP_QUIET}" af_packet # For DHCP
ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf
fi
[ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}"
-
+
if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then
rc=0
elif do_nfsmount ; then
do_nfsmount() {
rc=1
- modprobe -q nfs
+ modprobe "${MP_QUIET}" nfs
if [ -z "${NFSOPTS}" ]; then
NFSOPTS=""
fi
fi
[ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
- modprobe -q cifs
+ modprobe "${MP_QUIET}" cifs
if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then
rc=0
image_directory="$1"
rootmnt="$2"
- modprobe -qb unionfs
+ modprobe "${MP_QUIET}" -b unionfs
- # run-init can't deal with this, but we're going to move all of these
- # away before it runs anyway.
- croot="/casper"
+ # 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=""
mkdir -p /cow
cowdevice="tmpfs"
cow_fstype="tmpfs"
-
+
# Looking for "${root_persistence}" device or file
if [ ! -z "${PERSISTENT}" ]; then
cowprobe=$(find_cow_device "${root_persistence}")
cowdevice=${cowprobe}
cow_fstype=$(get_fstype "${cowprobe}")
else
- [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent medium"
+ [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent medium"
fi
fi
mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow"
-
+
mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs mount failed"
-
- for d in ${rofslist}; do
- mkdir -p "${rootmnt}/casper/${d##*/}"
- case d in
- *.dir) mount -o bind "${d}" "${rootmnt}/casper/${d##*/}" ;;
- *) mount -o move "${d}" "${rootmnt}/casper/${d##*/}" ;;
- esac
- done
+
+ # Look for a snapshot to copy
# Adding other custom mounts
if [ ! -z "${PERSISTENT}" ]; then
fi
fi
- if [ ! -z "${SHOWCOW}" ]; then
- mkdir -p "$rootmnt/cow"
- mount -o bind /cow "$rootmnt/cow"
+ if [ ! -z "${SHOWMOUNTS}" ]; then
+ for d in ${rofslist}; do
+ mkdir -p "${rootmnt}/casper/${d##*/}"
+ case d in
+ *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/casper/${d##*/}"
+ ;;
+ *) mount -o move "${d}" "${rootmnt}/casper/${d##*/}"
+ ;;
+ esac
+ done
fi
+
+ # shows cow fs on /cow for use by casper-snapshot
+ mkdir -p "$rootmnt/cow"
+ mount -o bind /cow "$rootmnt/cow"
}
is_usb_device() {
sysfs_path="${1#/sys}"
- if /lib/udev/path_id "${sysfs_path}" | grep -Eq "ID_PATH=(usb|pci-[^-]*-usb)"; then
+ if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-usb)"; then
return 0
fi
return 1
done
elif [ "${fstype}" = "squashfs" || \
"${fstype}" = "ext2" ]; then
-
+
# This is an ugly hack situation, the block device has
# an image directly on it. It's hopefully
# casper, so take it and run with it.
-
+
ln -s "${devname}" "${devname}.${fstype}"
echo "${devname}.${fstype}"
return
done
}
+pulsate() {
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "PULSATE"
+ fi
+}
+
set_usplash_timeout() {
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT 120"
exec 7>&2
exec > casper.log
exec 2>&1
-
+
set_usplash_timeout
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount"
+ pulsate
run_scripts /scripts/casper-premount
[ "$quiet" != "y" ] && log_end_msg
if [ "$?" -gt 0 ]; then
panic "Unable to find a medium containing a live file system"
fi
-
+
if [ ! -z "${TORAM}" ]; then
copy_to_ram "${livefs_root}"
fi
maybe_break casper-bottom
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-bottom"
+ pulsate
run_scripts /scripts/casper-bottom
[ "$quiet" != "y" ] && log_end_msg