Changeset 7610
- Timestamp:
- 10/06/11 20:38:12 (20 months ago)
- Location:
- luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard
- Files:
-
- 1 removed
- 11 modified
-
functions.sh (modified) (1 diff)
-
helpers/initial_config.sh (modified) (2 diffs)
-
helpers/rename-wifi.sh (modified) (2 diffs)
-
helpers/setup_dhcp.sh (modified) (2 diffs)
-
helpers/setup_firewall.sh (modified) (4 diffs)
-
helpers/setup_freifunk.sh (deleted)
-
helpers/setup_network.sh (modified) (3 diffs)
-
helpers/setup_olsrd.sh (modified) (4 diffs)
-
helpers/setup_splash.sh (modified) (1 diff)
-
helpers/setup_system.sh (modified) (1 diff)
-
helpers/setup_wifi.sh (modified) (3 diffs)
-
wizard.sh (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/functions.sh
r7606 r7610 34 34 } 35 35 36 # 1 argument: section to remove37 section_cleanup() {38 uci -q delete $1 && msg_cleanup $1 || msg_cleanup_error $139 }40 41 36 # 3 arguements: 1=config name 2=oldname 3=newname 42 37 section_rename() { 43 38 uci -q rename $1.$2=$3 && msg_rename $1.$2 $1.$3 || msg_rename_error $1.2 $1.$3 44 }45 46 msg_cleanup() {47 echo " Cleanup: Removed section $1."48 }49 50 msg_cleanup_error() {51 echo -e " \033[1mWarning:\033[0m Cleanup of $1 failed."52 39 } 53 40 -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/initial_config.sh
r7606 r7610 3 3 # It sets up the initial config for this node. 4 4 5 6 5 . /etc/functions.sh 7 6 . $dir/functions.sh 8 9 ### System config10 7 11 8 config_load system … … 20 17 21 18 if [ -n "$(uci -q get meshwizard.community)" ]; then 22 echo " + Setup community"23 19 set_defaults "community_" freifunk.community 24 20 uci -q delete meshwizard.community 25 uci_commitverbose freifunk26 21 fi 22 [ -n "$profile_homepage" ] && uci set freifunk.community.homepage="$profile_homepage" 23 uci_commitverbose "Setup community" freifunk 27 24 28 25 if [ -n "$(uci -q get meshwizard.contact)" ]; then 29 echo " + Setup contact"30 26 set_defaults "contact_" freifunk.contact 31 uci -q delete meshwizard.contact && uci_commitverbose freifunk27 uci -q delete meshwizard.contact && uci_commitverbose "Setup contact" freifunk 32 28 fi 33 29 34 30 if [ "$has_luci" == TRUE ]; then 35 echo " + Setup luci"36 31 set_defaults "luci_main_" luci.main 37 uci -q delete meshwizard.luci_main && uci_commitverbose luci32 uci -q delete meshwizard.luci_main && uci_commitverbose "Setup luci" luci 38 33 fi 39 40 uci commit41 42 -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/rename-wifi.sh
r7208 r7610 3 3 # E.g. wireless.IB_wifi0 would become wireless.wifi0 on madwifi and wireless.radio0 on mac80211 4 4 5 . $dir/functions.sh 6 5 7 posIB=-1 6 8 7 9 IBwifis="$(uci show meshwizard.netconfig | grep -v 'netconfig=netconfig' | sed 's/meshwizard.netconfig\.\(IB_wifi.*\)_.*/\1/' |uniq)" 10 [ -z "$(echo $IBwifis |grep IB_wifi)" ] && exit 8 11 9 12 for w in $IBwifis; do … … 41 44 done 42 45 43 uci commit46 uci_commitverbose "Renaming wifi-devices in /etc/config/meshwizard" meshwizard -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh
r7501 r7610 10 10 config_get interface "$1" interface 11 11 if [ "$interface" == "${netrenamed}dhcp" ]; then 12 if [ "$cleanup" == 1 ]; then 13 section_cleanup dhcp.$1 14 else 15 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 16 section_rename dhcp $1 ${netrenamed}dhcp 17 fi 18 fi 19 fi 12 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 13 section_rename dhcp $1 ${netrenamed}dhcp 14 fi 15 fi 20 16 } 21 17 config_load dhcp … … 24 20 uci batch << EOF 25 21 set dhcp.${netrenamed}dhcp="dhcp" 26 set dhcp.${netrenamed}dhcp.leasetime="$dhcp_leasetime"27 set dhcp.${netrenamed}dhcp.force="$dhcp_force"28 22 set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp" 29 23 EOF 30 24 25 set_defaults "dhcp_" dhcp.${netrenamed}dhcp 26 31 27 uci_commitverbose "Setup DHCP for $netrenamed" dhcp 32 28 -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh
r7501 r7610 28 28 29 29 if [ "$2" == "zoneconf" ]; then 30 # clean zone31 30 if [ "$name" == "freifunk" ]; then 32 if [ "$cleanup" == 1 ]; then 33 section_cleanup firewall.$1 34 else 35 # rename section if unnamed 36 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 37 section_rename firewall $1 zone_freifunk 38 fi 31 # rename section if unnamed 32 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 33 section_rename firewall $1 zone_freifunk 39 34 fi 40 35 else 41 42 if [ "$name" == "$netrenamed" ]; then43 section_cleanup firewall.$144 fi45 36 if [ -n "$netrenamed" -a -n "$(echo $network | grep $netrenamed)" ] && [ ! "$name" == "freifunk" ]; then 46 37 echo " Removed $netrenamed from firewall zone $name." … … 49 40 fi 50 41 fi 51 else52 # clean fw_rule, fw_forwarding, include and advanced53 for option in src tcp_ecn path; do54 config_get $option $1 $option55 done56 if [ "$src" == "freifunk" -o "$path" == "/etc/firewall.freifunk" -o -n "$tcpecn" ]; then57 section_cleanup firewall.$158 fi59 42 fi 60 43 } … … 62 45 config_foreach handle_fwzone zone zoneconf 63 46 64 if [ "$cleanup" == 1 ]; then65 for target in include advanced rule forwarding; do66 config_foreach handle_fwzone $target67 done68 fi69 70 47 # setup freifunk firewall zone 71 72 48 # add $netrenamed and if needed ${netrenamed}dhcp to the networks for this zone 73 49 config_get network zone_freifunk network … … 153 129 154 130 uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall 131 -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh
r7501 r7610 5 5 . /etc/functions.sh 6 6 . $dir/functions.sh 7 8 # Delete the network interface section for $net9 if [ "$cleanup" == 1 ]; then10 section_cleanup network.$netrenamed11 fi12 7 13 8 # Setup a (new) interface section for $net … … 21 16 set network.$netrenamed.proto="static" 22 17 set network.$netrenamed.ipaddr="$ipaddr" 23 set network.$netrenamed.netmask="$interface_netmask"24 set network.$netrenamed.dns="$interface_dns"25 18 EOF 26 19 set_defaults "interface_" network.$netrenamed 27 20 uci_commitverbose "Setup interface $netrenamed" network 28 21 … … 37 30 vap=$(uci -q get meshwizard.netconfig.${net}_vap) 38 31 39 # Clean/rename config32 # Rename config 40 33 handle_dhcpalias() { 41 34 config_get interface "$1" interface 42 35 if [ "$interface" == "$netrenamed" ]; then 43 if [ "$cleanup" == 1 ]; then 44 section_cleanup network.$1 45 else 46 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 47 section_rename network $1 ${netrenamed}dhcp 48 fi 36 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 37 section_rename network $1 ${netrenamed}dhcp 49 38 fi 50 39 fi -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh
r7501 r7610 8 8 . $dir/functions.sh 9 9 10 # Clean or delete interface defaults10 # Rename interface defaults 11 11 handle_interfacedefaults() { 12 if [ "$cleanup" == 1 ]; then 13 section_cleanup olsrd.$1 14 else 15 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 16 section_rename olsrd $1 InterfaceDefaults 17 fi 12 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 13 section_rename olsrd $1 InterfaceDefaults 18 14 fi 19 15 } 20 21 16 config_load olsrd 22 17 config_foreach handle_interfacedefaults InterfaceDefaults 23 18 24 19 # Setup new InterfaceDefaults 25 26 20 uci set olsrd.InterfaceDefaults=InterfaceDefaults 27 21 set_defaults "olsr_interfacedefaults_" olsrd.InterfaceDefaults 28 22 uci_commitverbose "Setup olsr interface defaults" olsrd 29 23 30 # Delete oldinterface for $netrenamed24 # Rename interface for $netrenamed 31 25 handle_interface() { 32 26 config_get interface "$1" Interface 33 27 if [ "$interface" == "$netrenamed" ]; then 34 if [ "$cleanup" == 1 ]; then 35 section_cleanup olsrd.$1 36 elif [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 28 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 37 29 section_rename olsrd $1 $netrenamed 38 30 fi … … 59 51 dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)" 60 52 53 # If it is setup hna for it 61 54 if [ "$dhcpinmesh" == 1 ]; then 62 55 uci set olsrd.${netrenamed}clients="Hna4" … … 68 61 69 62 70 # Delete nameservice, dyngw and httpinfo plugins63 # Rename nameservice, dyngw and httpinfo plugins 71 64 72 65 handle_plugin() { 73 66 config_get library "$1" library 74 if [ "$cleanup" == 1 ]; then 75 case library in 76 olsrd_*) 77 section_cleanup olsrd.$1 78 esac 79 elif [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 67 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 80 68 new="$(echo $library | cut -d '.' -f 1)" 81 69 section_rename olsrd $1 $new … … 106 94 sharenet=$(uci -q get meshwizard.general.sharenet) 107 95 108 if [ -n "$(uci -q get olsrd.dyngw_plain.library)" ]; then109 section_cleanup olsrd.dyngw_plain110 fi111 112 96 if [ "$sharenet" == 1 ]; then 113 97 uci set olsrd.dyngw_plain=LoadPlugin 114 98 uci set olsrd.dyngw_plain.ignore=0 115 99 uci set olsrd.dyngw_plain.library="olsrd_dyn_gw_plain.so.0.4" 116 uci_commitverbose "Setup olsrd_dyngw_plain plugin" 100 uci_commitverbose "Setup olsrd_dyngw_plain plugin" olsrd 117 101 fi 118 102 -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh
r7578 r7610 15 15 config_get network "$1" network 16 16 if [ "$network" == "${netrenamed}dhcp" ]; then 17 if [ "$cleanup" == 1 ]; then 18 section_cleanup luci_splash.$1 19 else 20 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 21 section_rename luci_splash $1 ${netrenamed}dhcp 22 fi 17 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 18 section_rename luci_splash $1 ${netrenamed}dhcp 23 19 fi 24 20 fi -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh
r7606 r7610 1 1 #!/bin/sh 2 # Sets values from /etc/config/freifunk and/or the community profile in /etc/config/system3 2 4 3 . $dir/functions.sh 5 4 6 if [ -n "$(env | grep '^system_')" ]; then 7 env | grep "^system_" | sed "s/system_/uci set system.system./g" | while read line; do 8 eval $line 9 done 10 fi 11 5 set_defaults "system_" system.system 12 6 uci -q delete meshwizard.system && uci commit meshwizard 13 7 uci_commitverbose "System config" system -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh
r7501 r7610 13 13 config_get type $net type 14 14 15 # Delete oldwifi-device for $net15 # Rename wifi-device for $net 16 16 17 17 handle_wifidevice() { 18 if [ "$1" == "$net" -a "$cleanup" == 1 ]; then 19 section_cleanup wireless.${net} 20 else 21 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 22 section_rename wireless $1 $net 23 fi 18 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 19 section_rename wireless $1 $net 24 20 fi 25 21 } … … 48 44 ##### wifi iface 49 45 50 # Delete oldwifi-iface for $net46 # Rename wifi-iface for $net 51 47 handle_interface() { 52 48 config_get device "$1" device 53 49 if [ "$device" == "$net" ]; then 54 if [ "$cleanup" == 1 ]; then 55 section_cleanup wireless.${net}_iface 56 else 57 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 58 section_rename wireless $1 ${net}_iface 59 fi 50 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then 51 section_rename wireless $1 ${net}_iface 60 52 fi 61 53 fi … … 71 63 # overwrite defaults 72 64 bssid="$($dir/helpers/gen_bssid.sh $channel $community)" 65 73 66 ssid="$profile_ssid" 74 67 if [ "$profile_ssid_scheme" == "addchannel" ]; then -
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh
r7606 r7610 1 1 #!/bin/sh 2 # This script will take settings from /etc/config/meshwizard, /etc/config/freifunk and /etc/config/profile_<selected in freifunk> 3 # and setup the router to participate in wireless mesh networks 2 3 # This collection of scripts will take settings from /etc/config/meshwizard, /etc/config/freifunk 4 # and /etc/config/profile_<community> and setup the router to participate in wireless mesh networks 5 6 # Copyright 2011 Manuel Munz <freifunk at somakoma dot de> 7 8 # Licensed under the Apache License, Version 2.0 (the "License") 9 # You may not use this file except in compliance with the License. 10 # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 4 11 5 12 . /etc/functions.sh 6 13 7 14 echo " 8 Meshwizard 0.0.3 15 /* Meshwizard 0.0.4 */ 9 16 " 10 17 … … 12 19 export dir="/usr/bin/meshwizard" 13 20 . $dir/functions.sh 14 debug=115 21 16 22 # Check which packages we have installed … … 20 26 opkg list_installed |grep luci-app-splash > /dev/null && export has_luci_splash=TRUE 21 27 28 # Check whether we want to cleanup/restore uci config before setting new options 29 cleanup=$(uci -q get meshwizard.general.cleanup) 30 [ "$cleanup" == 1 ] && $dir/helpers/restore_default_config.sh 31 22 32 # Rename wifi interfaces 23 echo "+ Renaming wifi-devices in /etc/config/meshwizard" 24 $dir/helpers/rename-wifi.sh 33 $dir/helpers/rename-wifi.sh 25 34 26 35 # Get community 27 export community=$(uci -q get meshwizard.community.name) 28 [ -z "$community" ] && community=$(uci -q get freifunk.community.name) 36 community=$(uci -q get meshwizard.community.name || uci -q get freifunk.community.name) 29 37 [ -z "$community" ] && echo "Error: Community is not set in /etc/config/freifunk, aborting now." && exit 1 30 31 # Check whether we want to cleanup uci config before setting new options or not 32 cleanup=$(uci -q get meshwizard.general.cleanup) 33 34 [ "$cleanup" == 1 ] && export cleanup=1 38 export community="$community" 35 39 36 40 # Get a list of networks we need to setup 37 41 networks=$(uci show meshwizard.netconfig | grep -v "netconfig=" | sed -e 's/meshwizard.netconfig\.\(.*\)\_.*/\1/' |sort|uniq) 38 42 export networks 39 40 43 [ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1 41 42 echo " Community=$community43 Network(s)=$networks"44 44 45 45 # Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community … … 52 52 done < /tmp/meshwizard.tmp 53 53 54 # Firstboot/initial config 55 echo "+ Initial config" 56 $dir/helpers/initial_config.sh 57 58 54 # Do config 55 $dir/helpers/initial_config.sh 59 56 $dir/helpers/setup_dnsmasq.sh 60 57 $dir/helpers/setup_system.sh 61 $dir/helpers/setup_freifunk.sh62 58 63 59 # Configure found networks 64 60 for net in $networks; do 65 61 # radioX devices need to be renamed 66 62 netrenamed="${net/radio/wireless}" 67 63 export netrenamed 68 69 64 $dir/helpers/setup_network.sh $net 70 65 $dir/helpers/setup_wifi.sh $net
