X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=stage2%2Fbootscripts%2Fifup;h=6af859a6d3ff9c1f9149309cff377ee2e6cb3cd0;hb=39a19cacbb9a44c5ceadd254463ea87c588a82a3;hp=e31fd43372112302cb78c921a1aae40e99bba01e;hpb=e352b98ed255880460f137cd2304602c51e74f38;p=hvlinux.git diff --git a/stage2/bootscripts/ifup b/stage2/bootscripts/ifup index e31fd43..6af859a 100755 --- a/stage2/bootscripts/ifup +++ b/stage2/bootscripts/ifup @@ -31,6 +31,25 @@ bring_if_up() if ! echo "${link_status}" | grep -q UP; then cmd_run_log ip link set ${DEVICE} up fi + else + echo "Interface ${DEVICE} not found" + exit ${EXIT_CODE_WARNING} + fi + + # Check if a cable is plugged for wired interface + if echo "${DEVICE}" | grep -q "eth" ; then + count=0 + while cat /sys/class/net/${DEVICE}/carrier | grep -q "0"; do + echo "Waiting for carrier to go up" + sleep 0.25 + + let count=count+1 + # 2.5 seconds delay + if [ $count -gt 10 ]; then + echo "Interface ${DEVICE}: carrier not detected (cable unplugged?)" + exit ${EXIT_CODE_WARNING} + fi + done fi } @@ -44,7 +63,7 @@ proto_static() if ip route | grep -q default; then msg_log "Gateway already setup; skipping." else - cmd_run_log_box "Adding default route to gateway ${GATEWAY}" \ + cmd_run_log_box "Adding default route to gateway ${GATEWAY} via ${DEVICE}" \ ip route add default via ${GATEWAY} dev ${DEVICE} fi fi @@ -53,6 +72,8 @@ proto_static() # Obtain IP address from DHCP proto_dhcp() { + bring_if_up + # Load DHCP client parameters source /etc/sysconfig/network/dhcp-client @@ -104,10 +125,10 @@ proto_wireless() count=0 while ! wpa_cli -i ${DEVICE} status | grep "wpa_state=COMPLETED"; do echo "Waiting for wpa_supplicant to complete" - sleep 1 + sleep 0.25 let count=count+1 - if [ $count -gt 10 ]; then + if [ $count -gt 20 ]; then echo "wpa_supplicant failure" exit ${EXIT_CODE_WARNING} fi @@ -115,8 +136,8 @@ proto_wireless() } # Make sure interface is available -if ! ip link show ${DEVICE} > /dev/null 2>&1; then - echo "Interface ${1} not found" +if [ ! -d /sys/class/net/${DEVICE} ]; then + echo "Interface ${DEVICE} not found" exit ${EXIT_CODE_WARNING} fi