mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-22 04:40:16 +00:00
- 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:
parent
fc9a9f5ab7
commit
69606f7207
1 changed files with 32 additions and 27 deletions
|
@ -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,43 +596,48 @@ getStaticIPv4Settings() {
|
||||||
|
|
||||||
if [ "${runUnattended}" = 'true' ]; then
|
if [ "${runUnattended}" = 'true' ]; then
|
||||||
|
|
||||||
local INVALID_STATIC_IPV4_SETTINGS=0
|
if [ -z "$dhcpReserv" ] || [ "$dhcpReserv" -ne 1 ]; then
|
||||||
|
local INVALID_STATIC_IPV4_SETTINGS=0
|
||||||
|
|
||||||
if [ -z "$IPv4addr" ]; then
|
if [ -z "$IPv4addr" ]; then
|
||||||
echo "::: Missing static IP address"
|
echo "::: Missing static IP address"
|
||||||
INVALID_STATIC_IPV4_SETTINGS=1
|
INVALID_STATIC_IPV4_SETTINGS=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$IPv4gw" ]; then
|
if [ -z "$IPv4gw" ]; then
|
||||||
echo "::: Missing static IP gateway"
|
echo "::: Missing static IP gateway"
|
||||||
INVALID_STATIC_IPV4_SETTINGS=1
|
INVALID_STATIC_IPV4_SETTINGS=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$INVALID_STATIC_IPV4_SETTINGS" -eq 1 ]; then
|
if [ "$INVALID_STATIC_IPV4_SETTINGS" -eq 1 ]; then
|
||||||
echo "::: Incomplete static IP settings"
|
echo "::: Incomplete static IP settings"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$IPv4addr" ] && [ -z "$IPv4gw" ]; then
|
|
||||||
echo "::: No static IP settings, using current settings"
|
|
||||||
echo "::: Your static IPv4 address: ${IPv4addr}"
|
|
||||||
echo "::: Your static IPv4 gateway: ${IPv4gw}"
|
|
||||||
else
|
|
||||||
if validIP "${IPv4addr%/*}"; then
|
|
||||||
echo "::: Your static IPv4 address: ${IPv4addr}"
|
|
||||||
else
|
|
||||||
echo "::: ${IPv4addr%/*} is not a valid IP address"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if validIP "${IPv4gw}"; then
|
if [ -z "$IPv4addr" ] && [ -z "$IPv4gw" ]; then
|
||||||
|
echo "::: No static IP settings, using current settings"
|
||||||
|
echo "::: Your static IPv4 address: ${IPv4addr}"
|
||||||
echo "::: Your static IPv4 gateway: ${IPv4gw}"
|
echo "::: Your static IPv4 gateway: ${IPv4gw}"
|
||||||
else
|
else
|
||||||
echo "::: ${IPv4gw} is not a valid IP address"
|
if validIP "${IPv4addr%/*}"; then
|
||||||
exit 1
|
echo "::: Your static IPv4 address: ${IPv4addr}"
|
||||||
|
else
|
||||||
|
echo "::: ${IPv4addr%/*} is not a valid IP address"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if validIP "${IPv4gw}"; then
|
||||||
|
echo "::: Your static IPv4 gateway: ${IPv4gw}"
|
||||||
|
else
|
||||||
|
echo "::: ${IPv4gw} is not a valid IP address"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "::: Skipping setting static IP address"
|
||||||
fi
|
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
|
||||||
|
|
Loading…
Reference in a new issue