summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2011-10-26 12:53:40 +0000
committerManuel Munz <freifunk@somakoma.de>2011-10-26 12:53:40 +0000
commit5654bb7ef6e72734f1f3fcfd6ce2ee1382d8335a (patch)
tree7e6efff1aedf5a01e23b3c8b074aa83e3221d7e8
parent334756a472e933c4fe407aaa9df66d56ccd3e94a (diff)
contrib/meshwizard: Add wan configuration
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh2
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh10
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wan_static.sh48
-rwxr-xr-xcontrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh9
4 files changed, 61 insertions, 8 deletions
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh
index 67469e3c2c..89f788ecd2 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/read_defaults.sh
@@ -20,6 +20,6 @@ for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_
done
# read values from meshwizard
-for v in system luci_main contact community; do
+for v in system luci_main contact community wan; do
get_var meshwizard.$v
done
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
index 9958af1ac9..1d4c3ba7e1 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
@@ -61,11 +61,11 @@ if [ "$net_dhcp" == 1 ]; then
uci set network.${netrenamed}dhcp.interface="$netrenamed"
fi
-uci batch << EOF
-set network.${netrenamed}dhcp.proto=static
-set network.${netrenamed}dhcp.ipaddr="$START"
-set network.${netrenamed}dhcp.netmask="$NETMASK"
-uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
+ uci batch << EOF
+ set network.${netrenamed}dhcp.proto=static
+ set network.${netrenamed}dhcp.ipaddr="$START"
+ set network.${netrenamed}dhcp.netmask="$NETMASK"
+ uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
EOF
fi
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wan_static.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wan_static.sh
new file mode 100755
index 0000000000..e41695f8c3
--- /dev/null
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wan_static.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+# Setup static interface settings for wan if wan is not an olsr interface
+
+[ ! "$(uci -q get network.wan)" == "interface" ] && exit
+
+. /etc/functions.sh
+. $dir/functions.sh
+
+uci batch << EOF
+set network.wan.proto='$wan_proto'
+set network.wan.ipaddr='$wan_ip4addr'
+set network.wan.netmask='$wan_netmask'
+set network.wan.gateway='$wan_gateway'
+set network.wan.dns='$wan_dns'
+EOF
+
+uci_commitverbose "Setup static ip settings for wan" network
+
+uci delete meshwizard.wan && uci commit meshwizard
+
+# Firewall rules to allow incoming ssh and web
+
+if [ "$wan_allowssh" == 1 ]; then
+ uci batch << EOF
+set firewall.wanssh=rule
+set firewall.wanssh.src=wan
+set firewall.wanssh.target=ACCEPT
+set firewall.wanssh.proto=tcp
+set firewall.wanssh.dest_port=22
+EOF
+ uci_commitverbose "Allow incoming connections to port 22 (ssh) on wan" firewall
+fi
+
+if [ "$wan_allowweb" == 1 ]; then
+ uci batch << EOF
+set firewall.wanweb=rule
+set firewall.wanweb.src=wan
+set firewall.wanweb.target=ACCEPT
+set firewall.wanweb.proto=tcp
+set firewall.wanweb.dest_port=80
+set firewall.wanwebhttps=rule
+set firewall.wanwebhttps.src=wan
+set firewall.wanwebhttps.target=ACCEPT
+set firewall.wanwebhttps.proto=tcp
+set firewall.wanwebhttps.dest_port=443
+EOF
+ uci_commitverbose "Allow incoming connections to port 80 and 443 (http and https) on wan" firewall
+fi
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh
index 2b85b73799..fd9d95ebf8 100755
--- a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh
+++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh
@@ -12,7 +12,7 @@
. /etc/functions.sh
echo "
-/* Meshwizard 0.0.5 */
+/* Meshwizard 0.0.4 */
"
# config
@@ -36,6 +36,7 @@ $dir/helpers/rename-wifi.sh
community=$(uci -q get meshwizard.community.name || uci -q get freifunk.community.name)
[ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1
export community="$community"
+echo $community
# Get a list of networks we need to setup
networks=$(uci show meshwizard.netconfig | grep -v "netconfig=" | sed -e 's/meshwizard.netconfig\.\(.*\)\_.*/\1/' |sort|uniq)
@@ -58,6 +59,10 @@ $dir/helpers/setup_system.sh
$dir/helpers/setup_olsrd.sh
$dir/helpers/setup_firewall.sh
+if [ "$wan_proto" == "static" ] && [ -n "$wan_ip4addr" ] && [ -n "$wan_netmask" ]; then
+ $dir/helpers/setup_wan_static.sh
+fi
+
# Configure found networks
for net in $networks; do
# radioX devices need to be renamed
@@ -80,4 +85,4 @@ done
##### Reboot the router (because simply restarting services gave errors)
-#reboot
+reboot