Merge pull request #512 from edmael/web_reboot

Added "Reboot into AUTO mode" button in web ui
This commit is contained in:
evilsocket 2019-11-04 11:07:22 +01:00 committed by GitHub
commit 59019efad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View File

@ -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")

View File

@ -52,8 +52,11 @@ INDEX = """<html>
<img src="/ui" id="ui" style="width:100%%;image-rendering: pixelated;"/>
<br/>
<hr/>
<form method="POST" action="/shutdown" onsubmit="return confirm('This will halt the unit, continue?');">
<input type="submit" class="block" value="Shutdown"/>
<form style="display:inline;" method="POST" action="/shutdown" onsubmit="return confirm('This will halt the unit, continue?');">
<input style="display:inline;" type="submit" class="block" value="Shutdown"/>
</form>
<form style="display:inline;" method="POST" action="/reboot_into_auto" onsubmit="return confirm('This will reboot the unit into AUTO mode, continue?');">
<input style="display:inline;" type="submit" class="block" value="Reboot into AUTO mode"/>
</form>
</div>
@ -73,6 +76,17 @@ SHUTDOWN = """<html>
</body>
</html>"""
REBOOT_INTO_AUTO = """<html>
<head>
<title>%s</title>
<style>""" + STYLE + """</style>
</head>
<body>
<div style="position: absolute; top:0; left:0; width:100%%;">
Rebooting into AUTO mode ...
</div>
</body>
</html>"""
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