#!/bin/ash source /run/network.conf for i in 1 2 3 4 5 6 7 8; do echo "<$i> Try to fix broken network" echo -n "Take interface $IFACE down .. " ip link set dev "$BRIDGE" down ip link set dev "$IFACE" down usleep 100000 echo "and up again.." ip link set dev "$IFACE" up usleep 100000 wait_for_iface "$IFACE" "$(( 15 + i * 2 ))" retval=$? ip link set dev "$BRIDGE" up if [ "$retval" -eq 0 ] && [ "$i" -ge 4 ] && [ -n "$CLIENTIP" ] && [ -n "$GATEWAY" ]; then echo "....." usleep 100000 echo "Checking if static IP config works...." if ping -c1 -w2 "$GATEWAY" &> /dev/null || ping -c1 -w2 "$SERVERIP" &> /dev/null; then echo "apparently so." echo "Trying to boot without DHCP config (DNS, Hostname, ...), YMMV!" sleep 3 RET=0 break fi echo "...nope..." fi wait_for_iface "$BRIDGE" 10 usleep 100000 udhcpc $PARAM -O ntpsrv -O domain -O search -t "$(( 2 + i / 2 ))" -T "$(( 4 + i ))" -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" \ || udhcpc $PARAM -O ntpsrv -O domain -O search -t "$(( 2 + i / 2 ))" -T "$(( 4 + i ))" -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" RET="$?" if [ "$RET" -eq 0 ]; then echo "Finally fixed IP config. Continue boot." break fi done [ $RET -gt 0 ] && drop_shell "Something is really broken.. Please check your network cable and reset your computer. $(ip a) $(ip r s)" # create correct return value [ $RET -eq 0 ]