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..e1ec13f79b --- /dev/null +++ b/live/root/usr/lib/dracut/modules.d/99agama-cmdline/agama-cmdline-conf.sh @@ -0,0 +1,31 @@ +#! /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)" + if ! strstr "$_i" "="; then + # Set the variable as a boolean if there is no assignation + _i="${_i}=1" + fi + 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..24a6bcd321 --- /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..612843ddd7 --- /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 diff --git a/live/src/agama-installer.changes b/live/src/agama-installer.changes index 8d573634a3..7113bb56f0 100644 --- a/live/src/agama-installer.changes +++ b/live/src/agama-installer.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Jan 8 12:10:39 UTC 2025 - Knut Anderssen + +- Make agama kernel cmdline options available in the sysroot at + /etc/agama.d/cmdline.conf and set it as a EnvironmentFile + in Agama related services (gh#agama-project/agama#1866). + ------------------------------------------------------------------- Tue Dec 10 12:46:06 UTC 2024 - Michal Filka diff --git a/live/src/config.sh b/live/src/config.sh index d326a0c76b..607fe25094 100644 --- a/live/src/config.sh +++ b/live/src/config.sh @@ -82,11 +82,11 @@ echo "root_disk=live:LABEL=$label" >>/etc/cmdline.d/10-liveroot.conf # if there's a default network location, add it here # echo "root_net=" >> /etc/cmdline.d/10-liveroot.conf echo 'install_items+=" /etc/cmdline.d/10-liveroot.conf "' >/etc/dracut.conf.d/10-liveroot-file.conf -echo 'add_dracutmodules+=" dracut-menu "' >>/etc/dracut.conf.d/10-liveroot-file.conf +echo 'add_dracutmodules+=" dracut-menu agama-cmdline "' >>/etc/dracut.conf.d/10-liveroot-file.conf -if [ "${arch}" = "s390x" ];then - # workaround for custom bootloader setting - touch /config.bootoptions +if [ "${arch}" = "s390x" ]; then + # workaround for custom bootloader setting + touch /config.bootoptions fi # replace the @@LIVE_MEDIUM_LABEL@@ with the real Live partition label name from KIWI @@ -111,7 +111,7 @@ rm /var/log/zypper.log /var/log/zypp/history # reduce the "vim-data" content, this package is huge (37MB unpacked!), keep only # support for JSON (for "agama config edit") and Ruby (fixing/debugging the Ruby # service) -rpm -ql vim-data | grep -v -e '/ruby.vim$' -e '/json.vim$' -e colors | xargs rm 2> /dev/null || true +rpm -ql vim-data | grep -v -e '/ruby.vim$' -e '/json.vim$' -e colors | xargs rm 2>/dev/null || true du -h -s /usr/{share,lib}/locale/ @@ -125,7 +125,7 @@ du -h -s /usr/{share,lib}/locale/ mkdir -p /etc/agama.d # emulate "localectl list-locales" call, it cannot be used here because it # insists on running systemd as PID 1 :-/ -ls -1 -d /usr/lib/locale/*.utf8 | sed -e "s#/usr/lib/locale/##" -e "s#utf8#UTF-8#" > /etc/agama.d/locales +ls -1 -d /usr/lib/locale/*.utf8 | sed -e "s#/usr/lib/locale/##" -e "s#utf8#UTF-8#" >/etc/agama.d/locales # delete translations and unusupported languages (makes ISO about 22MiB smaller) # build list of ignore options for "ls" with supported languages like "-I cs* -I de* -I es* ..." @@ -138,7 +138,7 @@ ls -1 "${IGNORE_OPTS[@]}" -I "en_US*" -I "C.*" /usr/lib/locale/ | xargs -I% sh - # delete unused translations (MO files) for t in zypper gettext-runtime p11-kit; do - rm -f /usr/share/locale/*/LC_MESSAGES/$t.mo + rm -f /usr/share/locale/*/LC_MESSAGES/$t.mo done du -h -s /usr/{share,lib}/locale/ @@ -180,7 +180,7 @@ du -h -s /lib/modules /lib/firmware # disable the services included by dependencies for s in purge-kernels; do - systemctl -f disable $s || true + systemctl -f disable $s || true done # Only used for OpenCL and X11 acceleration on vmwgfx (?), saves ~50MiB diff --git a/rust/share/agama-web-server.service b/rust/share/agama-web-server.service index 0c8b27a4d8..210161d554 100644 --- a/rust/share/agama-web-server.service +++ b/rust/share/agama-web-server.service @@ -6,6 +6,7 @@ After=network-online.target agama.service agama-hostname.service BindsTo=agama.service [Service] +EnvironmentFile=-"/etc/agama.d/cmdline.conf" Environment="AGAMA_LOG=debug,zbus=info" Type=notify ExecStart=/usr/bin/agama-web-server serve --address :::80 --address2 :::443 diff --git a/service/share/agama.service b/service/share/agama.service index f9b9bcfeb3..0392ff5783 100644 --- a/service/share/agama.service +++ b/service/share/agama.service @@ -5,6 +5,7 @@ After=network-online.target [Service] Type=forking ExecStart=/usr/bin/agamactl --daemon +EnviromentFile=-/etc/agama.d/cmdline.conf PIDFile=/run/agama/bus.pid User=root TimeoutStopSec=5