diff -ru gosc-scripts/imc-shell/imgcust-scripts/CustomizationUtils.sh gosc-scripts-modified/imc-shell/imgcust-scripts/CustomizationUtils.sh --- gosc-scripts/imc-shell/imgcust-scripts/CustomizationUtils.sh 2016-04-29 15:41:27.000000000 -0700 +++ gosc-scripts-modified/imc-shell/imgcust-scripts/CustomizationUtils.sh 2016-10-04 16:24:20.797385696 -0700 @@ -182,7 +182,7 @@ echo "$newDomainname" } -# Finds the first IPv4 out of all NICs. +# Finds the first static IPv4 out of all NICs. # # Args: # None @@ -210,6 +210,40 @@ echo "$ipv4Addr" } +# Finds the first static IPv6 out of all NICs. +# +# Args: +# None +# Results: +# string: the first IPv6 or empty string in case there are no NICs or all are DHCP. +# Throws: +# Dies in case NICs setting is empty or IPv6 address setting is empty. +FindFirstStaticIpV6() +{ + local ipv6Addr='' + local nicsCnt='' # needs to be declared before assigned + + nicsCnt=$(ConfigFile_GetNicsCnt) || exit 1 + + local i= + for i in $(seq 1 $nicsCnt); do + local nic=$(ConfigFile_GetNicByIndex $i) + local ipv6Cnt=$(ConfigFile_GetIpV6Cnt $nic) || exit 1 + local j= + for j in $(seq 1 $ipv6Cnt); do + ipv6Addr=$(ConfigFile_GetIpV6AddrByInd $nic $j) || exit 1 + if [[ -n "$ipv6Addr" ]]; then + break + fi + done + if [[ -n "$ipv6Addr" ]]; then + break + fi + done + + echo "$ipv6Addr" +} + # Processes content of the existing /etc/hosts file. # # Args: @@ -341,7 +375,7 @@ local hostNameWasSet=0 #$(ProcessEtcHosts "$hostsFile" "$oldHostname" "$oldFQDN" "$newHostname" configFileVar output) - # Add mapping to the customized static ip + # Add mapping to the customized static V4 ip local ipaddr=$(FindFirstStaticIpV4) || exit 1 if [[ -n "$ipaddr" ]]; then local newStaticIPEntry="$ipaddr"$'\t'"$newFQDN" @@ -354,6 +388,21 @@ Debug "Static ip entry '$newStaticIPEntry' added" fi + # Add mapping to the customized static V6 ip + local ipv6addr=$(FindFirstStaticIpV6) || exit 1 + if [[ -n "$ipv6addr" ]]; then + local newStaticIPV6Entry="$ipv6addr"$'\t'"$newFQDN" + if [[ '$newFQDN' != '$newHostname' ]]; then + newStaticIPV6Entry="$newStaticIPV6Entry $newHostname"; + fi + + hostNameWasSet=1 + output="$output""::1 localhost ip6-localhost ip6-loopback"$'\n' + output="$output""$newStaticIPV6Entry"$'\n' + Debug "Static ip v6 entry '$newStaticIPV6Entry' added" + fi + + # Add mapping to loopback 127.0.1.1 if new hostname is still not set if [[ $hostNameWasSet -eq 0 ]]; then # Hostname still not added - use a loopback entry to @@ -744,7 +793,7 @@ Exec "$execute" Debug "Light wave domain join procedure completed" else - Debug "ERROR :: Either Domain Name or Password Missing: Cannot Join Lighwave domain" + Debug "Lightwave config not provided: Nothing to customize" fi }