diff options
| author | torben | 2015-04-09 03:27:39 +0200 |
|---|---|---|
| committer | torben | 2015-04-09 03:27:39 +0200 |
| commit | 3541f12849b277a2405a4d3bf692cf62f2045126 (patch) | |
| tree | 065f302e6fe108d53771bf421429224202ba33f1 /testModule | |
| parent | Trying convert given pxe ip configuration to dracut compatible one. (diff) | |
| download | systemd-init-3541f12849b277a2405a4d3bf692cf62f2045126.tar.gz systemd-init-3541f12849b277a2405a4d3bf692cf62f2045126.tar.xz systemd-init-3541f12849b277a2405a4d3bf692cf62f2045126.zip | |
Adding functions library.
Diffstat (limited to 'testModule')
| -rwxr-xr-x | testModule/busybox | bin | 0 -> 931664 bytes | |||
| -rw-r--r-- | testModule/library.sh | 38 | ||||
| -rw-r--r-- | testModule/module-setup.sh | 5 | ||||
| -rw-r--r-- | testModule/parse-ip.sh | 30 |
4 files changed, 52 insertions, 21 deletions
diff --git a/testModule/busybox b/testModule/busybox Binary files differnew file mode 100755 index 00000000..1212ae20 --- /dev/null +++ b/testModule/busybox diff --git a/testModule/library.sh b/testModule/library.sh new file mode 100644 index 00000000..d3f97aff --- /dev/null +++ b/testModule/library.sh @@ -0,0 +1,38 @@ +cat /proc/cmdline >/tmp/cmdline + +replace_cmd() { + sed --regexp-extended "s/$1=[^ ]*/$1=$2/g" /tmp/cmdline -i +} + +getcmdline() { + local _line + local _i + local CMDLINE_ETC_D + local CMDLINE_ETC + unset _line + + if [ -e /etc/cmdline ]; then + while read -r _line; do + CMDLINE_ETC="$CMDLINE_ETC $_line"; + done </etc/cmdline; + fi + for _i in /etc/cmdline.d/*.conf; do + [ -e "$_i" ] || continue + while read -r _line; do + CMDLINE_ETC_D="$CMDLINE_ETC_D $_line"; + done <"$_i"; + done + ## NOTE: We modify this to be able to alter kernel command line arguments + ## at runtime. + if [ -e /tmp/cmdline ]; then + read -r CMDLINE </tmp/cmdline; + CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE" + else + ## + if [ -e /proc/cmdline ]; then + read -r CMDLINE </proc/cmdline; + CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE" + fi + fi + printf "%s" "$CMDLINE" +} diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh index b06de3f5..8b35d52a 100644 --- a/testModule/module-setup.sh +++ b/testModule/module-setup.sh @@ -10,11 +10,14 @@ depends() { } install() { + # Loads globally needed useful functions or fixes some native dracut ones. + inst_hook cmdline 10 "$moddir/library.sh" # NOTE: Priority has to be greater than the network cmdline parsing hooks # since we have to modify the some kernel parameter before. inst_hook cmdline 100 "$moddir/parse-ip.sh" + #inst_simple "$moddir/busybox" /usr/bin/busybox #inst_hook pre-mount 20 "$moddir/setup_network.sh" - inst_multiple ping ip ifconfig mount sshd htop dhclient tail head cat vim touch + inst_multiple ping ip ifconfig sshd htop dhclient tail head cat vim touch sed return 0 } diff --git a/testModule/parse-ip.sh b/testModule/parse-ip.sh index 75fca7b2..2f720c57 100644 --- a/testModule/parse-ip.sh +++ b/testModule/parse-ip.sh @@ -1,19 +1,12 @@ # Converts ip configuration format given by the pxe pre boot provider to a # dracut compatible static ip configuration. -temporary_kernel_commandline_file_path='/temporary_kernel_commandline.txt' -warn -warn 'Running ip kernel command line transformation.' -warn - for parameter in $(getargs ip=); do + local temp="$parameter:" set -- - while [ -n "$parameter" ]; do - set -- "$@" "${parameter%%:*}" - parameter=${parameter#*:} - warn - warn JAU - warn + while [ -n "$temp" ]; do + set -- "$@" "${temp%%:*}" + temp=${temp#*:} done [ -n "$1" ] && ip=$1 @@ -21,17 +14,14 @@ for parameter in $(getargs ip=); do [ -n "$3" ] && broadcast_ip=$3 [ -n "$4" ] && net_mask=$4 - warn warn "PXE given net configuration: ip: $ip server_ip: $server_ip broadcast_ip: $broadcast_ip net_mask: $net_mask" - warn # TODO - gateway_ip="$broadcast_ip" - echo "ip=$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" > /etc/cmdline - warn - warn "Converted ip configuration: \"$ip\"." - warn + local gateway_ip="$broadcast_ip" + repace_cmd test "$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" done -#cat /proc/cmdline | sed --regexp-extended 's/ ip=[^ ]+//g' \ +# NOTE: Doesn't work since dracuts needed version of mount doesn't support +# binds. +#cat /proc/cmdline | sed --regexp-extended 's/ip=[^ ]+//g' \ # >"$temporary_kernel_commandline_file_path" && \ -#mount -n --bind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline +#mount -n --rbind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline |
