Upgrade plugins from webui/plugins page

This commit is contained in:
Jeroen Oudshoorn
2024-01-11 10:55:55 +01:00
parent fdf5dd28f3
commit c650188e1b
2 changed files with 10 additions and 0 deletions

View File

@ -188,6 +188,11 @@ class Handler:
checked = True if 'enabled' in request.form else False checked = True if 'enabled' in request.form else False
return 'success' if plugins.toggle_plugin(request.form['plugin'], checked) else 'failed' return 'success' if plugins.toggle_plugin(request.form['plugin'], checked) else 'failed'
if name == 'upgrade' and request.method == 'POST':
logging.info(f"Upgrading plugin: {request.form['plugin']}")
os.system(f"pwnagotchi plugins update && pwnagotchi plugins upgrade {request.form['plugin']}")
return redirect("/plugins")
if name in plugins.loaded and plugins.loaded[name] is not None and hasattr(plugins.loaded[name], 'on_webhook'): if name in plugins.loaded and plugins.loaded[name] is not None and hasattr(plugins.loaded[name], 'on_webhook'):
try: try:
return plugins.loaded[name].on_webhook(subpath, request) return plugins.loaded[name].on_webhook(subpath, request)

View File

@ -76,6 +76,11 @@ $(function(){
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="plugin" value="{{ name }}"/> <input type="hidden" name="plugin" value="{{ name }}"/>
</form> </form>
<form method="POST" action="/plugins/upgrade">
<input type="submit" name="upgrade" value="Upgrade">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<input type="hidden" name="plugin" value="{{ name }}"/>
</form>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>