-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation for agama cmdline conf
- Loading branch information
Showing
6 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
28 changes: 28 additions & 0 deletions
28
live/root/usr/lib/dracut/modules.d/99agama-cmdline/agama-cmdline-conf.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
live/root/usr/lib/dracut/modules.d/99agama-cmdline/module-setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
11 changes: 11 additions & 0 deletions
11
live/root/usr/lib/dracut/modules.d/99agama-cmdline/save-agama-conf.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |