Skip to content

Commit

Permalink
Merge pull request #671 from Evg33/reboot
Browse files Browse the repository at this point in the history
feature/plugin/web/reboot
  • Loading branch information
evilsocket authored Nov 29, 2019
2 parents ad51042 + 855bda9 commit b8eed4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pwnagotchi/ui/web/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, config, agent, app):
self._app.add_url_rule('/ui', 'ui', self.with_auth(self.ui))

self._app.add_url_rule('/shutdown', 'shutdown', self.with_auth(self.shutdown), methods=['POST'])
self._app.add_url_rule('/reboot', 'reboot', self.with_auth(self.reboot), methods=['POST'])
self._app.add_url_rule('/restart', 'restart', self.with_auth(self.restart), methods=['POST'])

# inbox
Expand Down Expand Up @@ -201,6 +202,14 @@ def shutdown(self):
finally:
_thread.start_new_thread(pwnagotchi.shutdown, ())

# serve a message and reboot the unit
def reboot(self):
try:
return render_template('status.html', title=pwnagotchi.name(), go_back_after=60,
message='Rebooting ...')
finally:
_thread.start_new_thread(pwnagotchi.reboot, ())

# serve a message and restart the unit in the other mode
def restart(self):
mode = request.form['mode']
Expand Down
7 changes: 7 additions & 0 deletions pwnagotchi/ui/web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
</form>
</li>
<li>
<form class="action" method="post" action="/reboot"
onsubmit="return confirm('this will reboot the unit, continue?');">
<input type="submit" class="button ui-btn ui-corner-all" value="Reboot"/>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
</form>
</li>
<li>
<form class="action" method="post" action="/restart"
onsubmit="return confirm('This will restart the service in {{ other_mode }} mode, continue?');">
Expand Down

0 comments on commit b8eed4f

Please sign in to comment.