/
wifi.sh
executable file
·90 lines (81 loc) · 2.13 KB
/
wifi.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
### BEGIN INIT INFO
# Provides: wifi
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Load MediaTek MT6625L firmware
### END INIT INFO
# Don't exit on error status
set +e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/dev/null
NAME=wifi
DESC="Load MediaTek MT6625L firmware wifi & BT"
#disable kernel-messages
echo 4 > /proc/sys/kernel/printk
#disable printing messages to console
dmesg -D
if [[ ! -e /dev/wmtWifi ]];
then
echo "wifidev does not exist...create it..."
# Check FILE exists and is executable
if [[ -x /usr/bin/wmt_loader ]];
then
# ??
/usr/bin/wmt_loader > /var/log/wmtloader.log
sleep 3
else
echo "Error, unable to find wmt_loader"
fi
# Check FILE exists and is character special
if [[ -c /dev/stpwmt ]];
then
# Load firmware
/usr/bin/stp_uart_launcher -p /etc/firmware > /var/log/stp_launcher.log &
sleep 5
else
echo "Error, device no created, /dev/stpwmt"
fi
fi
# Check FILE exists and is character special
if [[ -c /dev/wmtWifi ]];
then
if [[ -n $(pidof hostapd) ]];
then
echo "hostapd running...kill it";
killall hostapd
fi
if [[ -n $(ip a|grep ap0) ]];
then
echo "ap0 exists, reset it";
echo 0 >/dev/wmtWifi
sleep 5
fi
echo A >/dev/wmtWifi
sleep 2
else
echo "Error, wifi device no created, /dev/wmtWifi"
fi
# Check NIC ap0
#ifconfig ap0
ip addr show ap0
if [[ $? != "0" ]]
then
echo "Error, device no available, ap0"
else
# echo "set MAC"
# ip link set ap0 address 01:02:03:04:05:06 up
echo "Done, all good, ready to lauch hostapd"
hostapd -dd /etc/hostapd/hostapd_ap0.conf > /var/log/hostapd_ap0.log &
echo "set IP"
ip addr add 192.168.10.1/24 dev ap0
echo "restart dnsmasq..."
service dnsmasq restart
#limit speed as suggested in http://wiki.banana-pi.org/Getting_Started_with_R2#WiFi_and_Ap_mode_on_R2_Openwrt
#tc qdisc add dev ap0 root handle 1: htb default 11
#tc class add dev ap0 parent 1:1 classid 1:2 htb rate 8Mbit ceil 4Mbit prio 2
fi
#load bluetooth-driver (has to be done after stp_uart_launcher)
modprobe stp_chrdev_bt