- Allow setting DHCP reservation preference with --unattended

- Flip condition check on $dhcpReserv: first check if empty, and if not, check if it's not 1.
  Doing it the other way (first check if not 1) would give a shell error if $dhcpReserv was empty.
This commit is contained in:
Orazio 2020-01-20 09:34:43 +01:00
parent fc9a9f5ab7
commit 69606f7207

View file

@ -166,7 +166,7 @@ main(){
avoidStaticIPv4Ubuntu avoidStaticIPv4Ubuntu
else else
getStaticIPv4Settings getStaticIPv4Settings
if [ "$dhcpReserv" -ne 1 ] || [ -z "$dhcpReserv" ]; then if [ -z "$dhcpReserv" ] || [ "$dhcpReserv" -ne 1 ]; then
setStaticIPv4 setStaticIPv4
fi fi
fi fi
@ -596,6 +596,7 @@ getStaticIPv4Settings() {
if [ "${runUnattended}" = 'true' ]; then if [ "${runUnattended}" = 'true' ]; then
if [ -z "$dhcpReserv" ] || [ "$dhcpReserv" -ne 1 ]; then
local INVALID_STATIC_IPV4_SETTINGS=0 local INVALID_STATIC_IPV4_SETTINGS=0
if [ -z "$IPv4addr" ]; then if [ -z "$IPv4addr" ]; then
@ -632,7 +633,11 @@ getStaticIPv4Settings() {
exit 1 exit 1
fi fi
fi fi
else
echo "::: Skipping setting static IP address"
fi
echo "dhcpReserv=${dhcpReserv}" >> /tmp/setupVars.conf
echo "IPv4addr=${IPv4addr%/*}" >> /tmp/setupVars.conf echo "IPv4addr=${IPv4addr%/*}" >> /tmp/setupVars.conf
echo "IPv4gw=${IPv4gw}" >> /tmp/setupVars.conf echo "IPv4gw=${IPv4gw}" >> /tmp/setupVars.conf
return return