contrib/meshwizard: fix LAN with OLSR and DHCP
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / setup_splash.sh
1 #!/bin/sh
2 # Setup_splash, takes 1 argument: 1=net
3
4 . /lib/functions.sh
5 . $dir/functions.sh
6
7 net=$1
8 vap=$(uci -q get meshwizard.netconfig.${net}_vap)
9
10 if [ ! "$has_luci_splash" == TRUE ]; then
11         echo "    Luci Splash is not installed, skipping setup of it."
12         exit
13 fi
14
15 set_defaults "luci_splash_" luci_splash.general
16 uci_commitverbose "Setup general splash settings" luci_splash
17
18 dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange)
19
20 splash_net_add() {
21         uci batch <<- EOF
22                 set luci_splash.$1="iface"
23                 set luci_splash.$1.network="$1"
24                 set luci_splash.$1.zone="freifunk"
25         EOF
26 }
27
28 if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" = 1 ] && [ -n "$dhcprange" ]; then
29         handle_splash() {
30                 config_get network "$1" network
31                 if [ "$network" == "${netrenamed}dhcp" ]; then
32                         if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
33                                 section_rename luci_splash $1 ${netrenamed}dhcp
34                         fi
35                 fi
36         }
37         config_load luci_splash
38         config_foreach handle_splash iface
39
40         if [ "$supports_vap" = 1 -a "$vap" = 1 ]; then
41                 splash_net_add ${netrenamed}dhcp
42                 uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
43         fi
44
45         ahdhcp_when_vap="$(uci get profile_$community.profile.adhoc_dhcp_when_vap)"
46         if [ "$supports_vap" = 0 ] || \
47                 [ "$supports_vap" = 1 -a "$vap" = 1 -a "$ahdhcp_when_vap" = 1 ] || \
48                 [ "$lan_dhcp" = 1 ]; then
49                 splash_net_add ${netrenamed}ahdhcp
50                 uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash
51         fi
52         /etc/init.d/luci_splash enable
53 fi
54