summaryrefslogtreecommitdiffstats
path: root/testModule/parse-ip.sh
blob: 2f720c57664b6c9d44884e74cb35a6f7773f9578 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Converts ip configuration format given by the pxe pre boot provider to a
# dracut compatible static ip configuration.

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" ] && broadcast_ip=$3
    [ -n "$4" ] && net_mask=$4

    warn "PXE given net configuration: ip: $ip server_ip: $server_ip broadcast_ip: $broadcast_ip net_mask: $net_mask"
    # TODO
    local gateway_ip="$broadcast_ip"
    repace_cmd test "$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none"
done

# 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 --rbind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline