luci-theme-bootstrap: add explicit dark/light mode selection
[project/luci.git] / themes / luci-theme-bootstrap / root / etc / uci-defaults / 30_luci-theme-bootstrap
index 4381a15c2e7d1185dd4e32ac3399a0fa73c2cae8..b66e5b2be3934714dcffef6bd4f4b98a627513b8 100755 (executable)
@@ -1,12 +1,28 @@
 #!/bin/sh
 
+changed=0
+
+set_opt() {
+       local key=$1
+       local val=$2
+
+       if ! uci -q get "luci.themes.$key" 2>/dev/null; then
+               uci set "luci.themes.$key=$val"
+               changed=1
+       fi
+}
+
+set_opt Bootstrap /luci-static/bootstrap
+set_opt BootstrapDark /luci-static/bootstrap-dark
+set_opt BootstrapLight /luci-static/bootstrap-light
+
 if [ "$PKG_UPGRADE" != 1 ]; then
-       uci get luci.themes.Bootstrap >/dev/null 2>&1 || \
-       uci batch <<-EOF
-               set luci.themes.Bootstrap=/luci-static/bootstrap
-               set luci.main.mediaurlbase=/luci-static/bootstrap
-               commit luci
-       EOF
+       uci set luci.main.mediaurlbase=/luci-static/bootstrap
+       changed=1
+fi
+
+if [ $changed = 1 ]; then
+       uci commit luci
 fi
 
 exit 0