summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
authorSebastian2014-01-30 21:22:09 +0100
committerSebastian2014-01-30 21:22:09 +0100
commit62cd5c6a91ebba3ec9874fa620b35c9373c5ec12 (patch)
tree3e4282b7210f372122567a0650ef288702c69b55 /remote
parentMerge branch 'master' of git.openslx.org:openslx-ng/tm-scripts (diff)
downloadtm-scripts-62cd5c6a91ebba3ec9874fa620b35c9373c5ec12.tar.gz
tm-scripts-62cd5c6a91ebba3ec9874fa620b35c9373c5ec12.tar.xz
tm-scripts-62cd5c6a91ebba3ec9874fa620b35c9373c5ec12.zip
[rfs-s31] add network fallback script
Diffstat (limited to 'remote')
-rw-r--r--remote/rootfs/rootfs-stage31/data/inc/network.functions19
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/inc/setup_network28
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/inc/setup_network_retry33
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/init2
4 files changed, 61 insertions, 21 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/inc/network.functions b/remote/rootfs/rootfs-stage31/data/inc/network.functions
new file mode 100644
index 00000000..2b365059
--- /dev/null
+++ b/remote/rootfs/rootfs-stage31/data/inc/network.functions
@@ -0,0 +1,19 @@
+wait_for_iface() {
+ DEVICE=$1
+ echo -n "Waiting for interface $DEVICE: "
+ # Some systems don't have operstate. Seems to be hardware dependent
+ [ ! -e "/sys/class/net/${DEVICE}/operstate" ] && usleep 1000
+ if [ -e "/sys/class/net/${DEVICE}/operstate" ]; then
+ while true; do
+ # check linkstate
+ [ "x$(cat "/sys/class/net/${DEVICE}/operstate")" == "xup" ] && break
+ # else
+ echo -n "."
+ usleep 500000
+ done
+ else
+ # we really don't have a operstate .. then just wait a sec and hope for the best.
+ sleep 1
+ fi
+ echo "."
+}
diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_network b/remote/rootfs/rootfs-stage31/data/inc/setup_network
index b0e6f756..44d05ddf 100755
--- a/remote/rootfs/rootfs-stage31/data/inc/setup_network
+++ b/remote/rootfs/rootfs-stage31/data/inc/setup_network
@@ -4,27 +4,8 @@ echo "Setting up network..."
echo "Main MAC address is '$MAC'"
-wait_for_iface() {
- DEVICE=$1
- echo -n "Waiting for interface $DEVICE: "
- # Some systems don't have operstate. Seems to be hardware dependent
- [ ! -e "/sys/class/net/${DEVICE}/operstate" ] && usleep 1000
- if [ -e "/sys/class/net/${DEVICE}/operstate" ]; then
- while true; do
- # check linkstate
- [ "x$(cat "/sys/class/net/${DEVICE}/operstate")" == "xup" ] && break
- # else
- echo -n "."
- usleep 500000
- done
- else
- # we really don't have a operstate .. then just wait a sec and hope for the best.
- sleep 1
- fi
- echo "."
-}
-
# setup network
+source /inc/network.functions
# set up loopback networking
echo "Setting up loopback"
@@ -97,5 +78,12 @@ if [ -n "$CLIENTIP" ]; then
fi
echo -n "$CLIENTIP" > "/run/firstip"
echo -n "$GATEWAY" > "/run/firstgw"
+
+# save variables for retry script
+echo "CLIENTIP=$CLIENTIP" > /run/network.conf
+echo "GATEWAY=$GATEWAY" >> /run/network.conf
+echo "IFACE=$IFACE" >> /run/network.conf
+echo "BRIDGE=$BRIDGE" >> /run/network.conf
+
udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE"
diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_network_retry b/remote/rootfs/rootfs-stage31/data/inc/setup_network_retry
new file mode 100755
index 00000000..9693fbf5
--- /dev/null
+++ b/remote/rootfs/rootfs-stage31/data/inc/setup_network_retry
@@ -0,0 +1,33 @@
+#!/bin/ash
+
+source /inc/network.functions
+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 and up again.."
+
+ ip link set dev $IFACE down
+ usleep 1000
+
+ echo "and up again.."
+ ip link set dev $IFACE up
+ usleep 1000
+
+ wait_for_iface "$IFACE"
+
+ udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE"
+
+ if [ $? -eq 0 ]; then
+ echo "Finally fixed IP config. Continue boot."
+ RET=0
+ break
+ else
+ RET=1
+ fi
+done
+
+[ $RET -gt 0 ] && echo "Something is really broken.. Please check your network cable and reset your computer."
+
+# create correct return value
+[ $RET -eq 0 ]
diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init
index 714b22ac..957dbc61 100755
--- a/remote/rootfs/rootfs-stage31/data/init
+++ b/remote/rootfs/rootfs-stage31/data/init
@@ -87,7 +87,7 @@ fi
[ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: before network."
-. "/inc/setup_network" || drop_shell "Error setting up network"
+. "/inc/setup_network" || . "/inc/setup_network_retry" || drop_shell "Error setting up network"
[ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: after network/before configuring."