diff options
author | Manuel Munz <freifunk@somakoma.de> | 2011-09-21 16:43:38 +0000 |
---|---|---|
committer | Manuel Munz <freifunk@somakoma.de> | 2011-09-21 16:43:38 +0000 |
commit | 63639d6076048d87caab5bccdf943de9276e2ec8 (patch) | |
tree | 0a49caf83afe8d7dfd5b999cd3f0e9fa448396d7 /contrib/package | |
parent | bc8eaf6875fb195484b0a86e71ea92dc63b82ded (diff) |
contrib/meshwizard: Cleanup and add ssid_scheme option
Diffstat (limited to 'contrib/package')
11 files changed, 54 insertions, 112 deletions
diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/functions.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/functions.sh index 5e0e194185..689289bbb8 100644 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/functions.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/functions.sh @@ -12,11 +12,21 @@ uci_remove_list_element() { 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 } @@ -30,10 +40,6 @@ section_rename() { 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." } diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh index 4c7ea5afb0..06f80d850b 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh @@ -23,11 +23,10 @@ config_foreach handle_dnsmasq dhcp 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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh index 517b4fd348..26a896bc7b 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh @@ -13,19 +13,12 @@ handle_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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh index c9681425ff..e7e453d1c2 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh @@ -19,7 +19,7 @@ handle_zonewan() { 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() { @@ -69,8 +69,6 @@ fi # 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 @@ -93,15 +91,10 @@ set firewall.zone_freifunk.forward="$zone_freifunk_forward" 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 @@ -121,7 +114,7 @@ config_foreach handle_hna Hna4 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 @@ -137,11 +130,11 @@ for i in $networks; do 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 @@ -158,4 +151,4 @@ for config in freifunk profile_$community; do done done -uci commit +uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_freifunk.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_freifunk.sh index 7c66e638ba..0e6e7dfadf 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_freifunk.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_freifunk.sh @@ -1,7 +1,6 @@ #!/bin/sh # Sets values in /etc/config/freifunk -. /etc/functions.sh . $dir/functions.sh # Set community homepage @@ -11,4 +10,5 @@ if [ -n "$hp" ]; then uci set freifunk.community.homepage="$hp" fi +uci_commitverbose "/etc/init.d/freifunk config" freifunk 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 4f03d228c5..493c701b25 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 @@ -14,7 +14,6 @@ fi 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 @@ -25,8 +24,7 @@ set network.$netrenamed.netmask="$interface_netmask" 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 @@ -68,10 +66,8 @@ if [ "$net_dhcp" == 1 ]; then # 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 @@ -82,10 +78,6 @@ set network.${netrenamed}dhcp.ipaddr="$START" 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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh index d298828e3d..06cc2e58c2 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh @@ -5,7 +5,6 @@ net=$1 . /etc/functions.sh - . $dir/functions.sh # Clean or delete interface defaults @@ -24,9 +23,9 @@ config_foreach handle_interfacedefaults InterfaceDefaults # 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() { @@ -44,14 +43,11 @@ config_foreach handle_interface 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) @@ -63,19 +59,16 @@ uci -q delete olsrd.${netrenamed}clients 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 @@ -105,7 +98,7 @@ set olsrd.olsrd_nameservice.sighup_pid_file="/var/run/dnsmasq.pid" set olsrd.olsrd_nameservice.suffix="$suffix" EOF -echo " Nameservice Plugin configured." +uci_commitverbose "Setup olsr nameservice plugin" olsrd # Setup dyngw_plain @@ -117,10 +110,9 @@ if [ -n "$(uci -q get olsrd.dyngw_plain.library)" ]; then 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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh index b28ccc93c7..86f60aee1f 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh @@ -27,9 +27,7 @@ set luci_splash.${netrenamed}dhcp.network="${netrenamed}dhcp" 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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh index d6b30e3dd6..2c3081e666 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh @@ -1,12 +1,12 @@ #!/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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh index 150e412de7..1feff0d70e 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh @@ -8,8 +8,6 @@ net="$1" ##### wifi-device ##### -echo " + Setup wifi-device" - # Get the type before we delete the wifi-device config_load wireless config_get type $net type @@ -45,13 +43,10 @@ set wireless.${net}.type="$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 @@ -75,17 +70,19 @@ set_defaults "wifi_iface_" wireless.$net\_iface # 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)" @@ -98,10 +95,6 @@ set wireless.$net\_iface_dhcp.encryption="none" 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 diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh index a5f9a2fb9f..c03d11f93b 100755 --- a/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh +++ b/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh @@ -4,17 +4,21 @@ . /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 @@ -32,9 +36,8 @@ export networks [ -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 @@ -45,17 +48,9 @@ while read line; do 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 @@ -63,36 +58,17 @@ 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) |