Would be even better with the script actually attached...
--
Florent
#! /bin/bash
interfaces="eth0 eth1"
max_attempts=15
exit_status=1
for attempt in $(seq 1 $max_attempts); do
all_intf_ok=1
for intf in $interfaces; do
ifconfig $intf | grep >/dev/null "^[[:space:]]*inet addr:" \
|| { all_intf_ok=0; break; }
done
[ $all_intf_ok -eq 1 ] && { exit_status=0; break; }
echo "Ethernet interfaces not properly initialized." \
"Trying to fix that (attempt $attempt)..."
n=$(echo "($RANDOM % 3) + 2" | bc)
for i in $(seq 1 $n); do
modprobe -r r8169; modprobe r8169
done
ifdown -a "$@"
ifup -a "$@"
done
exit $exit_status