diff options
Diffstat (limited to 'core/rootfs/rootfs-stage31/data/inc/parse_kcl')
-rw-r--r-- | core/rootfs/rootfs-stage31/data/inc/parse_kcl | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/core/rootfs/rootfs-stage31/data/inc/parse_kcl b/core/rootfs/rootfs-stage31/data/inc/parse_kcl index 95f7daf5..ba2fea8f 100644 --- a/core/rootfs/rootfs-stage31/data/inc/parse_kcl +++ b/core/rootfs/rootfs-stage31/data/inc/parse_kcl @@ -5,26 +5,38 @@ getip () { } parse_ip () { local IPINFO=$1 - CLIENTIP="$(getip 1)" + export ip="$(getip 1)" SERVERIP="$(getip 2)" - GATEWAY="$(getip 3)" - SUBNET_MASK="$(getip 4)" - BROADCAST_ADDRESS="$(ipcalc -s -b "$CLIENTIP" "$SUBNET_MASK" | sed s/.*=//)" - [ -z "$BROADCAST_ADDRESS" ] && BROADCAST_ADDRESS="255.255.255.255" + export router="$(getip 3)" + export subnet="$(getip 4)" # we might have an idea of the dns server via preboot - DNS_SERVER="$(getip 5)" + export dns="$(getip 5)" +} + +parse_ipv4 () { + local var arg + var="${1%%=*}" + case "$var" in + ip|router|dns|hostname|domain|search|if|ntpsrv|subnet) ;; + *) return ;; + esac + arg="$( printf "%s" "${1#*=}" | tr -d "\`'\n\r" )" + export "$var=${arg}" } # read kernel command line DEBUG=0 SPLASH=0 -read KCL < "/proc/cmdline" +read -r KCL < "/proc/cmdline" for opts in ${KCL}; do case "${opts}" in debug=*) DEBUG=${opts#debug=} DEBUG_SHELL=set ;; + ipv4.*) + parse_ipv4 "${opts#ipv4.}" + ;; ip=*) # process IP info parse_ip ${opts#ip=} ;; @@ -36,9 +48,9 @@ for opts in ${KCL}; do BOOTIF=*) MAC="$( echo "$opts" | cut -b 11- | tr '-' ':' | tr '[A-Z]' '[a-z]' )" ;; # make mac lowercase for udev (see setup_network) slxsrv=*) - SLX_KCL_SERVERS=$( echo "${opts#slxsrv=}" | tr ',' " " ) ;; + SLX_KCL_SERVERS="$( echo "${opts#slxsrv=}" | tr ',' " " )" ;; slxbase=*) - SLX_BASE_PATH=${opts#slxbase=} ;; + SLX_BASE_PATH="${opts#slxbase=}" ;; splash) SPLASH=1 ;; nvidia) @@ -54,8 +66,15 @@ for opts in ${KCL}; do esac done +dns="${dns//,/ }" +search="${search//,/ }" +ntpsrv="${ntpsrv//,/ }" +[ -z "$MAC" ] && MAC="${if//-/:}" + # If slxsrv was not given on command line, just use the PXE server's address [ -z "$SLX_KCL_SERVERS" ] && [ -n "$SERVERIP" ] && SLX_KCL_SERVERS="$SERVERIP" +# Reverse case +[ -z "$SERVERIP" ] && SERVERIP="${SLX_KCL_SERVERS%% *}" # Now save to config file echo "SLX_KCL_SERVERS='$SLX_KCL_SERVERS'" >> "${FUTURE_ROOT}/opt/openslx/config" echo "SLX_BASE_PATH='$SLX_BASE_PATH'" >> "${FUTURE_ROOT}/opt/openslx/config" |