forked from adangert/JoustMania
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenable_ap.sh
executable file
·75 lines (50 loc) · 2.07 KB
/
enable_ap.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
#!/bin/bash
#following the guide here: https://github.com/peebles/rpi3-wifi-station-ap-stretch
if [ $UID -ne 0 ]; then
echo "Not root. Using sudo."
exec sudo $0
fi
if [ -f ./apfiles/ap_active ]
then echo "Script already run"
exit
fi
touch ./apfiles/ap_active
apt-get install -y hostapd dnsmasq
#cp ./apfiles/ap /etc/network/interfaces.d/ap
#cp ./apfiles/station /etc/network/interfaces.d/station
#cp ./apfiles/90-wireless.rules /etc/udev/rules.d/90-wireless.rules
#mv /lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant /lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant.bak
#cp ./apfiles/10-wpa_supplicant /lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
cp ./apfiles/dnsmasq.conf /etc/dnsmasq.conf
mv /etc/hostapd/hostapd.conf /etc/hostapd/hostapd.conf.bak
cp ./apfiles/hostapd.conf /etc/hostapd/hostapd.conf
mv /etc/default/hostapd /etc/default/hostapd.bak
cp ./apfiles/hostapd /etc/default/hostapd
#for testing
mv /etc/dhcpcd.conf /etc/dhcpcd.conf.bak
cp ./apfiles/dhcpcd.conf /etc/dhcpcd.conf
chown :pi /etc/dhcpcd.conf
#mv /etc/network/interfaces /etc/network/interfaces.bak
#cp ./apfiles/interfaces /etc/network/interfaces
#sudo service dhcpcd restart
#ifdown wlan0; ifup wlan0
mv /etc/sysctl.conf /etc/sysctl.conf.bak
cp ./apfiles/sysctl.conf /etc/sysctl.conf
#updates for allowing joustmania to work
#echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
#echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 10.3.141.0/24 ! -d 10.3.141.0/24 -j MASQUERADE
#iptables-save > /etc/iptables/rules.v4
#sh -c "iptables-save > /etc/iptables.ipv4.nat"
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
#iptables -A FORWARD -i eth0 -o uap0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
#iptables -A FORWARD -i uap0 -o eth0 -j ACCEPT
sh -c "iptables-save > /etc/iptables.ipv4.nat"
mv /etc/rc.local /etc/rc.local.bak
cp ./apfiles/rc.local /etc/rc.local
#update-rc.d hostapd enable
#update-rc.d dnsmasq enable
reboot