mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
@ -4,7 +4,10 @@ import _thread
|
||||
import threading
|
||||
import importlib, importlib.util
|
||||
import logging
|
||||
import pwnagotchi
|
||||
from pwnagotchi.ui import view
|
||||
from pwnagotchi.utils import save_config
|
||||
|
||||
|
||||
default_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default")
|
||||
loaded = {}
|
||||
@ -37,10 +40,16 @@ def toggle_plugin(name, enable=True):
|
||||
returns True if changed, otherwise False
|
||||
"""
|
||||
global loaded, database
|
||||
|
||||
if pwnagotchi.config:
|
||||
pwnagotchi.config['main']['plugins'][name]['enabled'] = enable
|
||||
save_config(pwnagotchi.config, '/etc/pwnagotchi/config.toml')
|
||||
|
||||
if not enable and name in loaded:
|
||||
if getattr(loaded[name], 'on_unload', None):
|
||||
loaded[name].on_unload(view.ROOT)
|
||||
del loaded[name]
|
||||
|
||||
return True
|
||||
|
||||
if enable and name in database and name not in loaded:
|
||||
|
@ -2,8 +2,8 @@ import logging
|
||||
import json
|
||||
import toml
|
||||
import _thread
|
||||
import pwnagotchi.plugins as plugins
|
||||
from pwnagotchi import restart
|
||||
from pwnagotchi import restart, plugins
|
||||
from pwnagotchi.utils import save_config
|
||||
from flask import abort
|
||||
from flask import render_template_string
|
||||
|
||||
@ -499,13 +499,10 @@ class WebConfig(plugins.Plugin):
|
||||
elif request.method == "POST":
|
||||
if path == "save-config":
|
||||
try:
|
||||
parsed_toml = toml.loads(request.get_json())
|
||||
with open('/etc/pwnagotchi/config.toml') as config_file:
|
||||
toml.dump(parsed_toml, config_file)
|
||||
|
||||
save_config(request.get_json(), '/etc/pwnagotchi/config.toml') # test
|
||||
_thread.start_new_thread(restart, (self.mode,))
|
||||
return "success"
|
||||
except Exception as ex:
|
||||
logging.error(ex)
|
||||
return "config error"
|
||||
return "config error", 500
|
||||
abort(404)
|
||||
|
Reference in New Issue
Block a user