Skip to content

Commit

Permalink
Initial implementation for agama cmdline conf
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jan 7, 2025
1 parent 4045c06 commit 4918e3d
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
17 changes: 17 additions & 0 deletions live/root/etc/systemd/system/agama-cmdline-env.service
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions live/root/usr/bin/agama-cmdline-env
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions live/root/usr/lib/dracut/modules.d/99agama-cmdline/README
Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions live/root/usr/lib/dracut/modules.d/99agama-cmdline/module-setup.sh
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4918e3d

Please sign in to comment.