diff --git a/lib/ap/airbase-ng.sh b/lib/ap/airbase-ng.sh index 6b7b6bf..b49cd2e 100644 --- a/lib/ap/airbase-ng.sh +++ b/lib/ap/airbase-ng.sh @@ -10,10 +10,6 @@ VIAP=$WIAccessPoint # and creates a separate interface, atX, for dhcpd. VIAPAddress="$VIGWNetwork.2" -VIAPRouteDelay=5 - -#APServiceConfPath="$FLUXIONWorkspacePath/APService.conf" - function ap_stop() { killall airbase-ng &> $FLUXIONOutputDevice @@ -41,7 +37,13 @@ function ap_prep() { function ap_start() { xterm $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [airbase-ng]" -e airbase-ng -P -e $APTargetSSID -c $APTargetChannel -a $APRogueMAC $VIAP & - sleep $VIAPRouteDelay; ap_route + + # Wait till airebase-ng has started and created the extra virtual interface. + while [ ! $(ps a | awk '$5~/^airbase-ng/ && $0~/'"$APRogueMAC"'/{print $1}') ] + do sleep 1 + done + + ap_route } # FLUXSCRIPT END diff --git a/lib/ap/hostapd.sh b/lib/ap/hostapd.sh index fd1aa07..49791e1 100644 --- a/lib/ap/hostapd.sh +++ b/lib/ap/hostapd.sh @@ -10,10 +10,6 @@ VIAP=$WIAccessPoint # to master, which is supported by dhcpd. VIAPAddress=$VIGWAddress -VIAPRouteDelay=5 - -APServiceConfPath="$FLUXIONWorkspacePath/APService.conf" - function ap_stop() { killall hostapd &> $FLUXIONOutputDevice @@ -50,7 +46,7 @@ interface=$VIAP driver=nl80211 ssid=$APTargetSSID channel=$APTargetChannel\ -" > "$APServiceConfPath" +" > "$APRogueMAC-hostapd.conf" # Spoof virtual interface MAC address. ifconfig $VIAP down @@ -64,8 +60,14 @@ channel=$APTargetChannel\ } function ap_start() { - xterm $HOLD $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APServiceConfPath" & - sleep $VIAPRouteDelay; ap_route + xterm $HOLD $BOTTOMRIGHT -bg "#000000" -fg "#FFFFFF" -title "FLUXION AP Service [hostapd]" -e hostapd "$APRogueMAC-hostapd.conf" & + + # Wait till hostapd has started and its virtual interface is ready. + while [ ! $(ps a | awk '$5~/^hostapd/ && $0~/'"$APRogueMAC-hostapd.conf"'/{print $1}') ] + do sleep 1 + done + + ap_route } # FLUXSCRIPT END