[bugfix] Set fixed IP address from first randomly assigned one.

This commit is contained in:
Igor Pecovnik 2018-10-24 17:01:08 +02:00
parent ca99f8d0b7
commit 345145f3b6

View file

@ -30,10 +30,17 @@ local random=$(shuf -i 0-3 -n 1)
MACADDR=$(printf ${prefixes[$random]}':%02X:%02X:%02X:%02X:%02X\n' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])
}
# set fixed IP address from first randomly assigned one. If nothing is deteceted, generate one.
set_fixed_mac ()
{
get_random_mac
uuid=$(nmcli -f UUID,DEVICE,TYPE connection show --active | grep ethernet | awk '{print $1}' | head -1)
local nmcli_query=$(nmcli -f UUID,DEVICE,TYPE connection show --active | grep ethernet | head -1)
device=$(echo $nmcli_query | awk '{print $2}' )
uuid=$(echo $nmcli_query | awk '{print $1}' )
MACADDR=$(nmcli device show $device | grep -i hwaddr | awk '{print $2}')
[[ -z $MACADDR ]] && get_random_mac
if [[ -n $uuid ]]; then
nmcli connection modify $uuid ethernet.cloned-mac-address $MACADDR
nmcli connection modify $uuid -ethernet.mac-address ""