|
|
@@ -56,28 +56,40 @@ def com_start(args):
|
|
|
from subprocess import run
|
|
|
set_wifi(True)
|
|
|
COM="""
|
|
|
+echo "STARTING"
|
|
|
+date
|
|
|
set -x
|
|
|
-systemctl stop networking dhcpcd
|
|
|
-sleep 3
|
|
|
-systemctl start hostapd.service
|
|
|
-sleep 2
|
|
|
-systemctl start networking dnsmasq.service bootstrap_captive@server.service dhcpcd
|
|
|
+systemctl stop networking dhcpcd.service wpa_supplicant.service
|
|
|
+ip addr flush wlan0
|
|
|
iptables -t nat -A PREROUTING -d 192.168.5.2 -j ACCEPT
|
|
|
iptables -t nat -A PREROUTING -d 0/0 -p tcp --dport 80 -j DNAT --to-destination 192.168.5.1:80
|
|
|
+sleep 3
|
|
|
+systemctl start hostapd.service
|
|
|
+while ! systemctl is-active dnsmasq.service;
|
|
|
+do
|
|
|
+ systemctl start networking dnsmasq.service bootstrap_captive@server.service dhcpcd;
|
|
|
+ sleep 1
|
|
|
+done
|
|
|
"""
|
|
|
- run(COM, shell=True)
|
|
|
+ with open("/var/log/bootstrap_captive.log", "a") as fd:
|
|
|
+ run(COM, shell=True, stdout=fd, stderr=fd)
|
|
|
|
|
|
def com_stop(args):
|
|
|
from subprocess import run
|
|
|
set_wifi(False)
|
|
|
COM="""
|
|
|
+echo "STOPPING"
|
|
|
+date
|
|
|
+set -x
|
|
|
iptables -F -t nat
|
|
|
-systemctl stop bootstrap_captive@server.service hostapd.service dnsmasq.service
|
|
|
+systemctl stop networking hostapd.service dnsmasq.service dhcpcd.service wpa_suplicant.service
|
|
|
ip addr flush wlan0
|
|
|
-sleep 3
|
|
|
-systemctl restart networking dhcpcd
|
|
|
+sleep 5
|
|
|
+systemctl restart networking dhcpcd.service wpa_supplicant.service;
|
|
|
+systemctl stop bootstrap_captive@server.service
|
|
|
"""
|
|
|
- run(COM, shell=True)
|
|
|
+ with open("/var/log/bootstrap_captive.log", "a") as fd:
|
|
|
+ run(COM, shell=True, stdout=fd, stderr=fd)
|
|
|
|
|
|
def com_server(args):
|
|
|
from bootstrap_captive.server import server
|