e41695f8c302330716d47ffd020b4da51e1e4f68
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / setup_wan_static.sh
1 #!/bin/sh
2 # Setup static interface settings for wan if wan is not an olsr interface
3
4 [ ! "$(uci -q get network.wan)" == "interface" ] && exit
5
6 . /etc/functions.sh
7 . $dir/functions.sh
8
9 uci batch << EOF
10 set network.wan.proto='$wan_proto'
11 set network.wan.ipaddr='$wan_ip4addr'
12 set network.wan.netmask='$wan_netmask'
13 set network.wan.gateway='$wan_gateway'
14 set network.wan.dns='$wan_dns'
15 EOF
16
17 uci_commitverbose "Setup static ip settings for wan" network
18
19 uci delete meshwizard.wan && uci commit meshwizard
20
21 # Firewall rules to allow incoming ssh and web
22
23 if [ "$wan_allowssh" == 1 ]; then
24         uci batch << EOF
25 set firewall.wanssh=rule
26 set firewall.wanssh.src=wan
27 set firewall.wanssh.target=ACCEPT
28 set firewall.wanssh.proto=tcp
29 set firewall.wanssh.dest_port=22
30 EOF
31         uci_commitverbose "Allow incoming connections to port 22 (ssh) on wan" firewall
32 fi
33
34 if [ "$wan_allowweb" == 1 ]; then
35         uci batch << EOF
36 set firewall.wanweb=rule
37 set firewall.wanweb.src=wan
38 set firewall.wanweb.target=ACCEPT
39 set firewall.wanweb.proto=tcp
40 set firewall.wanweb.dest_port=80
41 set firewall.wanwebhttps=rule
42 set firewall.wanwebhttps.src=wan
43 set firewall.wanwebhttps.target=ACCEPT
44 set firewall.wanwebhttps.proto=tcp
45 set firewall.wanwebhttps.dest_port=443
46 EOF
47         uci_commitverbose "Allow incoming connections to port 80 and 443 (http and https) on wan" firewall
48 fi