forked from radxa/rkwifibt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
S67wifi
executable file
·51 lines (50 loc) · 1.24 KB
/
S67wifi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# Start/stop wifi
#
case "$1" in
start)
CONFIG=/userdata/cfg/wpa_supplicant.conf
echo "Starting wifi, checking driver status..."
[ -x /usr/bin/wifi_start.sh ] || exit 0
[ -f $CONFIG ] || exit 0
WIFI_READY=`cat /proc/net/dev | grep wlan0`
while [ -z "$WIFI_READY" ]
do
sleep 1
WIFI_READY=`cat /proc/net/dev | grep wlan0`
#echo "wifi ready: $WIFI_READY"
CNT=`expr $CNT + 1`
if [ $CNT -gt 100 ];then
echo "wifi driver is not ready. please check if /etc/init.d/S36load_wifi_modules run correctly. then run /etc/init.d/S67wifi start"
exit 0
fi
done
echo "wifi driver is ready"
SSID=`grep ssid /userdata/cfg/wpa_supplicant.conf | cut -d '"' -f 2`
PWD=`grep psk /userdata/cfg/wpa_supplicant.conf | cut -d '"' -f 2`
if [ x$SSID = xSSID ];then
echo "ssid in /userdata/cfg/wpa_supplicant.conf not valid"
exit 0
fi
if [ x$PWD = xPWD ];then
echo "passwd in /userdata/cfg/wpa_supplicant.conf not valid"
exit 0
fi
wifi_start.sh $SSID $PWD
;;
stop)
echo "Stopping wifi..."
;;
reload|force-reload)
echo "Reloading reload wifi..."
;;
restart)
"$0" stop
sleep 1 # Prevent race condition: ensure dhcpcd stops before start.
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
esac