- Unfortunately, we got some issues.
+ Unfortunately, we got some issues
during the AP creation.
- Please verify that you've two Wifi interfaces on your device
- and restart it by clicking on the button below.
+ Please verify that you've two WiFi interfaces on your device
and try again by restarting it.
-
+
@@ -53,14 +52,15 @@ export default {
capture_token: false,
capture_start: false,
interval: false,
- error: false
+ error: false,
+ reboot_option: false
}
},
methods: {
generate_ap: function() {
clearInterval(this.interval)
this.ssid_name = false
- axios.get(`/api/network/ap/start`, { timeout: 70000 })
+ axios.get(`/api/network/ap/start`, { timeout: 30000 })
.then(response => (this.show_ap(response.data)))
},
show_ap: function(data) {
@@ -109,9 +109,19 @@ export default {
}
});
}
- }
+ },
+ load_config: function() {
+ axios.get(`/api/misc/config`, { timeout: 60000 })
+ .then(response => {
+ this.reboot_option = response.data.reboot_option
+ })
+ .catch(error => {
+ console.log(error)
+ });
+ },
},
created: function() {
+ this.load_config()
this.generate_ap();
}
}
diff --git a/server/frontend/app/blueprints/misc.py b/server/frontend/app/blueprints/misc.py
index 4fa467d..250c821 100644
--- a/server/frontend/app/blueprints/misc.py
+++ b/server/frontend/app/blueprints/misc.py
@@ -13,8 +13,35 @@ def api_reboot():
"""
Reboot the device
"""
- sp.Popen("reboot", shell=True)
- return jsonify({"mesage": "Let's reboot."})
+ if read_config(("frontend", "reboot_option")):
+ sp.Popen("shutdown -r now", shell=True)
+ return jsonify({"mesage": "Let's reboot."})
+ else:
+ return jsonify({"message": "Option disabled", "status": False})
+
+
+@misc_bp.route("/quit", methods=["GET"])
+def api_quit():
+ """
+ Quit the interface (Chromium browser)
+ """
+ if read_config(("frontend", "quit_option")):
+ sp.Popen('pkill -INT -f "chromium-browser"', shell=True)
+ return jsonify({"message": "Let's quit", "status": True})
+ else:
+ return jsonify({"message": "Option disabled", "status": False})
+
+
+@misc_bp.route("/shutdown", methods=["GET"])
+def api_shutdown():
+ """
+ Reboot the device
+ """
+ if read_config(("frontend", "shutdown_option")):
+ sp.Popen("shutdown -h now", shell=True)
+ return jsonify({"message": "Let's shutdown", "status": True})
+ else:
+ return jsonify({"message": "Option disabled", "status": False})
@misc_bp.route("/config", methods=["GET"])
@@ -27,4 +54,7 @@ def get_config():
"hide_mouse": read_config(("frontend", "hide_mouse")),
"download_links": read_config(("frontend", "download_links")),
"sparklines": read_config(("frontend", "sparklines")),
+ "quit_option": read_config(("frontend", "quit_option")),
+ "shutdown_option": read_config(("frontend", "shutdown_option")),
+ "reboot_option": read_config(("frontend", "reboot_option"))
})
diff --git a/update.sh b/update.sh
index e2db75e..0e67fbc 100644
--- a/update.sh
+++ b/update.sh
@@ -45,5 +45,18 @@ elif [ $PWD = "/tmp/tinycheck" ]; then
service tinycheck-frontend restart
service tinycheck-watchers restart
+ # Updating configuration with new key-val pairs.
+ if ! grep -q reboot_option /usr/share/tinycheck/config.yaml; then
+ sed -i 's/frontend:/frontend:\n reboot_option: true/g' /usr/share/tinycheck/config.yaml
+ fi
+
+ if ! grep -q shutdown_option /usr/share/tinycheck/config.yaml; then
+ sed -i 's/frontend:/frontend:\n shutdown_option: true/g' /usr/share/tinycheck/config.yaml
+ fi
+
+ if ! grep -q quit_option /usr/share/tinycheck/config.yaml; then
+ sed -i 's/frontend:/frontend:\n quit_option: true/g' /usr/share/tinycheck/config.yaml
+ fi
+
echo "[+] TinyCheck updated!"
fi
\ No newline at end of file