-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccess_point_setup.py
39 lines (29 loc) · 1.15 KB
/
access_point_setup.py
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
import subprocess
def subprocess_run(cmd):
p = subprocess.Popen(cmd, shell=True)
p.wait()
return p.returncode
print(subprocess_run("apt-get update -y"))
print(subprocess_run("apt-get upgrade -y"))
print(subprocess_run("apt-get install rfkill hostapd hostap-utils iw dnsmasq bridge-utils -y"))
with open("files/wifi_wap/etc_network_interfaces.txt", "r") as r:
with open("/etc/network/interfaces", "w") as w:
for line in r:
w.write(line)
with open("files/wifi_wap/etc_hostapd_hostapd_conf.txt", "r") as r:
with open("/etc/hostapd/hostapd.conf", "w") as w:
for line in r:
w.write(line)
with open("files/wifi_wap/hostapd_wap.txt", "r") as r:
with open("/etc/default/hostapd", "w") as w:
for line in r:
w.write(line)
with open("files/wifi_wap/dnsmasq_conf_wap.txt", "r") as r:
with open("/etc/dnsmasq.conf", "w") as w:
for line in r:
w.write(line)
print(subprocess_run("service networking restart"))
print(subprocess_run("service hostapd restart"))
print(subprocess_run("service dnsmasq restart"))
print(subprocess_run("sleep 5"))
print(subprocess_run("reboot"))