summaryrefslogtreecommitdiffstats
path: root/liveinit.tpl
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2018-06-15 13:06:32 +0200
committer Eric Hameleers <alien@slackware.com>2018-06-15 13:06:32 +0200
commit05e2b4b7564ba517aed3e1e714235312df6349d9 (patch)
treec98ddd4e45d646c23b13bdb255509073d20d5687 /liveinit.tpl
parent92e8f6612c81c805139c562fe666a37bee5df0fe (diff)
downloadliveslak-05e2b4b7564ba517aed3e1e714235312df6349d9.tar.gz
liveslak-05e2b4b7564ba517aed3e1e714235312df6349d9.tar.xz
Add support for on-disk OS configuration file
The configuration file must be in the liveslak main directory ('/liveslak' by default) and be called 'DISTRO_os.cfg' where DISTRO is the lower-case name of the distro ('slackware' by default). The following variables can be defined in the configuration file, one per line, in the format VAR=value: BLACKLIST, INIT, KEYMAP, LIVE_HOSTNAME, LOAD, LOCALE, LUKSVOL, NOLOAD, RUNLEVEL, TWEAKS, TZ, XKB. Since the configuration file is sourced by the live init script, it is OK to have comments in it that are prefixed with '#'.
Diffstat (limited to 'liveinit.tpl')
-rwxr-xr-xliveinit.tpl38
1 files changed, 37 insertions, 1 deletions
diff --git a/liveinit.tpl b/liveinit.tpl
index 5cddd02..da1b4ff 100755
--- a/liveinit.tpl
+++ b/liveinit.tpl
@@ -2,7 +2,7 @@
#
# Copyright 2004 Slackware Linux, Inc., Concord, CA, USA
# Copyright 2007, 2008, 2009, 2010, 2012 Patrick J. Volkerding, Sebeka, MN, USA
-# Copyright 2015, 2016, 2017 Eric Hameleers, Eindhoven, NL
+# Copyright 2015, 2016, 2017, 2018 Eric Hameleers, Eindhoven, NL
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -49,6 +49,9 @@ LIVEUID="@LIVEUID@"
LIVEMEDIA=""
LIVEPATH=""
+DISTROCFG="@DISTRO@_os.cfg"
+CFGACTION=""
+
# By default, let the media determine if we can write persistent changes:
# However, if we define TORAM=1, we will also set VIRGIN=1 since we want
# to avoid anything that writes to disk after we copy the OS to RAM.
@@ -185,6 +188,10 @@ for ARG in $(cat /proc/cmdline); do
# nic=<driver>:<interface>:<dhcp|static>[:ipaddr:netmask[:gateway]]
ENET=$(echo $ARG | cut -f2 -d=)
;;
+ cfg=*)
+ CFGACTION=$(echo $ARG | cut -f2 -d=)
+ if [ "${CFGACTION}" = "skip" ]; then DISTROCFG="" ; fi
+ ;;
noload=*)
NOLOAD=$(echo $ARG | cut -f2 -d=)
;;
@@ -676,6 +683,35 @@ if [ "$RESCUE" = "" ]; then
debugit
+ # liveslak can optionally load a OS config file "@DISTRO@_os.cfg"
+ # which contains "VARIABLE=value" lines, where VARIABLE is one of
+ # the following variables that are used below in the live init script:
+ # BLACKLIST, INIT, KEYMAP, LIVE_HOSTNAME, LOAD, LOCALE, LUKSVOL,
+ # NOLOAD, RUNLEVEL, TWEAKS, TZ, XKB.
+ if [ -z "$CFGACTION" ]; then
+ # Read OS configuration from disk file if present
+ # (prevent this by adding 'cfg=skip' to the boot commandline).
+ if [ -f "/mnt/media/${LIVEMAIN}/${DISTROCFG}" ]; then
+ source /mnt/media/${LIVEMAIN}/${DISTROCFG}
+ fi
+ elif [ "$CFGACTION" = "write" ]; then
+ # Write liveslak OS parameters to disk:
+ echo > /mnt/media/${LIVEMAIN}/${DISTROCFG} 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "${MARKER}: Live media read-only, cannot write config file."
+ else
+ echo "${MARKER}: Writing config to /${LIVEMAIN}/${DISTROCFG}"
+ for LIVEPARM in \
+ BLACKLIST INIT KEYMAP LIVE_HOSTNAME LOAD LOCALE LUKSVOL \
+ NOLOAD RUNLEVEL TWEAKS TZ XKB ;
+ do
+ if [ -n "$(eval echo \$$LIVEPARM)" ]; then
+ echo $LIVEPARM=$(eval echo \$$LIVEPARM) >> /mnt/media/${LIVEMAIN}/${DISTROCFG}
+ fi
+ done
+ fi
+ fi
+
# Start assembling our live system components below /mnt/live :
mkdir /mnt/live