diff options
Diffstat (limited to 'builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh')
| -rwxr-xr-x | builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh b/builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh new file mode 100755 index 00000000..4c388178 --- /dev/null +++ b/builder/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +( # subshell for variable scoping +SLX_INITIAL_KERNEL_COMMAND_LINE="$(cat /proc/cmdline | tr --delete '\n')" + +# This location will be used to have a writable kernel command line file +# location. +writeable_proc_cmdline_path='/writable_proc_cmdline/' +mkdir --parents "$writeable_proc_cmdline_path" +# NOTE: The fake writeable overlay have to be a temporary filesystem for the +# hack to work. +mount --types tmpfs tmpfs "$writeable_proc_cmdline_path" +echo -n "$SLX_INITIAL_KERNEL_COMMAND_LINE" > \ + "${writeable_proc_cmdline_path}/cmdline" + +echo -e \ + '-----------------------Kernel-Command-Line:--------------------------\n' \ + "${SLX_INITIAL_KERNEL_COMMAND_LINE}\n" \ + '----------------------------------------------------------------------' + +for parameter in $(getargs BOOTIF=); do + info "PXE given boot interface $parameter" + dracut_interface_name="bootnet:$(echo $parameter | \ + sed --regexp-extended 's/.{2}[:\-]((.{2}[:\-]){5}.{2})/\1/' | \ + sed s/-/:/g)" + info "Dracut interface name is: $dracut_interface_name" + echo -n " ifname=$dracut_interface_name" >> \ + "${writeable_proc_cmdline_path}cmdline" +done +for parameter in $(getargs ip=); do + temp="$parameter:" + set -- + while [ -n "$temp" ]; do + set -- "$@" "${temp%%:*}" + temp=${temp#*:} + done + + [ -n "$1" ] && ip=$1 + [ -n "$2" ] && server_ip=$2 + [ -n "$3" ] && gateway_ip=$3 + [ -n "$4" ] && net_mask=$4 + + info "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask" + dracut_ip_configuration="$ip::$gateway_ip:$net_mask::bootnet:off" + info "Dracut ip configuration is: $dracut_ip_configuration" + sed --regexp-extended "s/ip=[^ ]*/ip=$dracut_ip_configuration/g" \ + --in-place "${writeable_proc_cmdline_path}cmdline" +done + +if [ -z "$dracut_ip_configuration" ]; then + warn 'No "ip" parameter found in the kernel command line.' +fi +if [ -z "$dracut_interface_name" ]; then + warn 'No "BOOTIF" parameter found in the kernel command line.' +fi +mount --options bind "${writeable_proc_cmdline_path}cmdline" /proc/cmdline + +if [ -z $(getargs slxsrv=) ]; then + warn 'No "slxsrv" parameter found in the kernel command line.' + exit 1 +fi +if [ -z $(getargs slxbase=) ]; then + warn 'No "slxbase" parameter found in the kernel command line.' + exit 1 +fi + +echo '-----------------------Dracut-Kernel-Command-Line:----------------------' +cat /proc/cmdline +echo '------------------------------------------------------------------------' +) || exit $? +# region vim modline + +# vim: set tabstop=4 shiftwidth=4 expandtab: +# vim: foldmethod=marker foldmarker=region,endregion: + +# endregion |
