mr scripts: dos2unix on some files
[wilink8-wlan/wl18xx-target-scripts.git] / mr / ap_add.sh
1 #!/system/bin/sh
3 if [ "$1" == "" -o "$2" == "" ] ; then 
4         echo "Please insert parameters <IP> <NEW_APUT_CHANNEL> [MAC]" 
5         echo "MAC is optional" 
6         echo "ie: ap_add.sh 10.2.47.6 11 08:00:28:13:33:38" 
7         exit 0 
8 fi
10 INSMOD=/system/bin/insmod
11 IFCONFIG=/system/xbin/busybox/ifconfig
12 HOSTAPD=/system/bin/hostapd
13 IW=/system/bin/iw
14 HOSTAPD_CONF=/data/misc/wifi/hostapd.conf
16 WLAN_IF_SUT=wlan0
17 WLAN_IF_APUT=wlan1
18 WLAN_IP=$1
19 WLAN_NETMASK=255.255.255.0
20 MAC=$3
21 CHANNEL=$2
22 PHY=`ls /sys/class/ieee80211/`
24 SERVICE_SUPPLICANT=wpa_supplicant
25 SERVICE_HOSTAPD=hostapd_bin
27 echo "setting regulatory domain"
28 $IW reg set `grep country_code= $HOSTAPD_CONF | sed "s:country_code=::"`
29 $IW reg get
31 echo "creating new interface"
32 $IW $PHY interface add $WLAN_IF_APUT type managed
33 sleep 1
35 if [ "$MAC" != "" ] ; then
36         echo "setting new mac" 
37         $IFCONFIG $WLAN_IF_APUT hw ether $MAC 
38 fi
40 if [ ! -f $HOSTAPD_CONF ] ; then 
41         cp /etc/wifi/hostapd.conf $HOSTAPD_CONF 
42 fi
43 chmod 777 $HOSTAPD_CONF 
45 sed -i 's/^channel=[0-9,a-z,A-Z,_,$, ,]*/channel='$CHANNEL'/' $HOSTAPD_CONF
47 echo "loading hostapd"
48 setprop ctl.start $SERVICE_HOSTAPD
49 sleep 2
51 echo "enable interface"
52 $IFCONFIG $WLAN_IF_APUT $WLAN_IP netmask $WLAN_NETMASK
53 sleep 1
55 echo "starting dhcp deamon"
56 udhcpd -f dhcpd.conf &