contrib/meshwizard: Also setup a dhcp server on the adhoc interface if VAP is used...
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / setup_splash.sh
index f316798..722567e 100755 (executable)
@@ -1,38 +1,49 @@
 #!/bin/sh
 # Setup_splash, takes 1 argument: 1=net
 
-. /etc/functions.sh
+. /lib/functions.sh
 . $dir/functions.sh
 
 net=$1
+vap=$(uci -q get meshwizard.netconfig.${net}_vap)
 
 if [ ! "$has_luci_splash" == TRUE ]; then
        echo "    Luci Splash is not installed, skipping setup of it."
        exit
 fi
 
-handle_splash() {
-       config_get network "$1" network
-       if [ "$network" == "${netrenamed}dhcp" ]; then
-               if [ "$cleanup" == 1 ]; then
-                       section_cleanup luci_splash.$1
-               else
+set_defaults "luci_splash_" luci_splash.general
+uci_commitverbose "Setup general splash settings" luci_splash
+
+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
+       }
+       config_load luci_splash
+       config_foreach handle_splash iface
+
+       if [ "$vap" == 1 ]; then
+               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
+               uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
        fi
-}
-config_load luci_splash
-config_foreach handle_splash iface
-
-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
-
-uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
-
-/etc/init.d/luci_splash enable
+       uci batch <<- EOF
+               set luci_splash.${netrenamed}ahdhcp="iface"
+               set luci_splash.${netrenamed}ahdhcp.network="${netrenamed}ahdhcp"
+               set luci_splash.${netrenamed}ahdhcp.zone="freifunk"
+       EOF
+       uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash
+
+       /etc/init.d/luci_splash enable
+fi