summaryrefslogtreecommitdiffstats
path: root/liveinit.tpl
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2017-09-19 20:51:34 +0200
committer Eric Hameleers <alien@slackware.com>2017-09-19 20:51:34 +0200
commit888d2a08730e0dc7343696945769e4ab4f8b4659 (patch)
tree9cc3c4f675ac461fb43870d8981e14836faf5c3e /liveinit.tpl
parent0ddc28312087bd711b49240361177309ed3641e7 (diff)
downloadliveslak-888d2a08730e0dc7343696945769e4ab4f8b4659.tar.gz
liveslak-888d2a08730e0dc7343696945769e4ab4f8b4659.tar.xz
Add upslak.sh, a script to tweak the Live USB stick.
Purpose: to update the content of a Slackware Live USB stick. upslak.sh accepts the following parameters: -b|--nobackup Do not try to backup original kernel and modules. -d|--devices List removable devices on this computer. -h|--help This help. -i|--init <filename> Replacement init script. -k|--kernel <filename> The kernel file (or package). -m|--kmoddir <name> The kernel modules directory (or package). -n|--netsupport Add network boot support if not yet present. -o|--outdev <filename> The device name of your USB drive. -p|--persistence Move persistent data into new Live module. -r|--restore Restore previous kernel and modules. -s|--scan Scan for insertion of new USB device instead of providing a devicename (using option '-o'). -v|--verbose Show verbose messages. -w|--wait<number> Add <number> seconds wait time to initialize USB.
Diffstat (limited to '')
-rwxr-xr-xliveinit.tpl36
1 files changed, 26 insertions, 10 deletions
diff --git a/liveinit.tpl b/liveinit.tpl
index 7ffc871..ea88164 100755
--- a/liveinit.tpl
+++ b/liveinit.tpl
@@ -732,8 +732,9 @@ if [ "$RESCUE" = "" ]; then
# Try a write... just to be dead sure:
if touch /mnt/media/${PERSISTENCE}/.rwtest 2>/dev/null && rm /mnt/media/${PERSISTENCE}/.rwtest 2>/dev/null ; then
# Writable media and we are allowed to write to it.
- if [ "$WIPE_PERSISTENCE" = "1" ]; then
+ if [ "$WIPE_PERSISTENCE" = "1" -o -f /mnt/media/${PERSISTENCE}/.wipe ]; then
echo "${MARKER}: Wiping existing persistent data in '/${PERSISTENCE}'."
+ rm -f /mnt/media/${PERSISTENCE}/.wipe 2>/dev/null
find /mnt/media/${PERSISTENCE}/ -mindepth 1 -exec rm -rf {} \; 2>/dev/null
fi
echo "${MARKER}: Writing persistent changes to media directory '/${PERSISTENCE}'."
@@ -766,8 +767,9 @@ if [ "$RESCUE" = "" ]; then
echo "${MARKER}: Failed to mount persistence file '/${PERSISTENCE}.img'."
echo "${MARKER}: Falling back to RAM."
else
- if [ "$WIPE_PERSISTENCE" = "1" ]; then
+ if [ "$WIPE_PERSISTENCE" = "1" -o -f /mnt/live/${prdir}/$(basename ${PERSISTENCE})/.wipe ]; then
echo "${MARKER}: Wiping existing persistent data in '/${PERSISTENCE}.img'."
+ rm -f /mnt/live/${prdir}/$(basename ${PERSISTENCE})/.wipe 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'."
@@ -799,14 +801,28 @@ if [ "$RESCUE" = "" ]; then
mount -t overlay -o lowerdir=${FS2HD} overlay /mnt/${LIVEMAIN}fs
# And this is the actual Live overlay:
mount -t overlay -o workdir=${OVLWORK},upperdir=${UPPERDIR},lowerdir=${RODIRS} overlay /mnt/overlay
- if [ $? -ne 0 -a "$VIRGIN" = "0" ]; then
- # Failed to create the persistent overlay - try without persistence:
- echo "${MARKER}: Failed to create persistent overlay, attempting to continue in RAM."
- UPPERDIR=/mnt/live/changes
- OVLWORK=/mnt/live/.ovlwork
- mkdir -p ${UPPERDIR}
- mkdir -p ${OVLWORK}
- mount -t overlay -o workdir=${OVLWORK},upperdir=${UPPERDIR},lowerdir=${RODIRS} overlay /mnt/overlay
+ MNTSTAT=$?
+ if [ "$VIRGIN" = "0" ]; then
+ if [ $MNTSTAT -ne 0 ]; then
+ # Failed to create the persistent overlay - try without persistence:
+ echo "${MARKER}: Failed to create persistent overlay, attempting to continue in RAM."
+ # Clean up and re-create upper and work directories:
+ rmdir $UPPERDIR 2>/dev/null
+ rmdir $OVLWORK 2>/dev/null
+ [ -n "${prdir}" ] && rmdir /mnt/live/${prdir} 2>/dev/null
+ VIRGIN=1
+ UPPERDIR=/mnt/live/changes
+ OVLWORK=/mnt/live/.ovlwork
+ mkdir -p ${UPPERDIR}
+ mkdir -p ${OVLWORK}
+ mount -t overlay -o workdir=${OVLWORK},upperdir=${UPPERDIR},lowerdir=${RODIRS} overlay /mnt/overlay
+ else
+ # Use a predictable name "changes" for the changes-directory which we can
+ # use later to squash its contents into a new .sxz module if needed.
+ # Will be a directory when there's no persistence, otherwise a bind-mount.
+ mkdir -p /mnt/live/changes
+ mount --rbind ${UPPERDIR} /mnt/live/changes
+ fi
fi
debugit