|
|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
import os
|
|
|
import sys
|
|
|
-from bootstrap_captive.install import com_install
|
|
|
+from bootstrap_captive.install import com_install,com_unpack
|
|
|
from bootstrap_captive.wificonfig import set_wifi
|
|
|
realp = os.path.realpath(os.path.dirname(__file__))
|
|
|
|
|
|
@@ -24,18 +24,37 @@ def parser():
|
|
|
p_server.add_argument("-p", "--port", type=int, default=80)
|
|
|
p_server.add_argument("-s", "--ssl_port", type=int, default=443)
|
|
|
p_server.add_argument("-n", "--portal_name", default="portal.raspi.tsimnet.eu")
|
|
|
+
|
|
|
+ p_unpack = sub.add_parser("unpack")
|
|
|
+ p_unpack.set_defaults(func=com_unpack)
|
|
|
+ p_unpack.add_argument("-i", "--install_dir", default="/opt/eu.tsimnet.git/dasimmet/bootstrap_captive")
|
|
|
+
|
|
|
+ p_autostart = sub.add_parser("autostart")
|
|
|
+ p_autostart.set_defaults(func=com_autostart)
|
|
|
+ p_autostart.add_argument("-i", "--install_dir", default="/opt/eu.tsimnet.git/dasimmet/bootstrap_captive")
|
|
|
+
|
|
|
p_install = sub.add_parser("install")
|
|
|
p_install.set_defaults(func=com_install)
|
|
|
p_install.add_argument("-i", "--install_dir", default="/opt/eu.tsimnet.git/dasimmet/bootstrap_captive")
|
|
|
- p_install.add_argument("-r", "--remove_installer", action="store_true")
|
|
|
- p_install.add_argument("-e", "--enable", action="store_true")
|
|
|
- p_enable = sub.add_parser("enable")
|
|
|
- p_enable.set_defaults(func=com_enable)
|
|
|
- p_enable = sub.add_parser("disable")
|
|
|
- p_enable.set_defaults(func=com_disable)
|
|
|
+
|
|
|
+ p_start = sub.add_parser("start")
|
|
|
+ p_start.set_defaults(func=com_start)
|
|
|
+
|
|
|
+ p_stop = sub.add_parser("stop")
|
|
|
+ p_stop.set_defaults(func=com_stop)
|
|
|
return p
|
|
|
|
|
|
-def com_enable(args):
|
|
|
+def com_autostart(args):
|
|
|
+ com_install(args)
|
|
|
+ with open("/etc/cron.d/42-bootstrap_captive", "w") as fd:
|
|
|
+ fd.write('''
|
|
|
+@reboot /usr/local/bin/bootstrap_captive autostart
|
|
|
+''')
|
|
|
+ from bootstrap_captive.gpio import switch
|
|
|
+ if switch(args):
|
|
|
+ com_start(args)
|
|
|
+
|
|
|
+def com_start(args):
|
|
|
from subprocess import run
|
|
|
set_wifi(True)
|
|
|
COM="""
|
|
|
@@ -51,7 +70,7 @@ iptables -t nat -A PREROUTING -d 0/0 -p tcp --dport 80 -j DNAT --to-destination
|
|
|
"""
|
|
|
run(COM, shell=True)
|
|
|
|
|
|
-def com_disable(args):
|
|
|
+def com_stop(args):
|
|
|
from subprocess import run
|
|
|
set_wifi(False)
|
|
|
COM="""
|