done
}
+# Takes 2 arguments
+# $1 = text to be displayed in the output for this section
+# $2 = section (optional)
+uci_commitverbose() {
+ echo "+ $1"
+ uci changes $2 | while read line; do
+ echo " $line"
+ done
+ uci commit $2
+}
+
set_defaults() {
for def in $(env |grep "^$1"); do
option=${def/$1/}
uci set $2.$option
- echo " ${option/=/: }"
done
}
uci -q rename $1.$2=$3 && msg_rename $1.$2 $1.$3 || msg_rename_error $1.2 $1.$3
}
-msg_start() {
- echo " Starting configuration of $1"
-}
-
msg_cleanup() {
echo " Cleanup: Removed section $1."
}
uci batch << EOF
set dhcp.${netrenamed}dhcp="dhcp"
-set dhcp.${netrenamed}dhcp.leasetime="${dhcp_leasetime}"
-set dhcp.${netrenamed}dhcp.force="1"
+set dhcp.${netrenamed}dhcp.leasetime="$dhcp_leasetime"
+set dhcp.${netrenamed}dhcp.force="$dhcp_force"
set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp"
EOF
-echo " leasetime: ${dhcp_leasetime}
- interface: ${netrenamed}dhcp"
+uci_commitverbose "Setup DHCP for $netrenamed" dhcp
config_load dhcp
config_foreach handle_dhcp dnsmasq
-echo " + Setup dnsmasq"
-
uci set dhcp.dnsmasq.local="/$profile_suffix/"
uci set dhcp.dnsmasq.domain="$profile_suffix"
-echo " local: /$profile_suffix/
- domain: $profile_suffix"
-
config_get addnhosts dnsmasq addnhosts
if [ -z "${addnhosts/\var\/etc\/hosts.olsr/}" ]; then
uci add_list dhcp.dnsmasq.addnhosts="/var/etc/hosts.olsr"
- echo " addnhosts: /var/etc/hosts.olsr"
fi
-uci commit
-
+uci_commitverbose "Setup dnsmasq" dhcp
uci set firewall.$1.local_restrict=1
fi
}
-config_foreach handle_zonewan zone && echo " + Enable local_restrict for zone wan"
+config_foreach handle_zonewan zone && uci_commitverbose "Enable local_restrict for zone wan" firewall
# Delete old firewall zone for freifunk
handle_fwzone() {
# setup freifunk firewall zone
-echo " + Setup firewall zone."
-
# add $netrenamed and if needed ${netrenamed}dhcp to the networks for this zone
config_get network zone_freifunk network
set firewall.zone_freifunk.output="$zone_freifunk_output"
EOF
-echo " network: $network
- input: $zone_freifunk_input
- forward: $zone_freifunk_forward
- output: $zone_freifunk_output"
+uci_commitverbose "Setup freifunk firewall zone" firewall
# Usually we need to setup masquerading for lan, except lan is an olsr interface or has an olsr hna
-echo " + Setup masquerading rules"
-
handle_interface() {
config_get interface "$1" interface
if [ "$interface" == "lan" ]; then
currms=$(uci -q get firewall.zone_freifunk.masq_src)
if [ ! "$no_masq_lan" == "1" ]; then
- uci set firewall.zone_freifunk.masq="1" && echo " Enabled masquerading." || echo -e "\033[1mWarning:\033[0m: Could not enable masquerading."
+ uci set firewall.zone_freifunk.masq="1"
[ -z "$(echo $currms |grep lan)" ] && uci add_list firewall.zone_freifunk.masq_src="lan"
fi
fi
done
+uci_commitverbose "Setup masquerading rules" firewall
+
# Rules, Forwardings, advanced config and includes
# Clear firewall configuration
-echo " + Setup rules, forwardings, advanced config and includes."
-
for config in freifunk profile_$community; do
config_load $config
done
done
-uci commit
+uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall
#!/bin/sh
# Sets values in /etc/config/freifunk
-. /etc/functions.sh
. $dir/functions.sh
# Set community homepage
uci set freifunk.community.homepage="$hp"
fi
+uci_commitverbose "/etc/init.d/freifunk config" freifunk
ipaddr=$(uci get meshwizard.netconfig.$net\_ip4addr)
[ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr
-
[ -z "$interface_netmask" ] && interface netmask="255.255.0.0"
uci batch << EOF
set network.$netrenamed.dns="$interface_dns"
EOF
-echo " IP address: $ipaddr"
-echo " Netmask : $interface_netmask"
+uci_commitverbose "Setup interface $netrenamed" network
# setup dhcp alias/interface
# Setup alias for $net
if [ "$vap" == 1 ]; then
- echo " + Setup interface ${netrenamed}dhcp."
uci set network.${netrenamed}dhcp=interface
else
- echo " + Setup alias interface ${netrenamed}dhcp."
uci set network.${netrenamed}dhcp=alias
uci set network.${netrenamed}dhcp.interface="$netrenamed"
fi
set network.${netrenamed}dhcp.netmask="$NETMASK"
EOF
- echo " interface: $net
- ipaddr: $START
- netmask: $NETMASK"
-
fi
-uci commit
+uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
net=$1
. /etc/functions.sh
-
. $dir/functions.sh
# Clean or delete interface defaults
# Setup new InterfaceDefaults
-echo " + Setup InterfaceDefaults"
uci set olsrd.InterfaceDefaults=InterfaceDefaults
set_defaults "olsr_interfacedefaults_" olsrd.InterfaceDefaults
+uci_commitverbose "Setup olsr interface defaults" olsrd
# Delete old interface for $netrenamed
handle_interface() {
# Setup new interface for $netrenamed
-echo " + Setup Interface"
-
uci set olsrd.$netrenamed=Interface
-
set_defaults "olsr_interface_" olsrd.$net
-
uci set olsrd.$netrenamed.interface="$netrenamed"
-echo " interface: $netrenamed"
+
+uci_commitverbose "Setup olsr interface for $netrenamed." olsrd
# If dhcp-network is inside the mesh_network then add HNA for it
dhcprange=$(uci get meshwizard.netconfig.$net\_dhcprange)
dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"
if [ "$dhcpinmesh" == 1 ]; then
- echo " + Setting up HNA"
uci set olsrd.${netrenamed}clients="Hna4"
eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange)
uci set olsrd.${netrenamed}clients.netaddr="$NETWORK"
uci set olsrd.${netrenamed}clients.netmask="$NETMASK"
- echo " netaddr: $NETWORK"
- echo " natmask: $NETMASK"
+ uci_commitverbose "Setup HNA for network $dhcprange" olsrd
fi
# Delete nameservice, dyngw and httpinfo plugins
-echo " + Configure Plugins"
handle_plugin() {
config_get library "$1" library
if [ "$cleanup" == 1 ]; then
set olsrd.olsrd_nameservice.suffix="$suffix"
EOF
-echo " Nameservice Plugin configured."
+uci_commitverbose "Setup olsr nameservice plugin" olsrd
# Setup dyngw_plain
fi
if [ "$sharenet" == 1 ]; then
- echo " + Setup dyngw_plain"
uci set olsrd.dyngw_plain=LoadPlugin
uci set olsrd.dyngw_plain.ignore=0
uci set olsrd.dyngw_plain.library="olsrd_dyn_gw_plain.so.0.4"
+ uci_commitverbose "Setup olsrd_dyngw_plain plugin"
fi
-uci commit
set luci_splash.${netrenamed}dhcp.zone="freifunk"
EOF
-echo " network: ${netrenamed}dhcp"
-
-uci commit
+uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash
/etc/init.d/luci_splash enable
#!/bin/sh
# Sets values from /etc/config/freifunk and/or the community profile in /etc/config/system
+. $dir/functions.sh
+
if [ -n "$(env | grep '^system_')" ]; then
- echo "++++ Setup system"
env | grep "^system_" | sed "s/system_/uci set system.system./g" | while read line; do
eval $line
- echo " $line"
done
fi
-uci commit system
+uci_commitverbose "System config" system
##### wifi-device #####
-echo " + Setup wifi-device"
-
# Get the type before we delete the wifi-device
config_load wireless
config_get type $net type
set wireless.${net}.channel="$channel"
EOF
-echo " Type: $type"
-echo " Channel: $channel"
+uci_commitverbose "Setup wifi device for $netrenamed" wireless
##### wifi iface
-echo " + Setup wifi-iface"
-
# Delete old wifi-iface for $net
handle_interface() {
config_get device "$1" device
# overwrite defaults
bssid="$($dir/helpers/gen_bssid.sh $channel $community)"
+ssid="$profile_ssid"
+if [ "$profile_ssid_scheme" == "addchannel" ]; then
+ ssid="$ssid - ch$channel"
+fi
+
uci batch << EOF
set wireless.$net\_iface.device="${net}"
set wireless.$net\_iface.network="$netrenamed"
-set wireless.$net\_iface.ssid="$profile_ssid - ch$channel"
+set wireless.$net\_iface.ssid="$ssid"
set wireless.$net\_iface.bssid="$bssid"
EOF
-echo " device: $net
- network: $netrenamed
- ssid: $profile_ssid - ch$channel
- bssid: $bssid"
+uci_commitverbose "Setup wifi interface for $netrenamed" wireless
## VAP
ip4addr="$(uci get meshwizard.netconfig.$net\_ip4addr)"
set wireless.$net\_iface_dhcp.network="${netrenamed}dhcp"
set wireless.$net\_iface_dhcp.ssid="FF-AP-$ip4addr"
EOF
- echo " + Setting up VAP interface for $net
- device: $net
- network: ${netrenamed}dhcp
- ssid: AP-$profile_ssid-$ip4addr"
+ uci_commitverbose "Setup VAP interface for $netrenamed" wireless
fi
-uci commit
. /etc/functions.sh
+echo "
+Meshwizard 0.0.3
+"
+
# config
export dir="/usr/bin/meshwizard"
. $dir/functions.sh
debug=1
# Rename wifi interfaces
- echo "++++ Renaming wifi-devices in /etc/config/meshwizard"
+ echo "+ Renaming wifi-devices in /etc/config/meshwizard"
$dir/helpers/rename-wifi.sh
# Firstboot/initial config
- echo "++++ Initial config"
+ echo "+ Initial config"
$dir/helpers/initial_config.sh
# Get community
[ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1
-echo "+++ wizard 0.0.2 +++
-Community=$community
-Network(s)=$networks"
+echo " Community=$community
+ Network(s)=$networks"
# Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community,
# last will overwrite first
export "${line//\"/}"
done < /tmp/meshwizard.tmp
-# dnsmasq
- echo "++++ dnsmasq config"
- $dir/helpers/setup_dnsmasq.sh
-
-# system
- echo "++++ system config"
- $dir/helpers/setup_system.sh
-
-# freifunk
- echo "++++ /etc/config/freifunk config"
- $dir/helpers/setup_freifunk.sh
+$dir/helpers/setup_dnsmasq.sh
+$dir/helpers/setup_system.sh
+$dir/helpers/setup_freifunk.sh
# Configure found networks
for net in $networks; do
netrenamed="${net/radio/wireless}"
export netrenamed
- echo "++++ Configure interface $net"
-
- config="network"
- echo "$(msg_start $config)"
$dir/helpers/setup_network.sh $net
-
- config="wireless"
- echo "$(msg_start $config)"
$dir/helpers/setup_wifi.sh $net
-
- config="OLSRd"
- echo "$(msg_start $config)"
$dir/helpers/setup_olsrd.sh $net
net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp)
if [ "$net_dhcp" == 1 ]; then
- config="DHCP"
- echo "$(msg_start $config)"
$dir/helpers/setup_dhcp.sh $net
fi
- config="luci_splash"
- echo "$(msg_start $config)"
$dir/helpers/setup_splash.sh $net
-
- config="firewall"
- echo "$(msg_start $config)"
$dir/helpers/setup_firewall.sh $net
-
- echo " Configuration of $net finished."
done
##### Reboot the router (because simply restarting services gave errors)