contrib/meshwizard: Add lan config, rework wan config
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / setup_splash.sh
index 8e143d338e4fd273343a60afbf51bc047a320f1f..95b765a5a0b982feec95008dbcb71dfacc0a1219 100755 (executable)
@@ -6,27 +6,32 @@
 
 net=$1
 
-handle_splash() {
-       config_get network "$1" network
-       if [ "$network" == "${netrenamed}dhcp" ]; then
-               if [ "$cleanup" == 1 ]; then
-                       section_cleanup luci_splash.$1
-               else
+if [ ! "$has_luci_splash" == TRUE ]; then
+       echo "    Luci Splash is not installed, skipping setup of it."
+       exit
+fi
+
+dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange)
+
+if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then
+       handle_splash() {
+               config_get network "$1" network
+               if [ "$network" == "${netrenamed}dhcp" ]; then
                        if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
                                section_rename luci_splash $1 ${netrenamed}dhcp
                        fi
                fi
-       fi
-}
-config_load luci_splash
-config_foreach handle_splash iface
+       }
+       config_load luci_splash
+       config_foreach handle_splash iface
 
-uci batch << EOF
-set luci_splash.${netrenamed}dhcp="iface"
-set luci_splash.${netrenamed}dhcp.network="${net}dhcp"
-set luci_splash.${netrenamed}dhcp.zone="freifunk"
-EOF
+       uci batch <<- EOF
+               set luci_splash.${netrenamed}dhcp="iface"
+               set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp"
+               set luci_splash.${netrenamed}dhcp.zone="freifunk"
+       EOF
 
-echo "    network: ${netrenamed}dhcp"
+       uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
+       /etc/init.d/luci_splash enable
+fi
 
-uci commit
\ No newline at end of file