initrds: ifup: Move NETRETRIES handling to "dhcp" code path

This variable is only required and used for dynamic network configs:
validating and configuring it for rest of the paths isn't necessary.

While there split warning message to two lines to make code and
runtime output more readable.

Signed-off-by: Sergey Popovich <sergey.popovich@ordnance.co>
This commit is contained in:
Sergey Popovich
2018-08-06 09:26:25 +03:00
parent cdad662745
commit e2c1fcc335

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 "**********************************************************************"