722567e813d3561ffbff457eb7ffa9e6fea2cacb
[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 if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then
21         handle_splash() {
22                 config_get network "$1" network
23                 if [ "$network" == "${netrenamed}dhcp" ]; then
24                         if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
25                                 section_rename luci_splash $1 ${netrenamed}dhcp
26                         fi
27                 fi
28         }
29         config_load luci_splash
30         config_foreach handle_splash iface
31
32         if [ "$vap" == 1 ]; then
33                 uci batch <<- EOF
34                         set luci_splash.${netrenamed}dhcp="iface"
35                         set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp"
36                         set luci_splash.${netrenamed}dhcp.zone="freifunk"
37                 EOF
38                 uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
39         fi
40         uci batch <<- EOF
41                 set luci_splash.${netrenamed}ahdhcp="iface"
42                 set luci_splash.${netrenamed}ahdhcp.network="${netrenamed}ahdhcp"
43                 set luci_splash.${netrenamed}ahdhcp.zone="freifunk"
44         EOF
45         uci_commitverbose "Setup dhcpsplash for ${netrenamed}ahdhcp" luci_splash
46
47         /etc/init.d/luci_splash enable
48 fi
49