Merge pull request #428 from OrdnanceNetworks/onl-fixes

Assorted set of fixes and improvements to ONL
This commit is contained in:
Jeffrey Townsend
2018-10-09 12:35:38 -07:00
committed by GitHub
5 changed files with 25 additions and 11 deletions

View File

@@ -8,6 +8,8 @@
- python
- apt
- apt-utils
- debconf
- dialog
- procps
- net-tools
- iputils-ping

View File

@@ -8,6 +8,8 @@
- python
- apt
- apt-utils
- debconf
- dialog
- procps
- net-tools
- iputils-ping

View File

@@ -7,6 +7,8 @@
- python
- apt
- apt-utils
- debconf
- dialog
- procps
- net-tools
- iputils-ping

View File

@@ -44,18 +44,21 @@ if [ "${NETHW}" ]; then
ip link set dev ${NETDEV} addr ${NETHW}
fi
# Default DHCP timeout is 10 requests in 10 seconds.
NETRETRIES_DEFAULT=10
NETRETRIES=${NETRETRIES:-$NETRETRIES_DEFAULT}
if [ "$NETRETRIES" = "infinite" ]; then
NETRETRIES=
elif [ $(echo "$NETRETRIES" | tr -d '[:digit:]') ] || [ "$NETRETRIES" -lt 0 ]; then
echo "Warning: the NETRETRIES setting is currently '$NETRETRIES'. This is invalid and the default value of $NETRETRIES_DEFAULT will be used instead."
NETRETRIES=$NETRETRIES_DEFAULT
fi
case "${NETAUTO}" in
dhcp|auto)
# Default DHCP timeout is 10 requests in 10 seconds.
NETRETRIES_DEFAULT=10
NETRETRIES=${NETRETRIES:-$NETRETRIES_DEFAULT}
if [ "$NETRETRIES" = "infinite" ]; then
NETRETRIES=
elif [ $(echo "$NETRETRIES" | tr -d '[:digit:]') ] || [ "$NETRETRIES" -lt 0 ]; then
echo "Warning: the NETRETRIES setting is currently '$NETRETRIES'."
echo "This is invalid and the default value of $NETRETRIES_DEFAULT will be used instead."
NETRETRIES=$NETRETRIES_DEFAULT
fi
echo 1 >/proc/sys/net/ipv6/conf/${NETDEV}/autoconf
if [ -n "${NETRETRIES}" ]; then
if ! udhcpc --retries $NETRETRIES --now -i ${NETDEV}; then
echo "**********************************************************************"
@@ -81,6 +84,9 @@ case "${NETAUTO}" in
up)
ifconfig "${NETDEV}" up
;;
none)
exit 0
;;
*)
if [ "${NETIP}" ] && [ "${NETMASK}" ] && [ "${NETIP#*/}" = "${NETIP}" ]; then
NETIP=${NETIP}/$(ipcalc -p -s ${NETIP} ${NETMASK} | sed -n 's/PREFIX=//p')
@@ -118,6 +124,7 @@ for i in $(seq 30); do
fi
sleep 1
done
wait_link_up()
{
local intf=$1
@@ -144,4 +151,5 @@ wait_link_up()
if [ -n "${NETAUTO}" ]; then
wait_link_up $NETDEV 100
fi
return 0
exit 0

View File

@@ -191,7 +191,7 @@ class OnlBootConfigNet(OnlBootConfig):
if not self.is_ip_address(netdns):
raise ValueError("NETDNS=%s is not a valid ip-address" % (netdns))
elif self.keys['NETAUTO'] not in ['dhcp', 'up']:
elif self.keys['NETAUTO'] not in ['dhcp', 'up', 'none', '']:
raise ValueError("The NETAUTO value '%s' is invalid." % self.keys['NETAUTO'])
elif self.keys['NETAUTO'] == 'up' and self.NET_REQUIRED:
raise ValueError("NETAUTO is 'up' but non-local networking is required.")