Changeset 7501

Show
Ignore:
Timestamp:
09/21/11 18:43:38 (20 months ago)
Author:
soma
Message:

contrib/meshwizard: Cleanup and add ssid_scheme option

Location:
luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/functions.sh

    r7208 r7501  
    1313} 
    1414 
     15# Takes 2 arguments 
     16# $1 = text to be displayed in the output for this section 
     17# $2 = section (optional) 
     18uci_commitverbose() { 
     19    echo "+ $1" 
     20    uci changes $2 | while read line; do 
     21        echo "    $line" 
     22    done 
     23    uci commit $2 
     24} 
     25 
    1526set_defaults() { 
    1627    for def in $(env |grep "^$1"); do 
    1728        option=${def/$1/} 
    1829        uci set $2.$option 
    19         echo "    ${option/=/: }" 
    2030    done 
    2131} 
     
    2939section_rename() { 
    3040    uci -q rename $1.$2=$3 && msg_rename $1.$2 $1.$3 || msg_rename_error $1.2 $1.$3 
    31 } 
    32  
    33 msg_start() { 
    34     echo "  Starting configuration of $1" 
    3541} 
    3642 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dhcp.sh

    r7208 r7501  
    2424uci batch << EOF 
    2525set dhcp.${netrenamed}dhcp="dhcp" 
    26 set dhcp.${netrenamed}dhcp.leasetime="${dhcp_leasetime}" 
    27 set dhcp.${netrenamed}dhcp.force="1" 
     26set dhcp.${netrenamed}dhcp.leasetime="$dhcp_leasetime" 
     27set dhcp.${netrenamed}dhcp.force="$dhcp_force" 
    2828set dhcp.${netrenamed}dhcp.interface="${netrenamed}dhcp" 
    2929EOF 
    3030 
    31 echo "    leasetime: ${dhcp_leasetime} 
    32     interface: ${netrenamed}dhcp" 
     31uci_commitverbose "Setup DHCP for $netrenamed" dhcp 
    3332 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_dnsmasq.sh

    r7208 r7501  
    1414config_foreach handle_dhcp dnsmasq 
    1515 
    16 echo "    + Setup dnsmasq" 
    17  
    1816uci set dhcp.dnsmasq.local="/$profile_suffix/" 
    1917uci set dhcp.dnsmasq.domain="$profile_suffix" 
    20  
    21 echo "    local: /$profile_suffix/ 
    22     domain: $profile_suffix" 
    2318 
    2419config_get addnhosts dnsmasq addnhosts 
    2520if [ -z "${addnhosts/\var\/etc\/hosts.olsr/}" ]; then 
    2621    uci add_list dhcp.dnsmasq.addnhosts="/var/etc/hosts.olsr" 
    27     echo "    addnhosts: /var/etc/hosts.olsr" 
    2822fi 
    2923 
    30 uci commit 
    31  
     24uci_commitverbose "Setup dnsmasq" dhcp 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_firewall.sh

    r7252 r7501  
    2020    fi 
    2121} 
    22 config_foreach handle_zonewan zone && echo "    + Enable local_restrict for zone wan" 
     22config_foreach handle_zonewan zone && uci_commitverbose "Enable local_restrict for zone wan" firewall 
    2323 
    2424# Delete old firewall zone for freifunk 
     
    7070# setup freifunk firewall zone 
    7171 
    72 echo "    + Setup firewall zone." 
    73  
    7472# add $netrenamed and if needed ${netrenamed}dhcp to the networks for this zone 
    7573config_get network zone_freifunk network 
     
    9492EOF 
    9593 
    96 echo "    network: $network 
    97     input: $zone_freifunk_input 
    98     forward: $zone_freifunk_forward 
    99     output: $zone_freifunk_output" 
     94uci_commitverbose "Setup freifunk firewall zone" firewall 
    10095 
    10196# Usually we need to setup masquerading for lan, except lan is an olsr interface or has an olsr hna 
    102  
    103 echo "    + Setup masquerading rules" 
    10497 
    10598handle_interface() { 
     
    122115currms=$(uci -q get firewall.zone_freifunk.masq_src) 
    123116if [ ! "$no_masq_lan" == "1" ]; then 
    124     uci set firewall.zone_freifunk.masq="1" && echo "    Enabled masquerading." || echo -e "\033[1mWarning:\033[0m: Could not enable masquerading." 
     117    uci set firewall.zone_freifunk.masq="1" 
    125118    [ -z "$(echo $currms |grep lan)" ] && uci add_list firewall.zone_freifunk.masq_src="lan" 
    126119fi 
     
    138131done 
    139132 
     133uci_commitverbose "Setup masquerading rules" firewall 
     134 
    140135# Rules, Forwardings, advanced config and includes 
    141136# Clear firewall configuration 
    142  
    143 echo "    + Setup rules, forwardings, advanced config and includes." 
    144137 
    145138for config in freifunk profile_$community; do 
     
    159152done 
    160153 
    161 uci commit 
     154uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_freifunk.sh

    r7381 r7501  
    22# Sets values in /etc/config/freifunk 
    33 
    4 . /etc/functions.sh 
    54. $dir/functions.sh 
    65 
     
    1211fi 
    1312 
     13uci_commitverbose "/etc/init.d/freifunk config" freifunk 
    1414 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_network.sh

    r7208 r7501  
    1515ipaddr=$(uci get meshwizard.netconfig.$net\_ip4addr) 
    1616[ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr 
    17  
    1817[ -z "$interface_netmask" ] && interface netmask="255.255.0.0" 
    1918 
     
    2625EOF 
    2726 
    28 echo "    IP address: $ipaddr" 
    29 echo "    Netmask   : $interface_netmask" 
     27uci_commitverbose "Setup interface $netrenamed" network 
    3028 
    3129# setup dhcp alias/interface 
     
    6967 
    7068    if [ "$vap" == 1 ]; then 
    71         echo "    + Setup interface ${netrenamed}dhcp." 
    7269        uci set network.${netrenamed}dhcp=interface 
    7370    else 
    74         echo "    + Setup alias interface ${netrenamed}dhcp." 
    7571        uci set network.${netrenamed}dhcp=alias 
    7672        uci set network.${netrenamed}dhcp.interface="$netrenamed" 
     
    8379EOF 
    8480 
    85     echo "    interface: $net 
    86     ipaddr: $START 
    87     netmask: $NETMASK" 
    88  
    8981fi 
    9082 
    91 uci commit 
     83uci_commitverbose  "Setup interface for ${netrenamed}dhcp" network 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_olsrd.sh

    r7208 r7501  
    66 
    77. /etc/functions.sh 
    8  
    98. $dir/functions.sh 
    109 
     
    2524# Setup new InterfaceDefaults 
    2625 
    27 echo "    + Setup InterfaceDefaults" 
    2826uci set olsrd.InterfaceDefaults=InterfaceDefaults 
    2927set_defaults "olsr_interfacedefaults_" olsrd.InterfaceDefaults 
     28uci_commitverbose "Setup olsr interface defaults" olsrd 
    3029 
    3130# Delete old interface for $netrenamed 
     
    4544# Setup new interface for $netrenamed 
    4645 
    47 echo "    + Setup Interface" 
     46uci set olsrd.$netrenamed=Interface 
     47set_defaults "olsr_interface_" olsrd.$net 
     48uci set olsrd.$netrenamed.interface="$netrenamed" 
    4849 
    49 uci set olsrd.$netrenamed=Interface 
    50  
    51 set_defaults "olsr_interface_" olsrd.$net 
    52  
    53 uci set olsrd.$netrenamed.interface="$netrenamed" 
    54 echo "    interface: $netrenamed" 
     50uci_commitverbose "Setup olsr interface for $netrenamed." olsrd 
    5551 
    5652# If dhcp-network is inside the mesh_network then add HNA for it 
     
    6460 
    6561if [ "$dhcpinmesh" == 1 ]; then 
    66     echo "    + Setting up HNA" 
    6762    uci set olsrd.${netrenamed}clients="Hna4" 
    6863    eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange) 
    6964    uci set olsrd.${netrenamed}clients.netaddr="$NETWORK" 
    7065    uci set olsrd.${netrenamed}clients.netmask="$NETMASK" 
    71     echo "    netaddr: $NETWORK" 
    72     echo "    natmask: $NETMASK" 
     66    uci_commitverbose "Setup HNA for network $dhcprange" olsrd 
    7367fi 
    7468 
     
    7670# Delete nameservice, dyngw and httpinfo plugins 
    7771 
    78 echo "    + Configure Plugins" 
    7972handle_plugin() { 
    8073        config_get library "$1" library 
     
    10699EOF 
    107100 
    108 echo "    Nameservice Plugin configured." 
     101uci_commitverbose "Setup olsr nameservice plugin" olsrd 
    109102 
    110103# Setup dyngw_plain 
     
    118111 
    119112if [ "$sharenet" == 1 ]; then 
    120     echo "    + Setup dyngw_plain" 
    121113    uci set olsrd.dyngw_plain=LoadPlugin 
    122114    uci set olsrd.dyngw_plain.ignore=0 
    123115    uci set olsrd.dyngw_plain.library="olsrd_dyn_gw_plain.so.0.4" 
     116    uci_commitverbose "Setup olsrd_dyngw_plain plugin" 
    124117fi 
    125118 
    126 uci commit 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_splash.sh

    r7252 r7501  
    2828EOF 
    2929 
    30 echo "    network: ${netrenamed}dhcp" 
    31  
    32 uci commit 
     30uci_commitverbose "Setup dhcpsplash for ${netrenamed}dhcp" luci_splash 
    3331 
    3432/etc/init.d/luci_splash enable 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_system.sh

    r7264 r7501  
    22# Sets values from /etc/config/freifunk and/or the community profile in /etc/config/system 
    33 
     4. $dir/functions.sh 
     5 
    46if [ -n "$(env | grep '^system_')" ]; then 
    5     echo "++++ Setup system" 
    67    env | grep "^system_" | sed "s/system_/uci set system.system./g" | while read line; do 
    78        eval $line 
    8         echo "    $line" 
    99    done 
    1010fi 
    1111 
    12 uci commit system 
     12uci_commitverbose "System config" system 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_wifi.sh

    r7208 r7501  
    88 
    99##### wifi-device ##### 
    10  
    11 echo "    + Setup wifi-device" 
    1210 
    1311# Get the type before we delete the wifi-device 
     
    4644EOF 
    4745 
    48 echo "    Type: $type" 
    49 echo "    Channel: $channel" 
     46uci_commitverbose "Setup wifi device for $netrenamed" wireless 
    5047 
    5148##### wifi iface 
    52  
    53 echo "    + Setup wifi-iface" 
    5449 
    5550# Delete old wifi-iface for $net 
     
    7671# overwrite defaults 
    7772bssid="$($dir/helpers/gen_bssid.sh $channel $community)" 
     73ssid="$profile_ssid" 
     74if [ "$profile_ssid_scheme" == "addchannel" ]; then 
     75    ssid="$ssid - ch$channel" 
     76fi 
     77 
    7878uci batch << EOF 
    7979set wireless.$net\_iface.device="${net}" 
    8080set wireless.$net\_iface.network="$netrenamed" 
    81 set wireless.$net\_iface.ssid="$profile_ssid - ch$channel" 
     81set wireless.$net\_iface.ssid="$ssid" 
    8282set wireless.$net\_iface.bssid="$bssid" 
    8383EOF 
    8484 
    85 echo "    device: $net 
    86     network: $netrenamed 
    87     ssid: $profile_ssid - ch$channel 
    88     bssid: $bssid" 
     85uci_commitverbose "Setup wifi interface for $netrenamed" wireless 
    8986 
    9087## VAP 
     
    9996set wireless.$net\_iface_dhcp.ssid="FF-AP-$ip4addr" 
    10097EOF 
    101     echo "    + Setting up VAP interface for $net 
    102     device: $net 
    103     network: ${netrenamed}dhcp 
    104     ssid: AP-$profile_ssid-$ip4addr" 
     98    uci_commitverbose "Setup VAP interface for $netrenamed" wireless 
    10599fi 
    106100 
    107 uci commit 
  • luci/trunk/contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh

    r7381 r7501  
    44 
    55. /etc/functions.sh 
     6 
     7echo " 
     8Meshwizard 0.0.3 
     9" 
    610 
    711# config 
     
    1115 
    1216# Rename wifi interfaces 
    13     echo "++++ Renaming wifi-devices in /etc/config/meshwizard" 
     17    echo "+ Renaming wifi-devices in /etc/config/meshwizard" 
    1418    $dir/helpers/rename-wifi.sh 
    1519 
    1620# Firstboot/initial config 
    17     echo "++++ Initial config" 
     21    echo "+ Initial config" 
    1822    $dir/helpers/initial_config.sh 
    1923 
     
    3337[ -z "$networks" ] && echo "Error: No networks to setup could be found in /etc/config/meshwizard, aborting now." && exit 1 
    3438 
    35 echo "+++ wizard 0.0.2 +++ 
    36 Community=$community 
    37 Network(s)=$networks" 
     39echo "    Community=$community 
     40    Network(s)=$networks" 
    3841 
    3942# Read default values (first from /etc/config/freifunk, then from /etc/config/profile_$community, 
     
    4649done < /tmp/meshwizard.tmp 
    4750 
    48 # dnsmasq 
    49     echo "++++ dnsmasq config" 
    50     $dir/helpers/setup_dnsmasq.sh 
    51  
    52 # system 
    53     echo "++++ system config" 
    54     $dir/helpers/setup_system.sh 
    55  
    56 # freifunk 
    57     echo "++++ /etc/config/freifunk config" 
    58         $dir/helpers/setup_freifunk.sh 
     51$dir/helpers/setup_dnsmasq.sh 
     52$dir/helpers/setup_system.sh 
     53$dir/helpers/setup_freifunk.sh 
    5954 
    6055# Configure found networks 
     
    6459    export netrenamed 
    6560 
    66     echo "++++ Configure interface $net" 
    67  
    68     config="network" 
    69     echo "$(msg_start $config)" 
    7061    $dir/helpers/setup_network.sh $net 
    71  
    72     config="wireless" 
    73     echo "$(msg_start $config)" 
    7462    $dir/helpers/setup_wifi.sh $net 
    75  
    76     config="OLSRd" 
    77     echo "$(msg_start $config)" 
    7863    $dir/helpers/setup_olsrd.sh $net 
    7964 
    8065    net_dhcp=$(uci -q get meshwizard.netconfig.${net}_dhcp) 
    8166    if [ "$net_dhcp" == 1 ]; then 
    82         config="DHCP" 
    83         echo "$(msg_start $config)" 
    8467        $dir/helpers/setup_dhcp.sh $net 
    8568    fi 
    8669 
    87     config="luci_splash" 
    88     echo "$(msg_start $config)" 
    8970    $dir/helpers/setup_splash.sh $net 
    90  
    91     config="firewall" 
    92     echo "$(msg_start $config)" 
    9371    $dir/helpers/setup_firewall.sh $net 
    94  
    95     echo "  Configuration of $net finished." 
    9672done 
    9773