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 [ ! -d /sys/class/net/${DEVICE}/wireless ]; 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
}
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
# Obtain IP address from DHCP
proto_dhcp()
{
+ bring_if_up
+
# Load DHCP client parameters
source /etc/sysconfig/network/dhcp-client
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
}
# 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