diff mbox series

[2/2] uhttpd: Execute uci commit and reload_config once

Message ID 20210320123228.3697143-2-hauke@hauke-m.de
State Superseded
Delegated to: Hauke Mehrtens
Headers show
Series [1/2] uhttpd: Reload config after uhttpd-mod-ubus was added | expand

Commit Message

Hauke Mehrtens March 20, 2021, 12:32 p.m. UTC
Instead of doing uci commit and reload_config for each setting do it
only once when one of these options was changed. This should make it a
little faster when both conditions are taken.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 package/network/services/uhttpd/files/ubus.default | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/package/network/services/uhttpd/files/ubus.default b/package/network/services/uhttpd/files/ubus.default
index 35724ba57e03..019f25ae6288 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -1,15 +1,17 @@ 
 #!/bin/sh
 
+commit=0
+
 if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then
 	uci set uhttpd.main.ubus_prefix=/ubus
-	uci commit uhttpd
-	reload_config
+	commit=1
 fi
 
 [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && {
 	uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock'
-	uci commit uhttpd
-	reload_config
+	commit=1
 }
 
+[ "$commit" = 1 ] && uci commit uhttpd && reload_config
+
 exit 0