webserver: introduce a parameter to run postupdate

Message ID 20181129165024.30521-1-sbabic@denx.de
State New
Headers show
Series
  • webserver: introduce a parameter to run postupdate
Related show

Commit Message

Stefano Babic Nov. 29, 2018, 4:50 p.m.
After a successful update, the Webserver initiates the postupdate
command automatically. There are some use case where this is not desired
because some manual interventions are required on the device before
rebooting. Make this behavior configurable adding a "run-postupdate"
flag in the webserver section of the configuration file (default =
active).

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 examples/configuration/swupdate.cfg | 3 +++
 mongoose/mongoose_interface.c       | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

Patch

diff --git a/examples/configuration/swupdate.cfg b/examples/configuration/swupdate.cfg
index be66484..01e6955 100644
--- a/examples/configuration/swupdate.cfg
+++ b/examples/configuration/swupdate.cfg
@@ -166,6 +166,9 @@  suricatta :
 # auth-domain		: string
 #			  path to auth-domain, if any
 #			  default = none
+# run-postupdate	: boolean (default true)
+#			  run the postupdate command automatically after
+#			  a successful update
 
 webserver :
 {
diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
index 2521b30..ef48c00 100644
--- a/mongoose/mongoose_interface.c
+++ b/mongoose/mongoose_interface.c
@@ -55,6 +55,7 @@  struct file_upload_state {
 	int fd;
 };
 
+static bool run_postupdate;
 static struct mg_serve_http_opts s_http_server_opts;
 static void upload_handler(struct mg_connection *nc, int ev, void *p);
 
@@ -238,7 +239,7 @@  static void *broadcast_progress_thread(void *data)
 			broadcast(mgr, str);
 		}
 
-		if (msg.status == SUCCESS && msg.source == SOURCE_WEBSERVER) {
+		if (msg.status == SUCCESS && msg.source == SOURCE_WEBSERVER && run_postupdate) {
 			ipc_message ipc = {};
 
 			ipc_postupdate(&ipc);
@@ -491,6 +492,12 @@  static int mongoose_settings(void *elem, void  __attribute__ ((__unused__)) *dat
 	if (strlen(tmp)) {
 		opts->auth_domain = strdup(tmp);
 	}
+	/*
+	 * Default value is active
+	 */
+	run_postupdate = true;
+	get_field(LIBCFG_PARSER, elem, "run-postupdate", &run_postupdate);
+
 	return 0;
 }