initial
[wilink8-wlan/wl18xx-target-scripts.git] / ap / ap_start.sh
1 #!/system/bin/sh
3 INSMOD=/system/bin/insmod
4 IFCONFIG=/system/bin/ifconfig
5 HOSTAPD=/system/bin/hostapd
6 IW=/system/bin/iw
7 HOSTAPD_CONF=/data/misc/wifi/hostapd.conf
9 WLAN_IF=wlan1
10 WLAN_IP=192.168.43.1
11 WLAN_NETMASK=255.255.255.0
13 SERVICE_SUPPLICANT=wpa_supplicant
14 SERVICE_HOSTAPD=hostapd_bin
16 SUPP_STAT=`getprop init.svc.$SERVICE_SUPPLICANT`
17 echo "wpa_supplicant state: $SUPP_STAT"
18 if [ "$SUPP_STAT" == "running" ] ; then echo "supplicant is in running state, exiting..." ; exit 0 ; fi
20 HOSTAPD_STAT=`getprop init.svc.$SERVICE_HOSTAPD`
21 echo "hostapd state: $HOSTAPD_STAT"
22 if [ "$HOSTAPD_STAT" == "running" ] ; then echo "hostapd is in running state, exiting..." ; exit 0 ; fi
24 echo "loading driver"
25 $INSMOD /system/lib/modules/wl12xx_sdio.ko
26 sleep 1
28 echo "setting regulatory domain"
29 $IW reg set `grep country_code= /data/misc/wifi/hostapd.conf | sed "s:country_code=::"`
30 $IW reg get
32 echo "creating new interface"
33 $IW wlan0 del
34 $IW `ls /sys/class/ieee80211/` interface add wlan1 type managed
36 if [ ! -f $HOSTAPD_CONF ] ; then \
37         cp /etc/wifi/hostapd.conf $HOSTAPD_CONF ; \
38 fi
39 chmod 777 $HOSTAPD_CONF
41 echo "loading hostapd"
42 setprop ctl.start $SERVICE_HOSTAPD
43 sleep 2
45 echo "enable interface"
46 $IFCONFIG $WLAN_IF up $WLAN_IP netmask $WLAN_NETMASK
47 sleep 1
48 $IFCONFIG $WLAN_IF
49 sleep 2
51 echo "starting dhcp deamon"
52 udhcpd -f dhcpd.conf &