From e2a44a9c03afe840b82e0a7b79a6113c15426bbf Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 8 May 2015 15:42:44 +0200 Subject: fix the cmdline hack for parsing ip config - now is statically set --- testModule/hooks/cmdline/expand-kcl-ip.sh | 30 +++++++++++++++++++++++------- testModule/hooks/pre-mount/fetch-config.sh | 27 +++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 11 deletions(-) (limited to 'testModule') diff --git a/testModule/hooks/cmdline/expand-kcl-ip.sh b/testModule/hooks/cmdline/expand-kcl-ip.sh index 8be1c718..9f617b09 100755 --- a/testModule/hooks/cmdline/expand-kcl-ip.sh +++ b/testModule/hooks/cmdline/expand-kcl-ip.sh @@ -1,20 +1,36 @@ -# fakes the cmdline to fix the ip parsing when using -# syslinux's IPAPPEND 1 mask +command -v warn >/dev/null || . /lib/dracut-lib.sh + +# fakes the cmdline to fix the ip parsing in darcut's net-lib.sh [ -d /fake ] || mkdir /fake # need to be a tmpfs for the hack to work mount -t tmpfs tmpfs /fake -# append ':hiwi:eth0:none' to the 'ip=' parameter we got -# from syslinux's IPAPPEND 1 -sed 's/\(ip=\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}:\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}:\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}:\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\)/\1:hiwi:eno1:none/' /proc/cmdline > /fake/cmdline +for parameter in $(getargs ip=); do + local 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 + + warn "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask" + local final_dracut_ip_config="$ip::$gateway_ip:$net_mask:hiwi-test-28:eno1:none" + warn "Final dracut ip config: $final_dracut_ip_config" + sed --regexp-extended "s/ip=[^ ]*/ip=$final_dracut_ip_config/g" /proc/cmdline > /fake/cmdline +done + # bind mount it. Can we trust mount return codes here? # # if so, we should check what we get in $? mount -o bind /fake/cmdline /proc/cmdline # check if it worked -if ! grep 'hiwi:eth0:none' /proc/cmdline; then - command -v warn >/dev/null || . /lib/dracut-lib.sh +if ! grep 'hiwi-test-28:eno1:none' /proc/cmdline; then warn 'Haxing cmdline did not work :( sad pandaz...' fi diff --git a/testModule/hooks/pre-mount/fetch-config.sh b/testModule/hooks/pre-mount/fetch-config.sh index 013b0058..5151c3b7 100755 --- a/testModule/hooks/pre-mount/fetch-config.sh +++ b/testModule/hooks/pre-mount/fetch-config.sh @@ -1,12 +1,31 @@ -command -v info >/dev/null || . /lib/dracut-lib.sh +# load dracut functions +command -v getarg >/dev/null || . /lib/dracut-lib.sh -info "Getting configuration from OPENSLX-Server..." +# read SLX_SERVER and SLX_BASE from the kernel command line +SLX_SERVER=$(getarg slxsrv) +SLX_BASE=$(getarg slxbase) +SLX_CONFIG_DIR="/opt/openslx" +SLX_CONFIG_FILE="/opt/openslx/config" + +if [ -z "$SLX_SERVER" ]; then + warn "No 'slxsrv' parameter found in the kernel command line!" + warn "Skipping OpenSLX configuration..." + exit 1 +fi +if [ -z "$SLX_BASE" ]; then + warn "No 'slxbase' parameter found in the kernel command line!" + warn "Skipping OpenSLX configuration..." + exit 1 +fi +info "Getting configuration from OPENSLX-Server..." WGET="$(busybox which wget)" if [ -z $WGET ]; then # do nothing warn "'wget' not found. Skipping openslx configuration..." exit 1 fi -mkdir -p /opt/openslx -$WGET http://10.4.9.51/openslx/config -O /opt/openslx/config + +# ok then we are ready to download the config +mkdir -p "${SLX_CONFIG_DIR}" +$WGET -T 5 -q "http://${SLX_SERVER}/${SLX_BASE}/config" -O "${SLX_CONFIG_FILE}" -- cgit v1.2.3-55-g7522