From dc2362c3711b4cf6d732ad943d4b2bc13eecb568 Mon Sep 17 00:00:00 2001 From: Edoardo Maria Elidoro Date: Sun, 3 Nov 2019 22:57:32 +0100 Subject: [PATCH] Added "Reboot into AUTO mode" button in web ui As requested in issue #502 --- pwnagotchi/__init__.py | 11 +++++++++++ pwnagotchi/ui/web.py | 23 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/__init__.py b/pwnagotchi/__init__.py index c0cac85..827f801 100644 --- a/pwnagotchi/__init__.py +++ b/pwnagotchi/__init__.py @@ -112,3 +112,14 @@ def reboot(): logging.warning("rebooting ...") os.system("sync") os.system("shutdown -r now") + + +def reboot_into_auto(): + logging.warning("rebooting into AUTO mode ...") + if view.ROOT: + view.ROOT.on_reboot() + # give it some time to refresh the ui + time.sleep(10) + os.system("touch /root/.pwnagotchi-auto") + os.system("sync") + os.system("shutdown -r now") diff --git a/pwnagotchi/ui/web.py b/pwnagotchi/ui/web.py index 8376ce4..b47601b 100644 --- a/pwnagotchi/ui/web.py +++ b/pwnagotchi/ui/web.py @@ -52,8 +52,11 @@ INDEX = """

-
- + + +
+
+
@@ -73,6 +76,17 @@ SHUTDOWN = """ """ +REBOOT_INTO_AUTO = """ + + %s + + + +
+ Rebooting into AUTO mode ... +
+ +""" class Handler(BaseHTTPRequestHandler): AllowedOrigin = None # CORS headers are not sent @@ -116,6 +130,11 @@ class Handler(BaseHTTPRequestHandler): self._html(SHUTDOWN % pwnagotchi.name()) pwnagotchi.shutdown() + # serve a message and reboot the unit into auto mode + def _reboot(self): + self._html(REBOOT % pwnagotchi.name()) + pwnagotchi.reboot_into_auto() + # serve the PNG file with the display image def _image(self): global frame_lock, frame_path, frame_ctype