summaryrefslogtreecommitdiffstats
path: root/liveinit
diff options
context:
space:
mode:
Diffstat (limited to 'liveinit')
-rwxr-xr-xliveinit156
1 files changed, 104 insertions, 52 deletions
diff --git a/liveinit b/liveinit
index 43c8a9c..38a13b1 100755
--- a/liveinit
+++ b/liveinit
@@ -40,6 +40,12 @@ LIVEMAIN="@LIVEMAIN@"
MARKER="@MARKER@"
PERSISTENCE="@PERSISTENCE@"
+DISTRO="@DISTRO@"
+CDISTRO="@CDISTRO@"
+VERSION="@VERSION@"
+
+LIVEUID="@LIVEUID@"
+
LIVEMEDIA=""
LIVEPATH=""
@@ -220,14 +226,18 @@ for ARG in $(cat /proc/cmdline); do
esac
done
+# Verbose boot script execution:
[ $DEBUG -ge 2 ] && set -x
debugit () {
- [ $DEBUG -eq 0 -o $DEBUG -gt 3 ] && return
- echo "DEBUG>> -- blkid info -- :"
- blkid | while read LINE ; do echo "DEBUG>> $LINE" ; done
- echo "DEBUG>> -- mount info -- :"
- mount | while read LINE ; do echo "DEBUG>> $LINE" ; done
+ if [ $DEBUG -eq 0 -o $DEBUG -gt 3 ]; then
+ return
+ elif [ $DEBUG -le 2 ]; then
+ echo "DEBUG>> -- blkid info -- :"
+ blkid | while read LINE ; do echo "DEBUG>> $LINE" ; done
+ echo "DEBUG>> -- mount info -- :"
+ mount | while read LINE ; do echo "DEBUG>> $LINE" ; done
+ fi
echo "DEBUG>> -- Press ENTER to continue -- : "
read JUNK
return
@@ -272,7 +282,7 @@ fi
# Load kernel modules (ideally this was already done by udev):
if [ ! -d /lib/modules/$(uname -r) ]; then
- echo "No kernel modules found for Linux $(uname -r)."
+ echo "${MARKER}: No kernel modules found for Linux $(uname -r)."
elif [ -x ./load_kernel_modules ]; then # use load_kernel_modules script:
echo "${MARKER}: Loading kernel modules from initrd image:"
. ./load_kernel_modules 1>/dev/null 2>/dev/null
@@ -477,33 +487,44 @@ if [ "$RESCUE" = "" ]; then
# SUBSYS can be 'system', 'addons', 'optional':
SUBSYS="$1"
- if ls /mnt/media/${LIVEMAIN}/${SUBSYS}/*.sxz 1>/dev/null 2>/dev/null ; then
- for MODULE in /mnt/media/${LIVEMAIN}/${SUBSYS}/*.sxz ; do
- MODBASE="$(basename ${MODULE} .sxz)"
- if [ "$SUBSYS" = "optional" ]; then
- # Load one or more optionals by using boot parameter 'load':
- # load=mod1[,mod2[,mod3]]
- if [ -z "$LOAD" -o -z "$(echo ",${LOAD}," |grep -i ",$(echo $MODBASE |cut -d- -f2),")" ]; then
- continue
- fi
- elif [ "$SUBSYS" = "addons" ]; then
- # Skip loading one or more addons by using boot parameter 'noload':
- # noload=mod1[,mod2[,mod3]]
- if [ -n "$NOLOAD" -a -n "$(echo ",${NOLOAD}," |grep -i ",$(echo $MODBASE |cut -d- -f2),")" ]; then
- echo "$MODBASE" >> /mnt/live/modules/skipped
- continue
- fi
+ for MODULE in $(find /mnt/media/${LIVEMAIN}/${SUBSYS}/ -name "*.sxz" 2>/dev/null |sort) ; do
+ MODBASE="$(basename ${MODULE} .sxz)"
+ if [ "$SUBSYS" = "optional" ]; then
+ # Load one or more optionals by using boot parameter 'load':
+ # load=mod1[,mod2[,mod3]]
+ if [ -z "$LOAD" -o -z "$(echo ",${LOAD}," |grep -i ",$(echo $MODBASE |cut -d- -f2),")" ]; then
+ continue
+ fi
+ elif [ "$SUBSYS" = "addons" ]; then
+ # Skip loading one or more addons by using boot parameter 'noload':
+ # noload=mod1[,mod2[,mod3]]
+ if [ -n "$NOLOAD" -a -n "$(echo ",${NOLOAD}," |grep -i ",$(echo $MODBASE |cut -d- -f2),")" ]; then
+ echo "$MODBASE" >> /mnt/live/modules/skipped
+ continue
fi
- MODLOC=$(find_modloc ${MODULE} /mnt/media)
+ fi
+ MODLOC=$(find_modloc ${MODULE} /mnt/media)
+ if [ -d /mnt/live/modules/${MODBASE} ]; then
+ echo "${MARKER}: duplicate $SUBSYS module '${MODBASE}', excluding it from the overlay."
+ echo "$MODBASE" >> /mnt/live/modules/dupes
+ else
mkdir /mnt/live/modules/${MODBASE}
mount -t squashfs -o loop ${MODLOC} /mnt/live/modules/${MODBASE}
- RODIRS=":/mnt/live/modules/${MODBASE}${RODIRS}"
- # 0099-* are the Live customizations, exclude those for setup2hd:
- if ! echo ${MODBASE} | grep -q ^0099 ; then
- FS2HD=":/mnt/live/modules/${MODBASE}${FS2HD}"
+ if [ $? -eq 0 ]; then
+ if echo ${MODBASE} | grep -q ^0000 -a ; then
+ echo "${MARKER}: ${CDISTRO} Live based on liveslak-${VERSION} #$(cat /mnt/live/modules/${MODBASE}/${MARKER})"
+ fi
+ RODIRS=":/mnt/live/modules/${MODBASE}${RODIRS}"
+ # 0099-* are the Live customizations, exclude those for setup2hd:
+ if ! echo ${MODBASE} | grep -q ^0099 ; then
+ FS2HD=":/mnt/live/modules/${MODBASE}${FS2HD}"
+ fi
+ else
+ echo "${MARKER}: Failed to mount $SUBSYS module '${MODBASE}', excluding it from the overlay."
+ echo "$MODBASE" >> /mnt/live/modules/failed
fi
- done
- fi
+ fi
+ done
}
## End support functions ##
@@ -691,19 +712,19 @@ if [ "$RESCUE" = "" ]; then
mount -o remount,rw /mnt/media
# Find a free loop device to mount the persistence container file:
prdev=$(find_loop)
- prdir=${PERSISTENCE}_$(od -An -N1 -tu1 /dev/urandom |tr -d ' ')
+ prdir=$(basename ${PERSISTENCE})_$(od -An -N1 -tu1 /dev/urandom |tr -d ' ')
mkdir -p /mnt/live/${prdir}
losetup $prdev /mnt/media/${PERSISTENCE}.img
# Check if the persistence container is LUKS encrypted:
if cryptsetup isLuks $prdev 1>/dev/null 2>/dev/null ; then
echo "Unlocking LUKS encrypted persistence file '/${PERSISTENCE}.img'"
- cryptsetup luksOpen $prdev ${PERSISTENCE} </dev/tty0 >/dev/tty0 2>&1
+ cryptsetup luksOpen $prdev $(basename ${PERSISTENCE}) </dev/tty0 >/dev/tty0 2>&1
if [ $? -ne 0 ]; then
echo "${MARKER}: Failed to unlock persistence file '/${PERSISTENCE}.img'."
echo "${MARKER}: Falling back to RAM."
else
# LUKS properly unlocked; from now on use the mapper device instead:
- prdev=/dev/mapper/${PERSISTENCE}
+ prdev=/dev/mapper/$(basename ${PERSISTENCE})
fi
fi
prfs=$(blkid $prdev |rev |cut -d'"' -f2 |rev)
@@ -714,10 +735,10 @@ if [ "$RESCUE" = "" ]; then
else
if [ "$WIPE_PERSISTENCE" = "1" ]; then
echo "${MARKER}: Wiping existing persistent data in '/${PERSISTENCE}.img'."
- find /mnt/live/${prdir}/${PERSISTENCE}/ -mindepth 1 -exec rm -rf {} \; 2>/dev/null
+ find /mnt/live/${prdir}/$(basename ${PERSISTENCE})/ -mindepth 1 -exec rm -rf {} \; 2>/dev/null
fi
echo "${MARKER}: Writing persistent changes to file '/${PERSISTENCE}.img'."
- UPPERDIR=/mnt/live/${prdir}/${PERSISTENCE}
+ UPPERDIR=/mnt/live/${prdir}/$(basename ${PERSISTENCE})
OVLWORK=/mnt/live/${prdir}/.ovlwork
fi
fi
@@ -730,6 +751,8 @@ if [ "$RESCUE" = "" ]; then
fi
fi
+ debugit
+
# Create the writable upper directory, plus the workdir which is required
# for overlay to function (the two must be in the same POSIX filesystem):
[ ! -d ${UPPERDIR} ] && mkdir -p ${UPPERDIR}
@@ -794,11 +817,19 @@ EOT
fi
if [ ! -z "$KEYMAP" -o ! -z "$XKB" ]; then
# Set a keyboard mapping in X.Org, derived from the console map if needed:
- # Variable XKB can be set to "XkbLayout,XkbVariant", like "xkb=ch,fr"
+ # Variable XKB can be set to "XkbLayout,XkbVariant,XkbOptions".
+ # For example "xkb=ch,fr,compose:sclk,grp:alt_shift_toggle"
+ # Note that the XkbOptions can be several comma-separated values.
+ # The XkbLayout and XkbVariant values must not contain commas.
# You can set just the XkbVariant by adding something like "kbd=ch xkb=,fr"
+
+ # Catch a missing comma in the "$XKB" string value which messes with 'cut':
+ XKB="$XKB,"
XKBLAYOUT=$(echo $XKB |cut -d, -f1)
XKBVARIANT=$(echo $XKB |cut -d, -f2)
- # Ensure that XKBLAYOUT gets a value; XKBVARIANT is allowed to be empty.
+ XKBOPTIONS=$(echo $XKB |cut -d, -f3-)
+ # Ensure that XKBLAYOUT gets a value;
+ # XKBVARIANT and XKBOPTIONS are allowed to be empty.
if [ -z "$XKBLAYOUT" ]; then
if [ -z "$KEYMAP" ]; then
XKBLAYOUT="us"
@@ -810,27 +841,48 @@ EOT
XKBLAYOUT="us"
fi
echo "${MARKER}: Switching live X desktop to '$XKBLAYOUT' keyboard"
- # Germans use the AltGr key, so Scroll Lock will be their Compose Key:
- if [ "$XKBLAYOUT" = "de" ]; then
- XKBOPTIONS="compose:sclk"
- else
- XKBOPTIONS="compose:ralt"
- fi
- # If the layout is not 'us' then add 'us' as a secondary nevertheless:
+
if [ "$XKBLAYOUT" != "us" ]; then
+ # If the layout is not 'us' then add 'us' as a secondary nevertheless:
XKBLAYOUT="$XKBLAYOUT,us"
XKBVARIANT="$XKBVARIANT,"
- XKBOPTIONS="grp:alt_shift_toggle,grp_led:scroll,$XKBOPTIONS"
+ fi
+
+ if [ -z "$XKBOPTIONS" ]; then
+ # If the user did not specify any X keyboard options then we will
+ # determine a set of sane defaults:
+ if [ "$XKBLAYOUT" != "us" ]; then
+ # User should be able to switch between layouts (Alt-Shift toggles).
+ # Also, many languages use the AltGr key, so we will use Shift-AltGr
+ # (press them, then release them, then enter your two keys of choice)
+ # as the Compose Key - see "/usr/share/X11/xkb/rules/xorg.lst":
+ XKBOPTIONS="grp:alt_shift_toggle,grp_led:scroll,lv3:ralt_switch_multikey"
+ else
+ # For US keyboard we just define the Compose Key as before:
+ XKBOPTIONS="lv3:ralt_switch_multikey"
+ fi
fi
mkdir -p /mnt/overlay/etc/X11/xorg.conf.d
- cat <<EOT > /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf
+ echo > /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf
+ cat <<EOT >> /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf
Section "InputClass"
Identifier "keyboard-all"
+ MatchIsKeyboard "on"
+ MatchDevicePath "/dev/input/event*"
Driver "evdev"
Option "XkbLayout" "$XKBLAYOUT"
+EOT
+ if [ -z "$XKBVARIANT" ]; then
+ cat <<EOT >> /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf
+ #Option "XkbVariant" "$XKBVARIANT"
+EOT
+ else
+ cat <<EOT >> /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf
Option "XkbVariant" "$XKBVARIANT"
+EOT
+ fi
+ cat <<EOT >> /mnt/overlay/etc/X11/xorg.conf.d/30-keyboard.conf
Option "XkbOptions" "$XKBOPTIONS"
- MatchIsKeyboard "on"
EndSection
EOT
@@ -859,21 +911,21 @@ EOT
echo ${TZ} > /mnt/overlay/etc/timezone
# KDE4 and PLASMA5 user timezone re-configuration:
- if [ -f /mnt/overlay/home/live/.kde/share/config/ktimezonedrc ]; then
+ if [ -f /mnt/overlay/home/${LIVEUID}/.kde/share/config/ktimezonedrc ]; then
sed -i -e "s%^LocalZone=.*%LocalZone=${TZ}%" \
- /mnt/overlay/home/live/.kde/share/config/ktimezonedrc
+ /mnt/overlay/home/${LIVEUID}/.kde/share/config/ktimezonedrc
fi
- if [ -f /mnt/overlay/home/live/.config/ktimezonedrc ]; then
+ if [ -f /mnt/overlay/home/${LIVEUID}/.config/ktimezonedrc ]; then
sed -i -e "s%^LocalZone=.*%LocalZone=${TZ}%" \
- /mnt/overlay/home/live/.config/ktimezonedrc
+ /mnt/overlay/home/${LIVEUID}/.config/ktimezonedrc
fi
fi
if [ ! -z "$LIVEPW" ]; then
# User entered a custom live password on the boot commandline:
- echo "${MARKER}: Changing password for user 'live'."
+ echo "${MARKER}: Changing password for user '${LIVEUID}'."
chroot /mnt/overlay /usr/sbin/chpasswd <<EOPW
-live:${LIVEPW}
+${LIVEUID}:${LIVEPW}
EOPW
fi