mr scripts v1
[wilink8-wlan/wl18xx-target-scripts.git] / mr / ap_add.sh
old mode 100644 (file)
new mode 100755 (executable)
index 2a5f031..3b7547b
@@ -1,66 +1,56 @@
-#!/system/bin/sh
-
-INSMOD=/system/bin/insmod
-IFCONFIG=/system/bin/ifconfig
-HOSTAPD=/system/bin/hostapd
-IW=/system/bin/iw
-HOSTAPD_CONF=/data/misc/wifi/hostapd.conf
-
-if [ "$1"=="" -a "$2"=="" ]; then
-echo "please give MAC and desired MAC address - exiting ..." ; exit 1; fi
-
-WLAN1_MAC=$1
-STA_CHANNEL=$2
-WLAN_IF=wlan1
-WLAN_IP=192.168.43.1
-WLAN_NETMASK=255.255.255.0
-
-SERVICE_SUPPLICANT=wpa_supplicant
-SERVICE_HOSTAPD=hostapd_bin
-
-SUPP_STAT=`getprop init.svc.$SERVICE_SUPPLICANT`
-echo "wpa_supplicant state: $SUPP_STAT"
-
-HOSTAPD_STAT=`getprop init.svc.$SERVICE_HOSTAPD`
-echo "hostapd state: $HOSTAPD_STAT"
-if [ "$HOSTAPD_STAT" == "running" ] ; then echo "hostapd is in running state, exiting..." ; exit 0 ; fi
-
-
-sleep 1
-iw wlan0 set power_save off
-
-echo "creating new interface"
-$IW `ls /sys/class/ieee80211/` interface add wlan1 type managed
-ifconfig wlan1 hw ether $WLAN1_MAC
-
-if [ ! -f $HOSTAPD_CONF ] ; then \
-       cp /etc/wifi/hostapd.conf $HOSTAPD_CONF ; \
-       chmod 777 $HOSTAPD_CONF ; \
-fi
-
-echo "loading hostapd"
-echo "setting the correct channel"
-sed s/channel=[0-9]*/channel=$STA_CHANNEL/ $HOSTAPD_CONF > /data/misc/wifi/tmp.conf
-mv -f /data/misc/wifi/tmp.conf $HOSTAPD_CONF
-
-sleep 1
-setprop ctl.start $SERVICE_HOSTAPD
-sleep 2
-
-echo "enable interface"
-$IFCONFIG $WLAN_IF up $WLAN_IP netmask $WLAN_NETMASK
-sleep 1
-$IFCONFIG $WLAN_IF
-sleep 2
-
-echo "starting dhcp deamon"
-udhcpd -f dhcpd.conf &
-
-
-
-
-
-
-
-
-
+#!/system/bin/sh\r
+\r
+if [ "$1" == "" -o "$2" == "" ] ; then \r
+       echo "Please insert parameters <IP> <NEW_APUT_CHANNEL> [MAC]" \r
+       echo "MAC is optional" \r
+       echo "ie: ap_add.sh 10.2.47.6 11 08:00:28:13:33:38" \r
+       exit 0 \r
+fi\r
+\r
+INSMOD=/system/bin/insmod\r
+IFCONFIG=/system/xbin/busybox/ifconfig\r
+HOSTAPD=/system/bin/hostapd\r
+IW=/system/bin/iw\r
+HOSTAPD_CONF=/data/misc/wifi/hostapd.conf\r
+\r
+WLAN_IF_SUT=wlan0\r
+WLAN_IF_APUT=wlan1\r
+WLAN_IP=$1\r
+WLAN_NETMASK=255.255.255.0\r
+MAC=$3\r
+CHANNEL=$2\r
+PHY=`ls /sys/class/ieee80211/`\r
+\r
+SERVICE_SUPPLICANT=wpa_supplicant\r
+SERVICE_HOSTAPD=hostapd_bin\r
+\r
+echo "setting regulatory domain"\r
+$IW reg set `grep country_code= $HOSTAPD_CONF | sed "s:country_code=::"`\r
+$IW reg get\r
+\r
+echo "creating new interface"\r
+$IW $PHY interface add $WLAN_IF_APUT type managed\r
+sleep 1\r
+\r
+if [ "$MAC" != "" ] ; then\r
+       echo "setting new mac" \r
+       $IFCONFIG $WLAN_IF_APUT hw ether $MAC \r
+fi\r
+\r
+if [ ! -f $HOSTAPD_CONF ] ; then \r
+       cp /etc/wifi/hostapd.conf $HOSTAPD_CONF \r
+fi\r
+chmod 777 $HOSTAPD_CONF \r
+\r
+sed -i 's/^channel=[0-9,a-z,A-Z,_,$, ,]*/channel='$CHANNEL'/' $HOSTAPD_CONF\r
+\r
+echo "loading hostapd"\r
+setprop ctl.start $SERVICE_HOSTAPD\r
+sleep 2\r
+\r
+echo "enable interface"\r
+$IFCONFIG $WLAN_IF_APUT $WLAN_IP netmask $WLAN_NETMASK\r
+sleep 1\r
+\r
+echo "starting dhcp deamon"\r
+udhcpd -f dhcpd.conf &\r