X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=stage2%2Fbootscripts%2Fifup;h=b36304601669331730f87057fe68ae9c4eead772;hb=e8cc14e96c051666130d201fa5c60291a881e008;hp=7f7d15f246f80383408e69ac49dfd492d7979f0e;hpb=16cc35ba4890382ee9368a176e4f5a7fa773b7a6;p=hvlinux.git diff --git a/stage2/bootscripts/ifup b/stage2/bootscripts/ifup index 7f7d15f..b363046 100755 --- a/stage2/bootscripts/ifup +++ b/stage2/bootscripts/ifup @@ -23,17 +23,54 @@ check_brctl() fi } +# Make sure interface is available +if ! ip link show ${DEVICE} > /dev/null 2>&1; then + echo "Interface ${1} not found" + exit ${EXIT_CODE_WARNING} +fi + # Determining if the interface is a bridge: -if [ "x${BRIDGE}" == "xyes" ]; then +if [ "x${BRIDGE}" = "xyes" ]; then check_brctl - cmd_run_log ${BRCTL} addbr ${1} && - cmd_run_log ${BRCTL} stp ${1} off || exit 1 + cmd_run_log ${BRCTL} addbr ${DEVICE} && + cmd_run_log ${BRCTL} stp ${DEVICE} off || exit 1 fi # Determining if the interface is part of a bridge: if [ -n "${BRIDGE_TO}" ]; then check_brctl - cmd_run_log ${BRCTL} addif ${BRIDGE_TO} ${1} || exit 1 + cmd_run_log ${BRCTL} addif ${BRIDGE_TO} ${DEVICE} || exit 1 +fi + +if [ "x${BOOTPROTO}" = "xwifi" ]; then + # Bring interface up + link_status=$(ip link show ${DEVICE}) + if [ -n "${link_status}" ]; then + if ! echo "${link_status}" | grep -q UP; then + cmd_run_log ip link set ${DEVICE} up + fi + fi + + if [ -f /var/run/wpa_supplicant/${DEVICE} ]; then + echo "Stopping previous wpa_supplicant" + killall wpa_supplicant + rm /var/run/wpa_supplicant/${DEVICE} + fi + + wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlan0 + count=0 + while ! wpa_cli -i wlan0 status | grep "wpa_state=COMPLETED"; do + echo "Waiting for wpa_supplicant to complete" + sleep 1 + + let count=count+1 + if [ $count -gt 10 ]; then + echo "wpa_supplicant failure" + exit ${EXIT_CODE_WARNING} + fi + done + + BOOTPROTO=dhcp fi if [ "x${BOOTPROTO}" = "xdhcp" ]; then @@ -57,6 +94,15 @@ elif [ x${BOOTPROTO} = "xstatic" ]; then # Static configuration cmd_run_log ip addr add ${IPADDR}/${PREFIX_LENGTH} dev ${DEVICE} brd + ${IFSCOPE} && cmd_run_log ip link set ${DEVICE} up + + if [ -n "${GATEWAY}" ]; then + if ip route | grep -q default; then + msg_log "Gateway already setup; skipping." + else + cmd_run_log_box "Adding default route to gateway ${GATEWAY}" \ + ip route add default via ${GATEWAY} dev ${DEVICE} + fi + fi elif [ x${BOOTPROTO} = "xpppoe" ]; then # PPPoE configuration cmd_run_log pppoe-start