Message ID | 20180609145129.28707-1-fabian@blaese.de |
---|---|
State | Superseded |
Headers | show |
diff --git a/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile new file mode 100644 index 0000000..62487f9 --- /dev/null +++ b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile @@ -0,0 +1,87 @@ +#!/bin/sh + +. /usr/share/libubox/jshn.sh +. /lib/functions/fff/wireless + +getWirelessHoodfile() { + if [ $# != 1 ] + then + echo "Usage: getWirelessHoodfile <download-location>" + return 1 + fi + file=$1 + + echo "Trying to get hoodfile from wireless neighbor..." + echo "All wireless interfaces will be disabled temporarily!" + + # only change temporarily + + if ! wifiDelIface; then + echo "Can't delete current wifi setup" + exit 1 + fi + #now we look for phy and add this + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do + radio="$(wifiAddPhyCond "$phy" "2" "auto")" + radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" + if [ -n "$radio5" ] ; then + radio="$radio5" + staiface="w5sta" + else + staiface="w2sta" + fi + + #and here we add the station + if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta" "$staiface" ; then + echo "Can't add Sta interface on $radio." + exit 1 + else + uci -q set network.configSta=interface + uci -q set network.configSta.proto='static' + uci -q commit network + reload_config + fi + done + + wifi + # wait a moment to start the interface + sleep 10; + + if wget -T15 -t5 -O "$file" "http://[fe80::1%w2sta]:2342/keyxchangev2data"; then + return 0 + elif wget -T15 -t5 -O "$file" "http://[fe80::1%w5sta]:2342/keyxchangev2data"; then + return 0 + else + return 1 + fi +} + +getGatewayHoodfile() { + if [ $# != 1 ] + then + echo "Usage: getGatewayHoodfile <download-location>" + return 1 + fi + file=$1 + + echo "Trying to get hoodfile from gateway..." + + if wget -T15 -t5 -O "$file" "http://[fe80::1%br-mesh]:2342/keyxchangev2data"; then + return 0 + else + return 1 + fi +} + +getKeyserverHoodfile() { + if [ $# != 1 ] + then + echo "Usage: getKeyserverHoodfile <download-location>" + return 1 + fi + file=$1 + + echo "Getting hoodfile from Keyserver" + + wget -T15 -t5 -O "$file" "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" +} diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood index e2c1fab..aee20e5 100755 --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood @@ -5,6 +5,7 @@ . /lib/functions/fff/network . /lib/functions/fff/wireless . /lib/functions/fff/timeserver +. /usr/lib/functions/fff/hoodfile sectorlocal=/etc/sectorfile sectortmp=/tmp/sectorfile @@ -78,7 +79,8 @@ if [ -s "$hoodlocal" ]; then else # if we have Internet, we download the Hoodfile from the keyxchangev2 if hasInternet ; then - wget -T15 -t5 "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O "$hoodfile" + getKeyserverHoodfile "$hoodfile" + rm -f "$sectortmp" [ -s "$sectorlocal" ] || rm -f "$sectorcopy" # If internet present, no custom config should be distributed, except when local file is present #UPLINK: No uplink download if internet present @@ -99,45 +101,15 @@ else sleep 30 # Wait for the config AP, which may be created at the same time as this script has started - if ! wifiDelIface; then - echo "Can't delete current wifi setup" - exit 1 - fi - #now we look for phy and add this - for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do - radio="$(wifiAddPhyCond "$phy" "2" "auto")" - radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" - if [ -n "$radio5" ] ; then - radio="$radio5" - staiface="w5sta" - else - staiface="w2sta" - fi + getWirelessHoodfile "$hoodfile" - #and here we add the station - if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta" "$staiface" ; then - echo "Can't add Sta interface on $radio." - exit 1 - else - uci -q set network.configSta=interface - uci -q set network.configSta.proto='static' - uci -q commit network - reload_config - fi - done - - wifi - # wait a moment to start the interface - sleep 10; - # and here we can download the Hoodfile from the other node - wget -T15 -t5 "http://[fe80::1%w2sta]:2342/keyxchangev2data" -O "$hoodfile" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/keyxchangev2data" -O "$hoodfile" #UPLINK: Set up uplink data on first contact: if [ -s /tmp/keyxchangev2data ]; then wget -T15 -t5 "http://[fe80::1%w2sta]:2342/sectorfile" -O "$sectortmp" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/sectorfile" -O "$sectortmp" fi else echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1" - wget -T15 -t5 "http://[fe80::1%br-mesh]:2342/keyxchangev2data" -O "$hoodfile" + getGatewayHoodfile "$hoodfile" #UPLINK: Do nothing fi fi
Anmerkung am Rand: Indentation ist kaputt, mach ich dann in der nächsten Version ganz.. Gruß Fabian > On 9. Jun 2018, at 16:51, Fabian Bläse <fabian@blaese.de> wrote: > > Signed-off-by: Fabian Bläse <fabian@blaese.de> > --- > .../fff-hoods/files/usr/lib/functions/fff/hoodfile | 87 ++++++++++++++++++++++ > .../fff/fff-hoods/files/usr/sbin/configurehood | 38 ++-------- > 2 files changed, 92 insertions(+), 33 deletions(-) > create mode 100644 src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > > diff --git a/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > new file mode 100644 > index 0000000..62487f9 > --- /dev/null > +++ b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > @@ -0,0 +1,87 @@ > +#!/bin/sh > + > +. /usr/share/libubox/jshn.sh > +. /lib/functions/fff/wireless > + > +getWirelessHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getWirelessHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Trying to get hoodfile from wireless neighbor..." > + echo "All wireless interfaces will be disabled temporarily!" > + > + # only change temporarily > + > + if ! wifiDelIface; then > + echo "Can't delete current wifi setup" > + exit 1 > + fi > + #now we look for phy and add this > + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > + radio="$(wifiAddPhyCond "$phy" "2" "auto")" > + radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" > + if [ -n "$radio5" ] ; then > + radio="$radio5" > + staiface="w5sta" > + else > + staiface="w2sta" > + fi > + > + #and here we add the station > + if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta" "$staiface" ; then > + echo "Can't add Sta interface on $radio." > + exit 1 > + else > + uci -q set network.configSta=interface > + uci -q set network.configSta.proto='static' > + uci -q commit network > + reload_config > + fi > + done > + > + wifi > + # wait a moment to start the interface > + sleep 10; > + > + if wget -T15 -t5 -O "$file" "http://[fe80::1%w2sta]:2342/keyxchangev2data"; then > + return 0 > + elif wget -T15 -t5 -O "$file" "http://[fe80::1%w5sta]:2342/keyxchangev2data"; then > + return 0 > + else > + return 1 > + fi > +} > + > +getGatewayHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getGatewayHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Trying to get hoodfile from gateway..." > + > + if wget -T15 -t5 -O "$file" "http://[fe80::1%br-mesh]:2342/keyxchangev2data"; then > + return 0 > + else > + return 1 > + fi > +} > + > +getKeyserverHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getKeyserverHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Getting hoodfile from Keyserver" > + > + wget -T15 -t5 -O "$file" "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" > +} > diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > index e2c1fab..aee20e5 100755 > --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > @@ -5,6 +5,7 @@ > . /lib/functions/fff/network > . /lib/functions/fff/wireless > . /lib/functions/fff/timeserver > +. /usr/lib/functions/fff/hoodfile > > sectorlocal=/etc/sectorfile > sectortmp=/tmp/sectorfile > @@ -78,7 +79,8 @@ if [ -s "$hoodlocal" ]; then > else > # if we have Internet, we download the Hoodfile from the keyxchangev2 > if hasInternet ; then > - wget -T15 -t5 "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O "$hoodfile" > + getKeyserverHoodfile "$hoodfile" > + > rm -f "$sectortmp" > [ -s "$sectorlocal" ] || rm -f "$sectorcopy" # If internet present, no custom config should be distributed, except when local file is present > #UPLINK: No uplink download if internet present > @@ -99,45 +101,15 @@ else > > sleep 30 # Wait for the config AP, which may be created at the same time as this script has started > > - if ! wifiDelIface; then > - echo "Can't delete current wifi setup" > - exit 1 > - fi > - #now we look for phy and add this > - for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > - radio="$(wifiAddPhyCond "$phy" "2" "auto")" > - radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" > - if [ -n "$radio5" ] ; then > - radio="$radio5" > - staiface="w5sta" > - else > - staiface="w2sta" > - fi > + getWirelessHoodfile "$hoodfile" > > - #and here we add the station > - if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta" "$staiface" ; then > - echo "Can't add Sta interface on $radio." > - exit 1 > - else > - uci -q set network.configSta=interface > - uci -q set network.configSta.proto='static' > - uci -q commit network > - reload_config > - fi > - done > - > - wifi > - # wait a moment to start the interface > - sleep 10; > - # and here we can download the Hoodfile from the other node > - wget -T15 -t5 "http://[fe80::1%w2sta]:2342/keyxchangev2data" -O "$hoodfile" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/keyxchangev2data" -O "$hoodfile" > #UPLINK: Set up uplink data on first contact: > if [ -s /tmp/keyxchangev2data ]; then > wget -T15 -t5 "http://[fe80::1%w2sta]:2342/sectorfile" -O "$sectortmp" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/sectorfile" -O "$sectortmp" > fi > else > echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1" > - wget -T15 -t5 "http://[fe80::1%br-mesh]:2342/keyxchangev2data" -O "$hoodfile" > + getGatewayHoodfile "$hoodfile" > #UPLINK: Do nothing > fi > fi > -- > 2.11.0 >
So nachdem ich jetzt doch recht lange hier gegrübelt habe. Doch, ja, ich denke ich habe den Patch verstanden und sieht für mich soweit gut aus. Wie geht das jetzt? Ich mach jetzt einfach Mal. Reviewed by Alex Gutzeit Fabian Bläse <fabian@blaese.de> schrieb am Sa., 9. Juni 2018, 19:31: > Anmerkung am Rand: Indentation ist kaputt, mach ich dann in der nächsten > Version ganz.. > > Gruß > Fabian > > > On 9. Jun 2018, at 16:51, Fabian Bläse <fabian@blaese.de> wrote: > > > > Signed-off-by: Fabian Bläse <fabian@blaese.de> > > --- > > .../fff-hoods/files/usr/lib/functions/fff/hoodfile | 87 > ++++++++++++++++++++++ > > .../fff/fff-hoods/files/usr/sbin/configurehood | 38 ++-------- > > 2 files changed, 92 insertions(+), 33 deletions(-) > > create mode 100644 > src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > > > > diff --git > a/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > > new file mode 100644 > > index 0000000..62487f9 > > --- /dev/null > > +++ b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > > @@ -0,0 +1,87 @@ > > +#!/bin/sh > > + > > +. /usr/share/libubox/jshn.sh > > +. /lib/functions/fff/wireless > > + > > +getWirelessHoodfile() { > > + if [ $# != 1 ] > > + then > > + echo "Usage: getWirelessHoodfile <download-location>" > > + return 1 > > + fi > > + file=$1 > > + > > + echo "Trying to get hoodfile from wireless neighbor..." > > + echo "All wireless interfaces will be disabled temporarily!" > > + > > + # only change temporarily > > + > > + if ! wifiDelIface; then > > + echo "Can't delete current wifi setup" > > + exit 1 > > + fi > > + #now we look for phy and add this > > + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > > + radio="$(wifiAddPhyCond "$phy" "2" "auto")" > > + radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" > > + if [ -n "$radio5" ] ; then > > + radio="$radio5" > > + staiface="w5sta" > > + else > > + staiface="w2sta" > > + fi > > + > > + #and here we add the station > > + if ! wifiAddSta "$radio" "config.franken.freifunk.net" > "configSta" "$staiface" ; then > > + echo "Can't add Sta interface on $radio." > > + exit 1 > > + else > > + uci -q set network.configSta=interface > > + uci -q set network.configSta.proto='static' > > + uci -q commit network > > + reload_config > > + fi > > + done > > + > > + wifi > > + # wait a moment to start the interface > > + sleep 10; > > + > > + if wget -T15 -t5 -O "$file" "http://[fe80::1%w2sta]:2342/keyxchangev2data"; > then > > + return 0 > > + elif wget -T15 -t5 -O "$file" "http://[fe80::1%w5sta]:2342/keyxchangev2data"; > then > > + return 0 > > + else > > + return 1 > > + fi > > +} > > + > > +getGatewayHoodfile() { > > + if [ $# != 1 ] > > + then > > + echo "Usage: getGatewayHoodfile <download-location>" > > + return 1 > > + fi > > + file=$1 > > + > > + echo "Trying to get hoodfile from gateway..." > > + > > + if wget -T15 -t5 -O "$file" "http://[fe80::1%br-mesh]:2342/keyxchangev2data"; > then > > + return 0 > > + else > > + return 1 > > + fi > > +} > > + > > +getKeyserverHoodfile() { > > + if [ $# != 1 ] > > + then > > + echo "Usage: getKeyserverHoodfile <download-location>" > > + return 1 > > + fi > > + file=$1 > > + > > + echo "Getting hoodfile from Keyserver" > > + > > + wget -T15 -t5 -O "$file" " > http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" > > +} > > diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > > index e2c1fab..aee20e5 100755 > > --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > > +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > > @@ -5,6 +5,7 @@ > > . /lib/functions/fff/network > > . /lib/functions/fff/wireless > > . /lib/functions/fff/timeserver > > +. /usr/lib/functions/fff/hoodfile > > > > sectorlocal=/etc/sectorfile > > sectortmp=/tmp/sectorfile > > @@ -78,7 +79,8 @@ if [ -s "$hoodlocal" ]; then > > else > > # if we have Internet, we download the Hoodfile from the > keyxchangev2 > > if hasInternet ; then > > - wget -T15 -t5 " > http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O > "$hoodfile" > > + getKeyserverHoodfile "$hoodfile" > > + > > rm -f "$sectortmp" > > [ -s "$sectorlocal" ] || rm -f "$sectorcopy" # If internet > present, no custom config should be distributed, except when local file is > present > > #UPLINK: No uplink download if internet present > > @@ -99,45 +101,15 @@ else > > > > sleep 30 # Wait for the config AP, which may be > created at the same time as this script has started > > > > - if ! wifiDelIface; then > > - echo "Can't delete current wifi setup" > > - exit 1 > > - fi > > - #now we look for phy and add this > > - for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); > do > > - radio="$(wifiAddPhyCond "$phy" "2" "auto")" > > - radio5="$(wifiAddPhyCond "$phy" "5" > "auto5")" > > - if [ -n "$radio5" ] ; then > > - radio="$radio5" > > - staiface="w5sta" > > - else > > - staiface="w2sta" > > - fi > > + getWirelessHoodfile "$hoodfile" > > > > - #and here we add the station > > - if ! wifiAddSta "$radio" " > config.franken.freifunk.net" "configSta" "$staiface" ; then > > - echo "Can't add Sta interface on > $radio." > > - exit 1 > > - else > > - uci -q set > network.configSta=interface > > - uci -q set > network.configSta.proto='static' > > - uci -q commit network > > - reload_config > > - fi > > - done > > - > > - wifi > > - # wait a moment to start the interface > > - sleep 10; > > - # and here we can download the Hoodfile from the > other node > > - wget -T15 -t5 "http://[fe80::1%w2sta]:2342/keyxchangev2data" > -O "$hoodfile" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/keyxchangev2data" > -O "$hoodfile" > > #UPLINK: Set up uplink data on first contact: > > if [ -s /tmp/keyxchangev2data ]; then > > wget -T15 -t5 "http://[fe80::1%w2sta]:2342/sectorfile" > -O "$sectortmp" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/sectorfile" > -O "$sectortmp" > > fi > > else > > echo "We have a Gateway in Range, we load the > keyxchangev2data from fe80::1" > > - wget -T15 -t5 "http://[fe80::1%br-mesh]:2342/keyxchangev2data" > -O "$hoodfile" > > + getGatewayHoodfile "$hoodfile" > > #UPLINK: Do nothing > > fi > > fi > > -- > > 2.11.0 > > > >
hi ich glaub es wurde gestern schon angesprochen, warum jetzt /usr/lib... und nicht /lib? Mir persönlich soll es aber egal sein daher: Reviewed-by: Christian Dresel <fff@chrisi01.de> mfg Christian On 09.06.2018 16:51, Fabian Bläse wrote: > Signed-off-by: Fabian Bläse <fabian@blaese.de> > --- > .../fff-hoods/files/usr/lib/functions/fff/hoodfile | 87 ++++++++++++++++++++++ > .../fff/fff-hoods/files/usr/sbin/configurehood | 38 ++-------- > 2 files changed, 92 insertions(+), 33 deletions(-) > create mode 100644 src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > > diff --git a/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > new file mode 100644 > index 0000000..62487f9 > --- /dev/null > +++ b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > @@ -0,0 +1,87 @@ > +#!/bin/sh > + > +. /usr/share/libubox/jshn.sh > +. /lib/functions/fff/wireless > + > +getWirelessHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getWirelessHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Trying to get hoodfile from wireless neighbor..." > + echo "All wireless interfaces will be disabled temporarily!" > + > + # only change temporarily > + > + if ! wifiDelIface; then > + echo "Can't delete current wifi setup" > + exit 1 > + fi > + #now we look for phy and add this > + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > + radio="$(wifiAddPhyCond "$phy" "2" "auto")" > + radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" > + if [ -n "$radio5" ] ; then > + radio="$radio5" > + staiface="w5sta" > + else > + staiface="w2sta" > + fi > + > + #and here we add the station > + if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta" "$staiface" ; then > + echo "Can't add Sta interface on $radio." > + exit 1 > + else > + uci -q set network.configSta=interface > + uci -q set network.configSta.proto='static' > + uci -q commit network > + reload_config > + fi > + done > + > + wifi > + # wait a moment to start the interface > + sleep 10; > + > + if wget -T15 -t5 -O "$file" "http://[fe80::1%w2sta]:2342/keyxchangev2data"; then > + return 0 > + elif wget -T15 -t5 -O "$file" "http://[fe80::1%w5sta]:2342/keyxchangev2data"; then > + return 0 > + else > + return 1 > + fi > +} > + > +getGatewayHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getGatewayHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Trying to get hoodfile from gateway..." > + > + if wget -T15 -t5 -O "$file" "http://[fe80::1%br-mesh]:2342/keyxchangev2data"; then > + return 0 > + else > + return 1 > + fi > +} > + > +getKeyserverHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getKeyserverHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Getting hoodfile from Keyserver" > + > + wget -T15 -t5 -O "$file" "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" > +} > diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > index e2c1fab..aee20e5 100755 > --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > @@ -5,6 +5,7 @@ > . /lib/functions/fff/network > . /lib/functions/fff/wireless > . /lib/functions/fff/timeserver > +. /usr/lib/functions/fff/hoodfile > > sectorlocal=/etc/sectorfile > sectortmp=/tmp/sectorfile > @@ -78,7 +79,8 @@ if [ -s "$hoodlocal" ]; then > else > # if we have Internet, we download the Hoodfile from the keyxchangev2 > if hasInternet ; then > - wget -T15 -t5 "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O "$hoodfile" > + getKeyserverHoodfile "$hoodfile" > + > rm -f "$sectortmp" > [ -s "$sectorlocal" ] || rm -f "$sectorcopy" # If internet present, no custom config should be distributed, except when local file is present > #UPLINK: No uplink download if internet present > @@ -99,45 +101,15 @@ else > > sleep 30 # Wait for the config AP, which may be created at the same time as this script has started > > - if ! wifiDelIface; then > - echo "Can't delete current wifi setup" > - exit 1 > - fi > - #now we look for phy and add this > - for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > - radio="$(wifiAddPhyCond "$phy" "2" "auto")" > - radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" > - if [ -n "$radio5" ] ; then > - radio="$radio5" > - staiface="w5sta" > - else > - staiface="w2sta" > - fi > + getWirelessHoodfile "$hoodfile" > > - #and here we add the station > - if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta" "$staiface" ; then > - echo "Can't add Sta interface on $radio." > - exit 1 > - else > - uci -q set network.configSta=interface > - uci -q set network.configSta.proto='static' > - uci -q commit network > - reload_config > - fi > - done > - > - wifi > - # wait a moment to start the interface > - sleep 10; > - # and here we can download the Hoodfile from the other node > - wget -T15 -t5 "http://[fe80::1%w2sta]:2342/keyxchangev2data" -O "$hoodfile" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/keyxchangev2data" -O "$hoodfile" > #UPLINK: Set up uplink data on first contact: > if [ -s /tmp/keyxchangev2data ]; then > wget -T15 -t5 "http://[fe80::1%w2sta]:2342/sectorfile" -O "$sectortmp" || wget -T15 -t5 "http://[fe80::1%w5sta]:2342/sectorfile" -O "$sectortmp" > fi > else > echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1" > - wget -T15 -t5 "http://[fe80::1%br-mesh]:2342/keyxchangev2data" -O "$hoodfile" > + getGatewayHoodfile "$hoodfile" > #UPLINK: Do nothing > fi > fi >
Am Sonntag, den 10.06.2018, 09:07 +0200 schrieb Christian Dresel: > hi > > ich glaub es wurde gestern schon angesprochen, warum jetzt > /usr/lib... > und nicht /lib? Mir persönlich soll es aber egal sein daher: Ja, das sollte schon einheitlich sein. Das wäre die erste "Lib", wo das nicht unter /lib/functions/fff liegen würde. Weiter wäre es gut, wenn gesagt wird, ob ein Patch zuvor applied werden müsste, damit der hier drauf geht. Mir ist aufgefallen, dass reload_config bei dir scheinbar bereits integriert ist. Tim > Reviewed-by: Christian Dresel <fff@chrisi01.de> > > mfg > > Christian > > On 09.06.2018 16:51, Fabian Bläse wrote: > > Signed-off-by: Fabian Bläse <fabian@blaese.de> > > --- > > .../fff-hoods/files/usr/lib/functions/fff/hoodfile | 87 > > ++++++++++++++++++++++ > > .../fff/fff-hoods/files/usr/sbin/configurehood | 38 ++-------- > > 2 files changed, 92 insertions(+), 33 deletions(-) > > create mode 100644 src/packages/fff/fff- > > hoods/files/usr/lib/functions/fff/hoodfile > > > > diff --git a/src/packages/fff/fff- > > hoods/files/usr/lib/functions/fff/hoodfile b/src/packages/fff/fff- > > hoods/files/usr/lib/functions/fff/hoodfile > > new file mode 100644 > > index 0000000..62487f9 > > --- /dev/null > > +++ b/src/packages/fff/fff- > > hoods/files/usr/lib/functions/fff/hoodfile > > @@ -0,0 +1,87 @@ > > +#!/bin/sh > > + > > +. /usr/share/libubox/jshn.sh > > +. /lib/functions/fff/wireless > > + > > +getWirelessHoodfile() { > > + if [ $# != 1 ] > > + then > > + echo "Usage: getWirelessHoodfile <download- > > location>" > > + return 1 > > + fi > > + file=$1 > > + > > + echo "Trying to get hoodfile from wireless neighbor..." > > + echo "All wireless interfaces will be disabled temporarily!" > > + > > + # only change temporarily > > + > > + if ! wifiDelIface; then > > + echo "Can't delete current wifi setup" > > + exit 1 > > + fi > > + #now we look for phy and add this > > + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > > + radio="$(wifiAddPhyCond "$phy" "2" "auto")" > > + radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" > > + if [ -n "$radio5" ] ; then > > + radio="$radio5" > > + staiface="w5sta" > > + else > > + staiface="w2sta" > > + fi > > + > > + #and here we add the station > > + if ! wifiAddSta "$radio" "config.franken.freifunk.net" > > "configSta" "$staiface" ; then > > + echo "Can't add Sta interface on $radio." > > + exit 1 > > + else > > + uci -q set network.configSta=interface > > + uci -q set network.configSta.proto='static' > > + uci -q commit network > > + reload_config > > + fi > > + done > > + > > + wifi > > + # wait a moment to start the interface > > + sleep 10; > > + > > + if wget -T15 -t5 -O "$file" "http://[fe80::1%w2sta]:2342/keyxc > > hangev2data"; then > > + return 0 > > + elif wget -T15 -t5 -O "$file" "http://[fe80::1%w5sta]:2342/key > > xchangev2data"; then > > + return 0 > > + else > > + return 1 > > + fi > > +} > > + > > +getGatewayHoodfile() { > > + if [ $# != 1 ] > > + then > > + echo "Usage: getGatewayHoodfile <download- > > location>" > > + return 1 > > + fi > > + file=$1 > > + > > + echo "Trying to get hoodfile from gateway..." > > + > > + if wget -T15 -t5 -O "$file" "http://[fe80::1%br-mesh]:2342/key > > xchangev2data"; then > > + return 0 > > + else > > + return 1 > > + fi > > +} > > + > > +getKeyserverHoodfile() { > > + if [ $# != 1 ] > > + then > > + echo "Usage: getKeyserverHoodfile <download- > > location>" > > + return 1 > > + fi > > + file=$1 > > + > > + echo "Getting hoodfile from Keyserver" > > + > > + wget -T15 -t5 -O "$file" "http://keyserver.freifunk-franken.de > > /v2/?lat=$lat&long=$long" > > +} > > diff --git a/src/packages/fff/fff- > > hoods/files/usr/sbin/configurehood b/src/packages/fff/fff- > > hoods/files/usr/sbin/configurehood > > index e2c1fab..aee20e5 100755 > > --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > > +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > > @@ -5,6 +5,7 @@ > > . /lib/functions/fff/network > > . /lib/functions/fff/wireless > > . /lib/functions/fff/timeserver > > +. /usr/lib/functions/fff/hoodfile > > > > sectorlocal=/etc/sectorfile > > sectortmp=/tmp/sectorfile > > @@ -78,7 +79,8 @@ if [ -s "$hoodlocal" ]; then > > else > > # if we have Internet, we download the Hoodfile from the > > keyxchangev2 > > if hasInternet ; then > > - wget -T15 -t5 "http://keyserver.freifunk-franken.d > > e/v2/?lat=$lat&long=$long" -O "$hoodfile" > > + getKeyserverHoodfile "$hoodfile" > > + > > rm -f "$sectortmp" > > [ -s "$sectorlocal" ] || rm -f "$sectorcopy" # If > > internet present, no custom config should be distributed, except > > when local file is present > > #UPLINK: No uplink download if internet present > > @@ -99,45 +101,15 @@ else > > > > sleep 30 # Wait for the config AP, which > > may be created at the same time as this script has started > > > > - if ! wifiDelIface; then > > - echo "Can't delete current wifi > > setup" > > - exit 1 > > - fi > > - #now we look for phy and add this > > - for phy in $(iw phy | awk '/^Wiphy/{ print > > $2 }'); do > > - radio="$(wifiAddPhyCond "$phy" "2" > > "auto")" > > - radio5="$(wifiAddPhyCond "$phy" > > "5" "auto5")" > > - if [ -n "$radio5" ] ; then > > - radio="$radio5" > > - staiface="w5sta" > > - else > > - staiface="w2sta" > > - fi > > + getWirelessHoodfile "$hoodfile" > > > > - #and here we add the station > > - if ! wifiAddSta "$radio" > > "config.franken.freifunk.net" "configSta" "$staiface" ; then > > - echo "Can't add Sta > > interface on $radio." > > - exit 1 > > - else > > - uci -q set > > network.configSta=interface > > - uci -q set > > network.configSta.proto='static' > > - uci -q commit network > > - reload_config > > - fi > > - done > > - > > - wifi > > - # wait a moment to start the interface > > - sleep 10; > > - # and here we can download the Hoodfile > > from the other node > > - wget -T15 -t5 "http://[fe80::1%w2sta]:2342 > > /keyxchangev2data" -O "$hoodfile" || wget -T15 -t5 > > "http://[fe80::1%w5sta]:2342/keyxchangev2data" -O "$hoodfile" > > #UPLINK: Set up uplink data on first > > contact: > > if [ -s /tmp/keyxchangev2data ]; then > > wget -T15 -t5 "http://[fe80::1%w2s > > ta]:2342/sectorfile" -O "$sectortmp" || wget -T15 -t5 > > "http://[fe80::1%w5sta]:2342/sectorfile" -O "$sectortmp" > > fi > > else > > echo "We have a Gateway in Range, we load > > the keyxchangev2data from fe80::1" > > - wget -T15 -t5 "http://[fe80::1%br-mesh]:23 > > 42/keyxchangev2data" -O "$hoodfile" > > + getGatewayHoodfile "$hoodfile" > > #UPLINK: Do nothing > > fi > > fi > > > >
Hallo Tim, > On 10. Jun 2018, at 11:23, Tim Niemeyer <tim@tn-x.org> wrote: > > Ja, das sollte schon einheitlich sein. Das wäre die erste "Lib", wo das > nicht unter /lib/functions/fff liegen würde. Wahrscheinlich gehören die alle eher nach /usr/lib, mir ist es aber an sich egal. Ich würde sie in der nächsten Version nach /lib packen, wenn keiner was dagegen hat. > Weiter wäre es gut, wenn gesagt wird, ob ein Patch zuvor applied werden > müsste, damit der hier drauf geht. Mir ist aufgefallen, dass > reload_config bei dir scheinbar bereits integriert ist. Jo, sollte unbedingt, hab ich leider vergessen.. Schon lange keine Patches mehr gemacht ;-) Gruß Fabian
Moin Alex, > On 9. Jun 2018, at 20:43, Alex Gutfried <alexgutfried@gmail.com> wrote: > > Wie geht das jetzt? > Ich mach jetzt einfach Mal. > > Reviewed by Alex Gutzeit Jo, fast. Siehe die Reviews der anderen. :-) Gruß Fabian
Am Sonntag, den 10.06.2018, 11:29 +0200 schrieb Fabian Bläse: > Hallo Tim, > > > On 10. Jun 2018, at 11:23, Tim Niemeyer <tim@tn-x.org> wrote: > > > > Ja, das sollte schon einheitlich sein. Das wäre die erste "Lib", wo > > das > > nicht unter /lib/functions/fff liegen würde. > > Wahrscheinlich gehören die alle eher nach /usr/lib, mir ist es aber > an sich egal. Warum sollten sie? > Ich würde sie in der nächsten Version nach /lib packen, wenn keiner > was dagegen hat. Ja bitte. Alle liegen dort. Die von den OpenWRT Packages und unsere auch. > > Weiter wäre es gut, wenn gesagt wird, ob ein Patch zuvor applied > > werden > > müsste, damit der hier drauf geht. Mir ist aufgefallen, dass > > reload_config bei dir scheinbar bereits integriert ist. > > Jo, sollte unbedingt, hab ich leider vergessen.. > Schon lange keine Patches mehr gemacht ;-) Ok, ich rätsel inzwischen weiter, was dein 2/2 Patch eigentlich tut. Tim > Gruß > Fabian
> On 10. Jun 2018, at 11:31, Tim Niemeyer <tim@tn-x.org> wrote: > > Warum sollten sie? Tja, darüber könnte man jetzt einen Glaubenskrieg führen. Nach /xy kommt normal der essentielle Kram (z.B. single-user mode, ..), nach /usr/xy der user-Kram. Vielleicht liegt auch das configurehood in /usr falsch. Wie auch immer, mir solls egal sein. Fabian
Am Sonntag, den 10.06.2018, 11:40 +0200 schrieb Fabian Bläse: > > On 10. Jun 2018, at 11:31, Tim Niemeyer <tim@tn-x.org> wrote: > > > > Warum sollten sie? > > Tja, darüber könnte man jetzt einen Glaubenskrieg führen. Nach /xy > kommt normal der essentielle Kram (z.B. single-user mode, ..), nach > /usr/xy der user-Kram. Hm.. > Vielleicht liegt auch das configurehood in /usr falsch. Wie auch > immer, mir solls egal sein. Ne, wahrscheinlich liegen die anderen functions einfach am falschen Platz. Tim > Fabian
Hi, ich bin fuer /usr/lib. Nach /lib gehoert das Systemzeugs. Robert Am 10.06.2018 um 11:49 schrieb Tim Niemeyer: > Am Sonntag, den 10.06.2018, 11:40 +0200 schrieb Fabian Bläse: >>> On 10. Jun 2018, at 11:31, Tim Niemeyer <tim@tn-x.org> wrote: >>> >>> Warum sollten sie? >> Tja, darüber könnte man jetzt einen Glaubenskrieg führen. Nach /xy >> kommt normal der essentielle Kram (z.B. single-user mode, ..), nach >> /usr/xy der user-Kram. > Hm.. > >> Vielleicht liegt auch das configurehood in /usr falsch. Wie auch >> immer, mir solls egal sein. > Ne, wahrscheinlich liegen die anderen functions einfach am falschen > Platz. > > Tim > >> Fabian
Am Sonntag, den 10.06.2018, 12:05 +0200 schrieb robert: > Hi, > > ich bin fuer /usr/lib. Nach /lib gehoert das Systemzeugs. Ok, dann machen wir das so. @Fabian: Bitte Patch nicht ändern. @Robert: https://mantis.freifunk-franken.de/view.php?id=100 Tim > > Robert > > > Am 10.06.2018 um 11:49 schrieb Tim Niemeyer: > > Am Sonntag, den 10.06.2018, 11:40 +0200 schrieb Fabian Bläse: > > > > On 10. Jun 2018, at 11:31, Tim Niemeyer <tim@tn-x.org> wrote: > > > > > > > > Warum sollten sie? > > > > > > Tja, darüber könnte man jetzt einen Glaubenskrieg führen. Nach > > > /xy > > > kommt normal der essentielle Kram (z.B. single-user mode, ..), > > > nach > > > /usr/xy der user-Kram. > > > > Hm.. > > > > > Vielleicht liegt auch das configurehood in /usr falsch. Wie auch > > > immer, mir solls egal sein. > > > > Ne, wahrscheinlich liegen die anderen functions einfach am falschen > > Platz. > > > > Tim > > > > > Fabian > >
Hallo,
wenn du meinst, die gehören alle nach /usr/lib, kann man das ja in einem eigenen Patch für alle dann irgendwann mal machen.
Ähnliches sollten wir dann auch für die leading whitespaces mal machen.
Grüße
Adrian
From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf Of Fabian Bläse
Sent: Sonntag, 10. Juni 2018 11:30
To: Tim Niemeyer <tim@tn-x.org>
Cc: franken-dev@freifunk.net
Subject: Re: [PATCH 1/2] Move hoodfile acquisition into function
Hallo Tim,
On 10. Jun 2018, at 11:23, Tim Niemeyer <tim@tn-x.org <mailto:tim@tn-x.org> > wrote:
Ja, das sollte schon einheitlich sein. Das wäre die erste "Lib", wo das
nicht unter /lib/functions/fff liegen würde.
Wahrscheinlich gehören die alle eher nach /usr/lib, mir ist es aber an sich egal.
Ich würde sie in der nächsten Version nach /lib packen, wenn keiner was dagegen hat.
Weiter wäre es gut, wenn gesagt wird, ob ein Patch zuvor applied werden
müsste, damit der hier drauf geht. Mir ist aufgefallen, dass
reload_config bei dir scheinbar bereits integriert ist.
Jo, sollte unbedingt, hab ich leider vergessen..
Schon lange keine Patches mehr gemacht ;-)
Gruß
Fabian
Hallo Fabian, ich würde auch hier die "download location" in "target file" umbennen. Ansonsten: Reviewed-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Grüße Adrian > -----Original Message----- > From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf > Of Fabian Bläse > Sent: Samstag, 9. Juni 2018 16:51 > To: franken-dev@freifunk.net > Subject: [PATCH 1/2] Move hoodfile acquisition into function > > Signed-off-by: Fabian Bläse <fabian@blaese.de> > --- > .../fff-hoods/files/usr/lib/functions/fff/hoodfile | 87 > ++++++++++++++++++++++ > .../fff/fff-hoods/files/usr/sbin/configurehood | 38 ++-------- > 2 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 > src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > > diff --git a/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > new file mode 100644 > index 0000000..62487f9 > --- /dev/null > +++ b/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile > @@ -0,0 +1,87 @@ > +#!/bin/sh > + > +. /usr/share/libubox/jshn.sh > +. /lib/functions/fff/wireless > + > +getWirelessHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getWirelessHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Trying to get hoodfile from wireless neighbor..." > + echo "All wireless interfaces will be disabled temporarily!" > + > + # only change temporarily > + > + if ! wifiDelIface; then > + echo "Can't delete current wifi setup" > + exit 1 > + fi > + #now we look for phy and add this > + for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > + radio="$(wifiAddPhyCond "$phy" "2" "auto")" > + radio5="$(wifiAddPhyCond "$phy" "5" "auto5")" > + if [ -n "$radio5" ] ; then > + radio="$radio5" > + staiface="w5sta" > + else > + staiface="w2sta" > + fi > + > + #and here we add the station > + if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta" > "$staiface" ; then > + echo "Can't add Sta interface on $radio." > + exit 1 > + else > + uci -q set network.configSta=interface > + uci -q set network.configSta.proto='static' > + uci -q commit network > + reload_config > + fi > + done > + > + wifi > + # wait a moment to start the interface > + sleep 10; > + > + if wget -T15 -t5 -O "$file" > "http://[fe80::1%w2sta]:2342/keyxchangev2data"; then > + return 0 > + elif wget -T15 -t5 -O "$file" > "http://[fe80::1%w5sta]:2342/keyxchangev2data"; then > + return 0 > + else > + return 1 > + fi > +} > + > +getGatewayHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getGatewayHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Trying to get hoodfile from gateway..." > + > + if wget -T15 -t5 -O "$file" "http://[fe80::1%br- > mesh]:2342/keyxchangev2data"; then > + return 0 > + else > + return 1 > + fi > +} > + > +getKeyserverHoodfile() { > + if [ $# != 1 ] > + then > + echo "Usage: getKeyserverHoodfile <download-location>" > + return 1 > + fi > + file=$1 > + > + echo "Getting hoodfile from Keyserver" > + > + wget -T15 -t5 -O "$file" "http://keyserver.freifunk- > franken.de/v2/?lat=$lat&long=$long" > +} > diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > index e2c1fab..aee20e5 100755 > --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood > @@ -5,6 +5,7 @@ > . /lib/functions/fff/network > . /lib/functions/fff/wireless > . /lib/functions/fff/timeserver > +. /usr/lib/functions/fff/hoodfile > > sectorlocal=/etc/sectorfile > sectortmp=/tmp/sectorfile > @@ -78,7 +79,8 @@ if [ -s "$hoodlocal" ]; then else > # if we have Internet, we download the Hoodfile from the > keyxchangev2 > if hasInternet ; then > - wget -T15 -t5 "http://keyserver.freifunk- > franken.de/v2/?lat=$lat&long=$long" -O "$hoodfile" > + getKeyserverHoodfile "$hoodfile" > + > rm -f "$sectortmp" > [ -s "$sectorlocal" ] || rm -f "$sectorcopy" # If internet > present, no custom config should be distributed, except when local file is > present > #UPLINK: No uplink download if internet present @@ -99,45 > +101,15 @@ else > > sleep 30 # Wait for the config AP, which may be > created at the same time as this script has started > > - if ! wifiDelIface; then > - echo "Can't delete current wifi setup" > - exit 1 > - fi > - #now we look for phy and add this > - for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do > - radio="$(wifiAddPhyCond "$phy" "2" "auto")" > - radio5="$(wifiAddPhyCond "$phy" "5" > "auto5")" > - if [ -n "$radio5" ] ; then > - radio="$radio5" > - staiface="w5sta" > - else > - staiface="w2sta" > - fi > + getWirelessHoodfile "$hoodfile" > > - #and here we add the station > - if ! wifiAddSta "$radio" > "config.franken.freifunk.net" "configSta" "$staiface" ; then > - echo "Can't add Sta interface on > $radio." > - exit 1 > - else > - uci -q set network.configSta=interface > - uci -q set > network.configSta.proto='static' > - uci -q commit network > - reload_config > - fi > - done > - > - wifi > - # wait a moment to start the interface > - sleep 10; > - # and here we can download the Hoodfile from the > other node > - wget -T15 -t5 > "http://[fe80::1%w2sta]:2342/keyxchangev2data" -O "$hoodfile" || wget - > T15 -t5 "http://[fe80::1%w5sta]:2342/keyxchangev2data" -O "$hoodfile" > #UPLINK: Set up uplink data on first contact: > if [ -s /tmp/keyxchangev2data ]; then > wget -T15 -t5 > "http://[fe80::1%w2sta]:2342/sectorfile" -O "$sectortmp" || wget -T15 -t5 > "http://[fe80::1%w5sta]:2342/sectorfile" -O "$sectortmp" > fi > else > echo "We have a Gateway in Range, we load the > keyxchangev2data from fe80::1" > - wget -T15 -t5 "http://[fe80::1%br- > mesh]:2342/keyxchangev2data" -O "$hoodfile" > + getGatewayHoodfile "$hoodfile" > #UPLINK: Do nothing > fi > fi > -- > 2.11.0
Signed-off-by: Fabian Bläse <fabian@blaese.de> --- .../fff-hoods/files/usr/lib/functions/fff/hoodfile | 87 ++++++++++++++++++++++ .../fff/fff-hoods/files/usr/sbin/configurehood | 38 ++-------- 2 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile