diff --git a/live/root/etc/systemd/system/agama-cmdline-env.service b/live/root/etc/systemd/system/agama-cmdline-env.service new file mode 100644 index 0000000000..c31d9371cf --- /dev/null +++ b/live/root/etc/systemd/system/agama-cmdline-env.service @@ -0,0 +1,17 @@ +[Unit] +Description=Export the configuration from kernel command line as environment variables + +# before starting the Agama server +Before=agama-web-server.service +Before=agama.service + +# before the interactive setting methods so they can override it +Before=live-password-dialog.service +Before=live-password-systemd.service + +[Service] +ExecStart=agama-cmdline-env +Type=oneshot + +[Install] +WantedBy=default.target diff --git a/live/root/usr/bin/agama-cmdline-env b/live/root/usr/bin/agama-cmdline-env new file mode 100755 index 0000000000..4e4dded3b9 --- /dev/null +++ b/live/root/usr/bin/agama-cmdline-env @@ -0,0 +1,24 @@ +#!/bin/sh + +#----[ import_agama_env ]----# +function import_agama_env () { +#-------------------------------------------------- +# import agama cmdline information as environment +# variables to the current environment +# --- + TERM_SAVE=$TERM + if [ -f /etc/agama.d/cmdline.conf ]; then + IFS_SAVE=$IFS +IFS=" +" + for i in `cat /etc/agama.d/cmdline.conf | sed -e s'@=@%@'`;do + varname=`echo $i | cut -f 1 -d% | tr -d " " | sed -e s'@\.@_@'` + varvals=`echo $i | cut -f 2 -d%` + varvals=`echo $varvals | sed -e s'@^ *@@' -e s'@ *$@@'` + export $varname=$varvals + done + IFS=$IFS_SAVE + fi +} + +import_agama_env diff --git a/live/root/usr/lib/dracut/modules.d/99agama-cmdline/README b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/README new file mode 100644 index 0000000000..2787db46c2 --- /dev/null +++ b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/README @@ -0,0 +1,6 @@ +dracut agama-cmdline module +------------------------------- + +This module writes any agama configuration given through the kernel cmdline +to its own cmdline conf file copying it to the sysroot. + diff --git a/live/root/usr/lib/dracut/modules.d/99agama-cmdline/agama-cmdline-conf.sh b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/agama-cmdline-conf.sh new file mode 100755 index 0000000000..187269f3d7 --- /dev/null +++ b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/agama-cmdline-conf.sh @@ -0,0 +1,28 @@ +#! /bin/sh + +[ -e /dracut-state.sh ] && . /dracut-state.sh + +. /lib/dracut-lib.sh + +get_agama_args() { + local _i _found + + for _i in $CMDLINE; do + case $_i in + LIBSTORAGE_* | YAST_* | agama* | Y2* | ZYPP_*) + _found=1 + ;; + esac + + if [ -n "$_found" ]; then + printf "Agama variable found ($_i)" + printf $_i + echo $_i >>/etc/cmdline.d/99-agama-cmdline.conf + fi + unset _found + done + + return 0 +} + +get_agama_args diff --git a/live/root/usr/lib/dracut/modules.d/99agama-cmdline/module-setup.sh b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/module-setup.sh new file mode 100755 index 0000000000..d957ddab0e --- /dev/null +++ b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/module-setup.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# called by dracut +check() { + return 0 +} + +# called by dracut +depends() { + return 0 +} + +installkernel() { + return 0 +} + +# called by dracut +install() { + inst_hook cmdline 99 "$moddir/agama-cmdline-conf.sh" + inst_hook pre-pivot 99 "$moddir/save-agama-conf.sh" +} diff --git a/live/root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh new file mode 100755 index 0000000000..99a328b7ee --- /dev/null +++ b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +[ -e /dracut-state.sh ] && . /dracut-state.sh + +. /lib/dracut-lib.sh + +if [ -e /etc/cmdline.d/99-agama-cmdline.conf ]; then + echo "Creating agama conf" + mkdir -p "$NEWROOT/etc/agama.d" + cp /etc/cmdline.d/99-agama-cmdline.conf "$NEWROOT/etc/agama.d/cmdline.conf" +fi