[v9,4/4] Add fff-hoods

Submitted by Adrian Schmutzler on Sept. 21, 2017, 2:02 p.m.

Details

Message ID 1506002558-2286-4-git-send-email-freifunk@adrianschmutzler.de
State Superseded
Headers show

Commit Message

Adrian Schmutzler Sept. 21, 2017, 2:02 p.m.
From: Christian Dresel <fff@chrisi01.de>

this packages connect to keyxchangev2
after review we must change the serveradress! This is only a example

Signed-off-by: Christian Dresel <fff@chrisi01.de>
Signed-off-by: Jan Kraus <mayosemmel@gmail.com>

Update in v2:
 - clean tabstops
 - move the json vpn out of the if because we need this after reboot

Update in v5:
	!!UNTESTED!!
 - change hidden AP ip to locallink
 - Open hidden AP after more checks
 - Load json File from Gateway if Gateway in Batman in Range

Update in v6:
	!!UNTESTED!!
 - fix hidden station v6
 - fix -n to -f if
 - Add function to check for a gateway and use this
 - remove /etc/community.cfg and variables
 - send fewer infos to keyxchangev2
 - add a check if /tmp/keyxchangev2 not downloadable and edit a bit  on the wgets
 - change the position from json_load and do this only 1 times

Update in v7:
	!!UNTESTED!!
 - delete keyxchangev2data at start of the script
 - do only things with keyxchangev2data if available
 - change keyxchangev2 url

Update in v8/v9:
 - rebase onto 20170918-beta
---
 src/packages/fff/fff-hoods/Makefile                |  39 ++++
 .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
 .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
 .../fff/fff-hoods/files/usr/sbin/configurehood     | 205 +++++++++++++++++++++
 4 files changed, 250 insertions(+)
 create mode 100644 src/packages/fff/fff-hoods/Makefile
 create mode 100644 src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
 create mode 100644 src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
 create mode 100755 src/packages/fff/fff-hoods/files/usr/sbin/configurehood

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-hoods/Makefile b/src/packages/fff/fff-hoods/Makefile
new file mode 100644
index 0000000..f85178d
--- /dev/null
+++ b/src/packages/fff/fff-hoods/Makefile
@@ -0,0 +1,39 @@ 
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=fff-hoods
+PKG_VERSION:=0.0.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fff-hoods
+    SECTION:=base
+    CATEGORY:=Freifunk
+    TITLE:= Freifunk-Franken hoods
+    URL:=http://www.freifunk-franken.de
+    DEPENDS:=+fff-network
+endef
+
+define Package/fff-hoods/description
+    This package load and configures the current hood
+endef
+
+define Build/Prepare
+	echo "all: " > $(PKG_BUILD_DIR)/Makefile
+endef
+
+define Build/Configure
+	# nothing
+endef
+
+define Build/Compile
+	# nothing
+endef
+
+define Package/fff-hoods/install
+	$(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,fff-hoods))
diff --git a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
new file mode 100644
index 0000000..49f53e3
--- /dev/null
+++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
@@ -0,0 +1,5 @@ 
+#!/bin/sh 
+[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
+       sleep 3
+       /usr/sbin/configurehood
+}
diff --git a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
new file mode 100644
index 0000000..ca8d798
--- /dev/null
+++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
@@ -0,0 +1 @@ 
+*/5 * * * * /usr/sbin/configurehood
diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
new file mode 100755
index 0000000..bfec822
--- /dev/null
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -0,0 +1,205 @@ 
+#!/bin/sh
+
+. /usr/share/libubox/jshn.sh
+. /lib/functions/fff/wireless
+
+rm /tmp/keyxchangev2data
+
+#Gatewaycheck function
+isGatewayAvailable() {
+	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
+		return true;
+	else
+		return false;
+	fi
+}
+
+
+# hidden AP check
+
+if [ -f /tmp/hiddenapflag ]; then
+	if [ isGatewayAvailable ]; then
+		if ! wifiAddAP "$radio" "config.franken.freifunk.net" "configap" "configap" "1"; then
+			echo "Can't add AP interface on $radio."
+			exit 1
+		else
+			#we must set here a fix ip adress
+			uci set network.configap=interface
+			uci set network.configap.proto='static'
+			uci set network.configap.ip6addr='fe80::1/64'
+			uci commit network
+		fi
+	else
+		rm /tmp/hiddenapflag
+	fi
+fi
+
+
+lat=$(uci get system.@system[0].latitude)
+long=$(uci get system.@system[0].longitude)
+hostname=$(cat /proc/sys/kernel/hostname)
+[ "$hostname" = "OpenWrt" ] && hostname=""
+[ "$hostname" = "" ] &&  hostname="$mac"
+
+test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken keyserver
+test_ipv4_host2="8.8.8.8"        # Google DNS
+test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
+
+# if we have Internet, we download the Hoodfile from the keyxchangev2
+if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
+	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
+	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
+	wget -T15 -t5 "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
+	#if no Internet, we connect to the hidden AP and download the file from another Node in range 
+else
+	# connect to wireless hidden ap here and download from the next router the json File -O /tmp/keyxchangev2data
+	# only to that, when we have no gateway in range. If the Uplinkrouter change the hood, we lost the GW and to this automatically again i think! Nice idea?
+	if [ ! isGatewayAvailable ]; then
+		#now we haven't a gateway in Range, we search for a hidden AP to get a keyxchangev2data file!
+		#first we delete all wifi settings
+		if ! wifiDelAll; 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
+			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
+				echo "$phy is 2.4 GHz"
+				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
+				if [ -z "$radio" ]; then
+					echo "Can't create radio for $phy"
+					exit 1
+				fi
+			fi
+			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
+				echo "$phy is 5 GHz"
+				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
+				if [ -z "$radio" ]; then
+					echo "Can't create radio for $phy"
+					exit 1
+				fi
+			fi
+			#and here we add the station
+			if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta"; then
+				echo "Can't add Sta interface on $radio."
+				exit 1
+			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]/keyxchangev2data" -O /tmp/keyxchangev2data   
+	else
+		echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
+		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data" -O /tmp/keyxchangev2data 
+	fi
+
+
+fi
+
+if [ -s /tmp/keyxchangev2data ]; then
+
+	# we get a json file in this format: 
+	# https://pw.freifunk-franken.de/patch/205/
+	# but without signature, every hood file we get is valid!
+
+	json_load "$(cat /tmp/keyxchangev2data)"
+	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
+	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d " ")
+	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then
+		echo "New file detect, we reconfigure the Node";
+
+		# copy the file to webroot that other Meshrouter can download them
+		cp /tmp/keyxchangev2data /www/public/
+
+		json_select hood
+
+		json_get_var hood name
+		json_get_var mesh_bssid mesh_bssid
+		json_get_var mesh_essid mesh_essid
+		json_get_var essid essid
+		# i think the next things we don't active this in the first version! we can do it later
+		#json_get_var channel2 channel2
+		#json_get_var mode2 mode2
+		#json_get_var type2 type2
+		#json_get_var channel5 channel5
+		#json_get_var mode5 mode5
+		#json_get_var type5 type5
+		#json_get_var protocol protocol
+
+		echo "Setting hood name: $hood"
+		uci set system.@system[0].hood=$hood
+
+		if ! wifiDelAll; then
+			echo "Can't delete current wifi setup"
+			exit 1
+		fi
+
+		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
+			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
+				echo "$phy is 2.4 GHz"
+				radio=$(wifiAddPhy "$phy" "1")
+				if [ -z "$radio" ]; then
+					echo "Can't create radio for $phy"
+					exit 1
+				fi
+			fi
+			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
+				echo "$phy is 5 GHz"
+				radio=$(wifiAddPhy "$phy" "13")
+				if [ -z "$radio" ]; then
+					echo "Can't create radio for $phy"
+					exit 1
+				fi
+			fi
+
+			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0"; then
+				echo "Can't add AP interface on $radio."
+				exit 1
+			fi
+
+			# here we set a bit for add hidden AP
+			touch /tmp/hiddenapflag
+
+			if ! wifiAddAdHocMesh "$radio" "$mesh_essid" "$mesh_bssid"; then
+				echo "Can't add AP interface on $radio."
+				exit 1
+			fi
+		done
+
+		echo "Loading wifi"
+		wifi
+
+
+	else
+		echo "we have no new file or we have no file get. We do nothing. We try it again in 5 minutes...";
+	fi
+
+	# and now we read the VPN Data and give this data to fff-vpn
+
+	json_select vpn
+	Index="1"
+	rm /tmp/fastd_fff_output
+	touch /tmp/fastd_fff_output
+	while json_select $Index > /dev/null
+	do                                                                                                                                                                                            
+		json_get_var protocol protocol                                                                                                                                                            
+		if [ "$protocol" == "fastd"]; then
+			json_get_var servername name
+			echo "####$servername.conf" >> /tmp/fastd_fff_output
+			echo "#name \"$servername\";" >> /tmp/fastd_fff_output
+			json_get_var key key
+			echo "key \"$key\";" >> /tmp/fastd_fff_output
+			json_get_var address address
+			json_get_var port port
+			echo "remote ipv4 \"$address\" port $port float;" >> /tmp/fastd_fff_output
+		fi
+		echo "" >> /tmp/fastd_fff_output
+		echo "###" >> /tmp/fastd_fff_output
+	done
+	#this we do every 5 minutes, because it can change the VPN Protocol
+	#and now we get to vpn-select Script and load VPNs
+	sh /usr/sbin/vpn-select
+fi

Comments

Christian Dresel Sept. 27, 2017, 7:54 a.m.
hi

Das ganze Paket muss noch in der fff-base aktiviert werden, das hab aber
wohl schon ich vermasselt da es wohl auch schon in den früheren
Patchversionen von mir fehlt. Sollte bei der nächsten Version mit
nachgetragen werden.

mfg

Christian

(sry wegen der doppelten Mail, ich hab die Absenderadresse mal wieder
vermurkst...)

On 21.09.2017 16:02, Adrian Schmutzler wrote:
> From: Christian Dresel <fff@chrisi01.de>
>
> this packages connect to keyxchangev2
> after review we must change the serveradress! This is only a example
>
> Signed-off-by: Christian Dresel <fff@chrisi01.de>
> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
>
> Update in v2:
>  - clean tabstops
>  - move the json vpn out of the if because we need this after reboot
>
> Update in v5:
> 	!!UNTESTED!!
>  - change hidden AP ip to locallink
>  - Open hidden AP after more checks
>  - Load json File from Gateway if Gateway in Batman in Range
>
> Update in v6:
> 	!!UNTESTED!!
>  - fix hidden station v6
>  - fix -n to -f if
>  - Add function to check for a gateway and use this
>  - remove /etc/community.cfg and variables
>  - send fewer infos to keyxchangev2
>  - add a check if /tmp/keyxchangev2 not downloadable and edit a bit  on the wgets
>  - change the position from json_load and do this only 1 times
>
> Update in v7:
> 	!!UNTESTED!!
>  - delete keyxchangev2data at start of the script
>  - do only things with keyxchangev2data if available
>  - change keyxchangev2 url
>
> Update in v8/v9:
>  - rebase onto 20170918-beta
> ---
>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205 +++++++++++++++++++++
>  4 files changed, 250 insertions(+)
>  create mode 100644 src/packages/fff/fff-hoods/Makefile
>  create mode 100644 src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>  create mode 100644 src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>  create mode 100755 src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>
> diff --git a/src/packages/fff/fff-hoods/Makefile b/src/packages/fff/fff-hoods/Makefile
> new file mode 100644
> index 0000000..f85178d
> --- /dev/null
> +++ b/src/packages/fff/fff-hoods/Makefile
> @@ -0,0 +1,39 @@
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=fff-hoods
> +PKG_VERSION:=0.0.1
> +PKG_RELEASE:=1
> +
> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
> +
> +include $(INCLUDE_DIR)/package.mk
> +
> +define Package/fff-hoods
> +    SECTION:=base
> +    CATEGORY:=Freifunk
> +    TITLE:= Freifunk-Franken hoods
> +    URL:=http://www.freifunk-franken.de
> +    DEPENDS:=+fff-network
> +endef
> +
> +define Package/fff-hoods/description
> +    This package load and configures the current hood
> +endef
> +
> +define Build/Prepare
> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile
> +endef
> +
> +define Build/Configure
> +	# nothing
> +endef
> +
> +define Build/Compile
> +	# nothing
> +endef
> +
> +define Package/fff-hoods/install
> +	$(CP) ./files/* $(1)/
> +endef
> +
> +$(eval $(call BuildPackage,fff-hoods))
> diff --git a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
> new file mode 100644
> index 0000000..49f53e3
> --- /dev/null
> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
> @@ -0,0 +1,5 @@
> +#!/bin/sh 
> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
> +       sleep 3
> +       /usr/sbin/configurehood
> +}
> diff --git a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
> new file mode 100644
> index 0000000..ca8d798
> --- /dev/null
> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
> @@ -0,0 +1 @@
> +*/5 * * * * /usr/sbin/configurehood
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> new file mode 100755
> index 0000000..bfec822
> --- /dev/null
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -0,0 +1,205 @@
> +#!/bin/sh
> +
> +. /usr/share/libubox/jshn.sh
> +. /lib/functions/fff/wireless
> +
> +rm /tmp/keyxchangev2data
> +
> +#Gatewaycheck function
> +isGatewayAvailable() {
> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
> +		return true;
> +	else
> +		return false;
> +	fi
> +}
> +
> +
> +# hidden AP check
> +
> +if [ -f /tmp/hiddenapflag ]; then
> +	if [ isGatewayAvailable ]; then
> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net" "configap" "configap" "1"; then
> +			echo "Can't add AP interface on $radio."
> +			exit 1
> +		else
> +			#we must set here a fix ip adress
> +			uci set network.configap=interface
> +			uci set network.configap.proto='static'
> +			uci set network.configap.ip6addr='fe80::1/64'
> +			uci commit network
> +		fi
> +	else
> +		rm /tmp/hiddenapflag
> +	fi
> +fi
> +
> +
> +lat=$(uci get system.@system[0].latitude)
> +long=$(uci get system.@system[0].longitude)
> +hostname=$(cat /proc/sys/kernel/hostname)
> +[ "$hostname" = "OpenWrt" ] && hostname=""
> +[ "$hostname" = "" ] &&  hostname="$mac"
> +
> +test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken keyserver
> +test_ipv4_host2="8.8.8.8"        # Google DNS
> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
> +
> +# if we have Internet, we download the Hoodfile from the keyxchangev2
> +if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
> +	wget -T15 -t5 "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
> +	#if no Internet, we connect to the hidden AP and download the file from another Node in range 
> +else
> +	# connect to wireless hidden ap here and download from the next router the json File -O /tmp/keyxchangev2data
> +	# only to that, when we have no gateway in range. If the Uplinkrouter change the hood, we lost the GW and to this automatically again i think! Nice idea?
> +	if [ ! isGatewayAvailable ]; then
> +		#now we haven't a gateway in Range, we search for a hidden AP to get a keyxchangev2data file!
> +		#first we delete all wifi settings
> +		if ! wifiDelAll; 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
> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
> +				echo "$phy is 2.4 GHz"
> +				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
> +				if [ -z "$radio" ]; then
> +					echo "Can't create radio for $phy"
> +					exit 1
> +				fi
> +			fi
> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
> +				echo "$phy is 5 GHz"
> +				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
> +				if [ -z "$radio" ]; then
> +					echo "Can't create radio for $phy"
> +					exit 1
> +				fi
> +			fi
> +			#and here we add the station
> +			if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta"; then
> +				echo "Can't add Sta interface on $radio."
> +				exit 1
> +			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]/keyxchangev2data" -O /tmp/keyxchangev2data   
> +	else
> +		echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data" -O /tmp/keyxchangev2data 
> +	fi
> +
> +
> +fi
> +
> +if [ -s /tmp/keyxchangev2data ]; then
> +
> +	# we get a json file in this format: 
> +	# https://pw.freifunk-franken.de/patch/205/
> +	# but without signature, every hood file we get is valid!
> +
> +	json_load "$(cat /tmp/keyxchangev2data)"
> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d " ")
> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then
> +		echo "New file detect, we reconfigure the Node";
> +
> +		# copy the file to webroot that other Meshrouter can download them
> +		cp /tmp/keyxchangev2data /www/public/
> +
> +		json_select hood
> +
> +		json_get_var hood name
> +		json_get_var mesh_bssid mesh_bssid
> +		json_get_var mesh_essid mesh_essid
> +		json_get_var essid essid
> +		# i think the next things we don't active this in the first version! we can do it later
> +		#json_get_var channel2 channel2
> +		#json_get_var mode2 mode2
> +		#json_get_var type2 type2
> +		#json_get_var channel5 channel5
> +		#json_get_var mode5 mode5
> +		#json_get_var type5 type5
> +		#json_get_var protocol protocol
> +
> +		echo "Setting hood name: $hood"
> +		uci set system.@system[0].hood=$hood
> +
> +		if ! wifiDelAll; then
> +			echo "Can't delete current wifi setup"
> +			exit 1
> +		fi
> +
> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
> +				echo "$phy is 2.4 GHz"
> +				radio=$(wifiAddPhy "$phy" "1")
> +				if [ -z "$radio" ]; then
> +					echo "Can't create radio for $phy"
> +					exit 1
> +				fi
> +			fi
> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
> +				echo "$phy is 5 GHz"
> +				radio=$(wifiAddPhy "$phy" "13")
> +				if [ -z "$radio" ]; then
> +					echo "Can't create radio for $phy"
> +					exit 1
> +				fi
> +			fi
> +
> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0"; then
> +				echo "Can't add AP interface on $radio."
> +				exit 1
> +			fi
> +
> +			# here we set a bit for add hidden AP
> +			touch /tmp/hiddenapflag
> +
> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid" "$mesh_bssid"; then
> +				echo "Can't add AP interface on $radio."
> +				exit 1
> +			fi
> +		done
> +
> +		echo "Loading wifi"
> +		wifi
> +
> +
> +	else
> +		echo "we have no new file or we have no file get. We do nothing. We try it again in 5 minutes...";
> +	fi
> +
> +	# and now we read the VPN Data and give this data to fff-vpn
> +
> +	json_select vpn
> +	Index="1"
> +	rm /tmp/fastd_fff_output
> +	touch /tmp/fastd_fff_output
> +	while json_select $Index > /dev/null
> +	do                                                                                                                                                                                            
> +		json_get_var protocol protocol                                                                                                                                                            
> +		if [ "$protocol" == "fastd"]; then
> +			json_get_var servername name
> +			echo "####$servername.conf" >> /tmp/fastd_fff_output
> +			echo "#name \"$servername\";" >> /tmp/fastd_fff_output
> +			json_get_var key key
> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
> +			json_get_var address address
> +			json_get_var port port
> +			echo "remote ipv4 \"$address\" port $port float;" >> /tmp/fastd_fff_output
> +		fi
> +		echo "" >> /tmp/fastd_fff_output
> +		echo "###" >> /tmp/fastd_fff_output
> +	done
> +	#this we do every 5 minutes, because it can change the VPN Protocol
> +	#and now we get to vpn-select Script and load VPNs
> +	sh /usr/sbin/vpn-select
> +fi
Christian Dresel Sept. 27, 2017, 8:52 a.m.
Falls jemand damit arbeiten will, einige Syntaxfehler:

On 27.09.2017 09:54, Christian Dresel wrote:
> hi
> 
> Das ganze Paket muss noch in der fff-base aktiviert werden, das hab aber
> wohl schon ich vermasselt da es wohl auch schon in den früheren
> Patchversionen von mir fehlt. Sollte bei der nächsten Version mit
> nachgetragen werden.
> 
> mfg
> 
> Christian
> 
> (sry wegen der doppelten Mail, ich hab die Absenderadresse mal wieder
> vermurkst...)
> 
> On 21.09.2017 16:02, Adrian Schmutzler wrote:
>> From: Christian Dresel <fff@chrisi01.de>
>>
>> this packages connect to keyxchangev2
>> after review we must change the serveradress! This is only a example
>>
>> Signed-off-by: Christian Dresel <fff@chrisi01.de>
>> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
>>
>> Update in v2:
>>  - clean tabstops
>>  - move the json vpn out of the if because we need this after reboot
>>
>> Update in v5:
>> 	!!UNTESTED!!
>>  - change hidden AP ip to locallink
>>  - Open hidden AP after more checks
>>  - Load json File from Gateway if Gateway in Batman in Range
>>
>> Update in v6:
>> 	!!UNTESTED!!
>>  - fix hidden station v6
>>  - fix -n to -f if
>>  - Add function to check for a gateway and use this
>>  - remove /etc/community.cfg and variables
>>  - send fewer infos to keyxchangev2
>>  - add a check if /tmp/keyxchangev2 not downloadable and edit a bit  on the wgets
>>  - change the position from json_load and do this only 1 times
>>
>> Update in v7:
>> 	!!UNTESTED!!
>>  - delete keyxchangev2data at start of the script
>>  - do only things with keyxchangev2data if available
>>  - change keyxchangev2 url
>>
>> Update in v8/v9:
>>  - rebase onto 20170918-beta
>> ---
>>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
>>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
>>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
>>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205 +++++++++++++++++++++
>>  4 files changed, 250 insertions(+)
>>  create mode 100644 src/packages/fff/fff-hoods/Makefile
>>  create mode 100644 src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>  create mode 100644 src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>  create mode 100755 src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>
>> diff --git a/src/packages/fff/fff-hoods/Makefile b/src/packages/fff/fff-hoods/Makefile
>> new file mode 100644
>> index 0000000..f85178d
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/Makefile
>> @@ -0,0 +1,39 @@
>> +include $(TOPDIR)/rules.mk
>> +
>> +PKG_NAME:=fff-hoods
>> +PKG_VERSION:=0.0.1
>> +PKG_RELEASE:=1
>> +
>> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
>> +
>> +include $(INCLUDE_DIR)/package.mk
>> +
>> +define Package/fff-hoods
>> +    SECTION:=base
>> +    CATEGORY:=Freifunk
>> +    TITLE:= Freifunk-Franken hoods
>> +    URL:=http://www.freifunk-franken.de
>> +    DEPENDS:=+fff-network
>> +endef
>> +
>> +define Package/fff-hoods/description
>> +    This package load and configures the current hood
>> +endef
>> +
>> +define Build/Prepare
>> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile
>> +endef
>> +
>> +define Build/Configure
>> +	# nothing
>> +endef
>> +
>> +define Build/Compile
>> +	# nothing
>> +endef
>> +
>> +define Package/fff-hoods/install
>> +	$(CP) ./files/* $(1)/
>> +endef
>> +
>> +$(eval $(call BuildPackage,fff-hoods))
>> diff --git a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>> new file mode 100644
>> index 0000000..49f53e3
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>> @@ -0,0 +1,5 @@
>> +#!/bin/sh 
>> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
>> +       sleep 3
>> +       /usr/sbin/configurehood
>> +}
>> diff --git a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>> new file mode 100644
>> index 0000000..ca8d798
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>> @@ -0,0 +1 @@
>> +*/5 * * * * /usr/sbin/configurehood
>> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>> new file mode 100755
>> index 0000000..bfec822
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>> @@ -0,0 +1,205 @@
>> +#!/bin/sh
>> +
>> +. /usr/share/libubox/jshn.sh
>> +. /lib/functions/fff/wireless
>> +
>> +rm /tmp/keyxchangev2data
>> +
>> +#Gatewaycheck function
>> +isGatewayAvailable() {
>> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
>> +		return true;
>> +	else
>> +		return false;
>> +	fi
>> +}
>> +
>> +
>> +# hidden AP check
>> +
>> +if [ -f /tmp/hiddenapflag ]; then
>> +	if [ isGatewayAvailable ]; then
>> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net" "configap" "configap" "1"; then
>> +			echo "Can't add AP interface on $radio."
>> +			exit 1
>> +		else
>> +			#we must set here a fix ip adress
>> +			uci set network.configap=interface
>> +			uci set network.configap.proto='static'
>> +			uci set network.configap.ip6addr='fe80::1/64'
>> +			uci commit network
>> +		fi
>> +	else
>> +		rm /tmp/hiddenapflag
>> +	fi
>> +fi
>> +
>> +
>> +lat=$(uci get system.@system[0].latitude)
>> +long=$(uci get system.@system[0].longitude)
>> +hostname=$(cat /proc/sys/kernel/hostname)
>> +[ "$hostname" = "OpenWrt" ] && hostname=""
>> +[ "$hostname" = "" ] &&  hostname="$mac"
>> +
>> +test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken keyserver
>> +test_ipv4_host2="8.8.8.8"        # Google DNS
>> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
>> +
>> +# if we have Internet, we download the Hoodfile from the keyxchangev2
>> +if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
>> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
>> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
>> +	wget -T15 -t5 "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
>> +	#if no Internet, we connect to the hidden AP and download the file from another Node in range 
>> +else
>> +	# connect to wireless hidden ap here and download from the next router the json File -O /tmp/keyxchangev2data
>> +	# only to that, when we have no gateway in range. If the Uplinkrouter change the hood, we lost the GW and to this automatically again i think! Nice idea?
>> +	if [ ! isGatewayAvailable ]; then
>> +		#now we haven't a gateway in Range, we search for a hidden AP to get a keyxchangev2data file!
>> +		#first we delete all wifi settings
>> +		if ! wifiDelAll; 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
>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>> +				echo "$phy is 2.4 GHz"
>> +				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>> +				echo "$phy is 5 GHz"
>> +				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +			#and here we add the station
>> +			if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta"; then
>> +				echo "Can't add Sta interface on $radio."
>> +				exit 1
>> +			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]/keyxchangev2data" -O /tmp/keyxchangev2data   
>> +	else
>> +		echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
>> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data" -O /tmp/keyxchangev2data 
>> +	fi
>> +
>> +
>> +fi
>> +
>> +if [ -s /tmp/keyxchangev2data ]; then
>> +
>> +	# we get a json file in this format: 
>> +	# https://pw.freifunk-franken.de/patch/205/
>> +	# but without signature, every hood file we get is valid!
>> +
>> +	json_load "$(cat /tmp/keyxchangev2data)"
>> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
>> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d " ")
>> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then

möp wichtiges Leerzeichen vor ]

>> +		echo "New file detect, we reconfigure the Node";
>> +
>> +		# copy the file to webroot that other Meshrouter can download them
>> +		cp /tmp/keyxchangev2data /www/public/
>> +
>> +		json_select hood
>> +
>> +		json_get_var hood name
>> +		json_get_var mesh_bssid mesh_bssid
>> +		json_get_var mesh_essid mesh_essid
>> +		json_get_var essid essid
>> +		# i think the next things we don't active this in the first version! we can do it later
>> +		#json_get_var channel2 channel2
>> +		#json_get_var mode2 mode2
>> +		#json_get_var type2 type2
>> +		#json_get_var channel5 channel5
>> +		#json_get_var mode5 mode5
>> +		#json_get_var type5 type5
>> +		#json_get_var protocol protocol
>> +
>> +		echo "Setting hood name: $hood"
>> +		uci set system.@system[0].hood=$hood
>> +
>> +		if ! wifiDelAll; then
>> +			echo "Can't delete current wifi setup"
>> +			exit 1
>> +		fi
>> +
>> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>> +				echo "$phy is 2.4 GHz"
>> +				radio=$(wifiAddPhy "$phy" "1")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>> +				echo "$phy is 5 GHz"
>> +				radio=$(wifiAddPhy "$phy" "13")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +
>> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0"; then
>> +				echo "Can't add AP interface on $radio."
>> +				exit 1
>> +			fi
>> +
>> +			# here we set a bit for add hidden AP
>> +			touch /tmp/hiddenapflag
>> +
>> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid" "$mesh_bssid"; then
>> +				echo "Can't add AP interface on $radio."
>> +				exit 1
>> +			fi
>> +		done
>> +
>> +		echo "Loading wifi"
>> +		wifi
>> +
>> +
>> +	else
>> +		echo "we have no new file or we have no file get. We do nothing. We try it again in 5 minutes...";
>> +	fi
>> +
>> +	# and now we read the VPN Data and give this data to fff-vpn

hier ist (warum auch immer) ein:

json_load "$(cat /tmp/keyxchangev2data)"

nötig obwohl es oben schon gemacht wurde, warum? Weiß ich gerade nicht
genau aber ohne geht es nicht.

>> +
>> +	json_select vpn
>> +	Index="1"
>> +	rm /tmp/fastd_fff_output
>> +	touch /tmp/fastd_fff_output
>> +	while json_select $Index > /dev/null
>> +	do                                                                                                                                                                                            
>> +		json_get_var protocol protocol                                                                                                                                                            
>> +		if [ "$protocol" == "fastd"]; then

möp, wichtiges Leerzeichen vor ]

mfg

Christian

>> +			json_get_var servername name
>> +			echo "####$servername.conf" >> /tmp/fastd_fff_output
>> +			echo "#name \"$servername\";" >> /tmp/fastd_fff_output
>> +			json_get_var key key
>> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
>> +			json_get_var address address
>> +			json_get_var port port
>> +			echo "remote ipv4 \"$address\" port $port float;" >> /tmp/fastd_fff_output
>> +		fi
>> +		echo "" >> /tmp/fastd_fff_output
>> +		echo "###" >> /tmp/fastd_fff_output
>> +	done
>> +	#this we do every 5 minutes, because it can change the VPN Protocol
>> +	#and now we get to vpn-select Script and load VPNs
>> +	sh /usr/sbin/vpn-select
>> +fi
> 
> 
> 
>
Adrian Schmutzler Sept. 27, 2017, 9:25 a.m.
Hallo,

ist das so jetzt schon benutzbar?

Würde bei mir ein paar Router testweise flashen ...

Durch das neue Batman dürften die ja dann keine Loops mit meiner bestehenden
Installation bauen, oder?

Grüße

Adrian

> -----Original Message-----
> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
> Of Christian Dresel
> Sent: Mittwoch, 27. September 2017 10:53
> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken-
> dev@freifunk.net
> Cc: Jan Kraus <mayosemmel@gmail.com>
> Subject: Re: [v9,4/4] Add fff-hoods
> 
> Falls jemand damit arbeiten will, einige Syntaxfehler:
> 
> On 27.09.2017 09:54, Christian Dresel wrote:
> > hi
> >
> > Das ganze Paket muss noch in der fff-base aktiviert werden, das hab
> > aber wohl schon ich vermasselt da es wohl auch schon in den früheren
> > Patchversionen von mir fehlt. Sollte bei der nächsten Version mit
> > nachgetragen werden.
> >
> > mfg
> >
> > Christian
> >
> > (sry wegen der doppelten Mail, ich hab die Absenderadresse mal wieder
> > vermurkst...)
> >
> > On 21.09.2017 16:02, Adrian Schmutzler wrote:
> >> From: Christian Dresel <fff@chrisi01.de>
> >>
> >> this packages connect to keyxchangev2 after review we must change the
> >> serveradress! This is only a example
> >>
> >> Signed-off-by: Christian Dresel <fff@chrisi01.de>
> >> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
> >>
> >> Update in v2:
> >>  - clean tabstops
> >>  - move the json vpn out of the if because we need this after reboot
> >>
> >> Update in v5:
> >> 	!!UNTESTED!!
> >>  - change hidden AP ip to locallink
> >>  - Open hidden AP after more checks
> >>  - Load json File from Gateway if Gateway in Batman in Range
> >>
> >> Update in v6:
> >> 	!!UNTESTED!!
> >>  - fix hidden station v6
> >>  - fix -n to -f if
> >>  - Add function to check for a gateway and use this
> >>  - remove /etc/community.cfg and variables
> >>  - send fewer infos to keyxchangev2
> >>  - add a check if /tmp/keyxchangev2 not downloadable and edit a bit
> >> on the wgets
> >>  - change the position from json_load and do this only 1 times
> >>
> >> Update in v7:
> >> 	!!UNTESTED!!
> >>  - delete keyxchangev2data at start of the script
> >>  - do only things with keyxchangev2data if available
> >>  - change keyxchangev2 url
> >>
> >> Update in v8/v9:
> >>  - rebase onto 20170918-beta
> >> ---
> >>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
> >>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
> >>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
> >>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205
> +++++++++++++++++++++
> >>  4 files changed, 250 insertions(+)
> >>  create mode 100644 src/packages/fff/fff-hoods/Makefile
> >>  create mode 100644
> >> src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
> >>  create mode 100644
> >> src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
> >>  create mode 100755
> >> src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >>
> >> diff --git a/src/packages/fff/fff-hoods/Makefile
> >> b/src/packages/fff/fff-hoods/Makefile
> >> new file mode 100644
> >> index 0000000..f85178d
> >> --- /dev/null
> >> +++ b/src/packages/fff/fff-hoods/Makefile
> >> @@ -0,0 +1,39 @@
> >> +include $(TOPDIR)/rules.mk
> >> +
> >> +PKG_NAME:=fff-hoods
> >> +PKG_VERSION:=0.0.1
> >> +PKG_RELEASE:=1
> >> +
> >> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
> >> +
> >> +include $(INCLUDE_DIR)/package.mk
> >> +
> >> +define Package/fff-hoods
> >> +    SECTION:=base
> >> +    CATEGORY:=Freifunk
> >> +    TITLE:= Freifunk-Franken hoods
> >> +    URL:=http://www.freifunk-franken.de
> >> +    DEPENDS:=+fff-network
> >> +endef
> >> +
> >> +define Package/fff-hoods/description
> >> +    This package load and configures the current hood endef
> >> +
> >> +define Build/Prepare
> >> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile endef
> >> +
> >> +define Build/Configure
> >> +	# nothing
> >> +endef
> >> +
> >> +define Build/Compile
> >> +	# nothing
> >> +endef
> >> +
> >> +define Package/fff-hoods/install
> >> +	$(CP) ./files/* $(1)/
> >> +endef
> >> +
> >> +$(eval $(call BuildPackage,fff-hoods))
> >> diff --git
> >> a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
> >> b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
> >> new file mode 100644
> >> index 0000000..49f53e3
> >> --- /dev/null
> >> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoo
> >> +++ ds
> >> @@ -0,0 +1,5 @@
> >> +#!/bin/sh
> >> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
> >> +       sleep 3
> >> +       /usr/sbin/configurehood
> >> +}
> >> diff --git
> >> a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
> >> b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
> >> new file mode 100644
> >> index 0000000..ca8d798
> >> --- /dev/null
> >> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
> >> @@ -0,0 +1 @@
> >> +*/5 * * * * /usr/sbin/configurehood
> >> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >> new file mode 100755
> >> index 0000000..bfec822
> >> --- /dev/null
> >> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >> @@ -0,0 +1,205 @@
> >> +#!/bin/sh
> >> +
> >> +. /usr/share/libubox/jshn.sh
> >> +. /lib/functions/fff/wireless
> >> +
> >> +rm /tmp/keyxchangev2data
> >> +
> >> +#Gatewaycheck function
> >> +isGatewayAvailable() {
> >> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
> >> +		return true;
> >> +	else
> >> +		return false;
> >> +	fi
> >> +}
> >> +
> >> +
> >> +# hidden AP check
> >> +
> >> +if [ -f /tmp/hiddenapflag ]; then
> >> +	if [ isGatewayAvailable ]; then
> >> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net"
> "configap" "configap" "1"; then
> >> +			echo "Can't add AP interface on $radio."
> >> +			exit 1
> >> +		else
> >> +			#we must set here a fix ip adress
> >> +			uci set network.configap=interface
> >> +			uci set network.configap.proto='static'
> >> +			uci set network.configap.ip6addr='fe80::1/64'
> >> +			uci commit network
> >> +		fi
> >> +	else
> >> +		rm /tmp/hiddenapflag
> >> +	fi
> >> +fi
> >> +
> >> +
> >> +lat=$(uci get system.@system[0].latitude) long=$(uci get
> >> +system.@system[0].longitude) hostname=$(cat
> >> +/proc/sys/kernel/hostname) [ "$hostname" = "OpenWrt" ] &&
> >> +hostname=""
> >> +[ "$hostname" = "" ] &&  hostname="$mac"
> >> +
> >> +test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken
> keyserver
> >> +test_ipv4_host2="8.8.8.8"        # Google DNS
> >> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
> >> +
> >> +# if we have Internet, we download the Hoodfile from the
> >> +keyxchangev2 if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
> >> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
> >> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
> >> +	wget -T15 -t5 "http://keyserver.freifunk-
> franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
> >> +	#if no Internet, we connect to the hidden AP and download the file
> >> +from another Node in range else
> >> +	# connect to wireless hidden ap here and download from the next
> router the json File -O /tmp/keyxchangev2data
> >> +	# only to that, when we have no gateway in range. If the
> Uplinkrouter change the hood, we lost the GW and to this automatically
> again i think! Nice idea?
> >> +	if [ ! isGatewayAvailable ]; then
> >> +		#now we haven't a gateway in Range, we search for a hidden
> AP to get a keyxchangev2data file!
> >> +		#first we delete all wifi settings
> >> +		if ! wifiDelAll; 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
> >> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
> >> +				echo "$phy is 2.4 GHz"
> >> +				radio=$(wifiAddPhy "$phy"
> "$BATMAN_CHANNEL")
> >> +				if [ -z "$radio" ]; then
> >> +					echo "Can't create radio for $phy"
> >> +					exit 1
> >> +				fi
> >> +			fi
> >> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
> >> +				echo "$phy is 5 GHz"
> >> +				radio=$(wifiAddPhy "$phy"
> "$BATMAN_CHANNEL_5GHZ")
> >> +				if [ -z "$radio" ]; then
> >> +					echo "Can't create radio for $phy"
> >> +					exit 1
> >> +				fi
> >> +			fi
> >> +			#and here we add the station
> >> +			if ! wifiAddSta "$radio"
"config.franken.freifunk.net"
> "configSta"; then
> >> +				echo "Can't add Sta interface on $radio."
> >> +				exit 1
> >> +			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]/keyxchangev2data" -O
> /tmp/keyxchangev2data
> >> +	else
> >> +		echo "We have a Gateway in Range, we load the
> keyxchangev2data from fe80::1"
> >> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data"
> -O /tmp/keyxchangev2data
> >> +	fi
> >> +
> >> +
> >> +fi
> >> +
> >> +if [ -s /tmp/keyxchangev2data ]; then
> >> +
> >> +	# we get a json file in this format:
> >> +	# https://pw.freifunk-franken.de/patch/205/
> >> +	# but without signature, every hood file we get is valid!
> >> +
> >> +	json_load "$(cat /tmp/keyxchangev2data)"
> >> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
> >> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d "
> ")
> >> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then
> 
> möp wichtiges Leerzeichen vor ]
> 
> >> +		echo "New file detect, we reconfigure the Node";
> >> +
> >> +		# copy the file to webroot that other Meshrouter can
> download them
> >> +		cp /tmp/keyxchangev2data /www/public/
> >> +
> >> +		json_select hood
> >> +
> >> +		json_get_var hood name
> >> +		json_get_var mesh_bssid mesh_bssid
> >> +		json_get_var mesh_essid mesh_essid
> >> +		json_get_var essid essid
> >> +		# i think the next things we don't active this in the first
> version! we can do it later
> >> +		#json_get_var channel2 channel2
> >> +		#json_get_var mode2 mode2
> >> +		#json_get_var type2 type2
> >> +		#json_get_var channel5 channel5
> >> +		#json_get_var mode5 mode5
> >> +		#json_get_var type5 type5
> >> +		#json_get_var protocol protocol
> >> +
> >> +		echo "Setting hood name: $hood"
> >> +		uci set system.@system[0].hood=$hood
> >> +
> >> +		if ! wifiDelAll; then
> >> +			echo "Can't delete current wifi setup"
> >> +			exit 1
> >> +		fi
> >> +
> >> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
> >> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
> >> +				echo "$phy is 2.4 GHz"
> >> +				radio=$(wifiAddPhy "$phy" "1")
> >> +				if [ -z "$radio" ]; then
> >> +					echo "Can't create radio for $phy"
> >> +					exit 1
> >> +				fi
> >> +			fi
> >> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
> >> +				echo "$phy is 5 GHz"
> >> +				radio=$(wifiAddPhy "$phy" "13")
> >> +				if [ -z "$radio" ]; then
> >> +					echo "Can't create radio for $phy"
> >> +					exit 1
> >> +				fi
> >> +			fi
> >> +
> >> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0";
then
> >> +				echo "Can't add AP interface on $radio."
> >> +				exit 1
> >> +			fi
> >> +
> >> +			# here we set a bit for add hidden AP
> >> +			touch /tmp/hiddenapflag
> >> +
> >> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid"
> "$mesh_bssid"; then
> >> +				echo "Can't add AP interface on $radio."
> >> +				exit 1
> >> +			fi
> >> +		done
> >> +
> >> +		echo "Loading wifi"
> >> +		wifi
> >> +
> >> +
> >> +	else
> >> +		echo "we have no new file or we have no file get. We do
> nothing. We try it again in 5 minutes...";
> >> +	fi
> >> +
> >> +	# and now we read the VPN Data and give this data to fff-vpn
> 
> hier ist (warum auch immer) ein:
> 
> json_load "$(cat /tmp/keyxchangev2data)"
> 
> nötig obwohl es oben schon gemacht wurde, warum? Weiß ich gerade nicht
> genau aber ohne geht es nicht.
> 
> >> +
> >> +	json_select vpn
> >> +	Index="1"
> >> +	rm /tmp/fastd_fff_output
> >> +	touch /tmp/fastd_fff_output
> >> +	while json_select $Index > /dev/null
> >> +	do
> >> +		json_get_var protocol protocol
> >> +		if [ "$protocol" == "fastd"]; then
> 
> möp, wichtiges Leerzeichen vor ]
> 
> mfg
> 
> Christian
> 
> >> +			json_get_var servername name
> >> +			echo "####$servername.conf" >>
> /tmp/fastd_fff_output
> >> +			echo "#name \"$servername\";" >>
> /tmp/fastd_fff_output
> >> +			json_get_var key key
> >> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
> >> +			json_get_var address address
> >> +			json_get_var port port
> >> +			echo "remote ipv4 \"$address\" port $port float;" >>
> /tmp/fastd_fff_output
> >> +		fi
> >> +		echo "" >> /tmp/fastd_fff_output
> >> +		echo "###" >> /tmp/fastd_fff_output
> >> +	done
> >> +	#this we do every 5 minutes, because it can change the VPN Protocol
> >> +	#and now we get to vpn-select Script and load VPNs
> >> +	sh /usr/sbin/vpn-select
> >> +fi
> >
> >
> >
> >
Christian Dresel Sept. 27, 2017, 10:15 a.m.
hi

On 27.09.2017 11:25, mail@adrianschmutzler.de wrote:
> Hallo,
> 
> ist das so jetzt schon benutzbar?

es fehlen noch Gateways, wenn du die Router Koordinatentechnisch nach
Fürth setzt (in der Nähe von
http://keyserver.freifunk-franken.de/v2/?lat=49.48&long=10.9 damit du
nicht in Nürnberg landest was noch kein GW hat:
http://keyserver.freifunk-franken.de/v2/?lat=47.48&long=9.9 ) könnte es
schon halbwegs klappen (Internetrouting ist noch ungetestet, das mach
ich jetzt gleich aber per Batman sollte er sich schon verbinden), ich
bin grad dabei einiges zu fixen und das GW zum laufen zu bringen, ist
aber noch SEHR testphasig und kann jederzeit noch viel kaputt gehen,
also bitte nur Router flashen die bei dir daheim zum testen rumstehen.

Auch das ganze Patchset ist noch experiementell wie man an meinen Mails
und div. Fehlern die noch auftauchen sieht ;)

> 
> Würde bei mir ein paar Router testweise flashen ...
> 
> Durch das neue Batman dürften die ja dann keine Loops mit meiner bestehenden
> Installation bauen, oder?

da sich die BSSID ändert sowieso nicht, das Problem wird sich mit dem
keyxchangev2 komplett lösen da jede Hood ne eigene BSSID hat damit kann
es gar keine Loops mehr geben (JUCHU keine Arbeit mehr ;))

Kleine Anmerkung noch Inline im Code, bin auf einen weiteren Fehler
gestolpert:

> 
> Grüße
> 
> Adrian
> 
>> -----Original Message-----
>> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
>> Of Christian Dresel
>> Sent: Mittwoch, 27. September 2017 10:53
>> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken-
>> dev@freifunk.net
>> Cc: Jan Kraus <mayosemmel@gmail.com>
>> Subject: Re: [v9,4/4] Add fff-hoods
>>
>> Falls jemand damit arbeiten will, einige Syntaxfehler:
>>
>> On 27.09.2017 09:54, Christian Dresel wrote:
>>> hi
>>>
>>> Das ganze Paket muss noch in der fff-base aktiviert werden, das hab
>>> aber wohl schon ich vermasselt da es wohl auch schon in den früheren
>>> Patchversionen von mir fehlt. Sollte bei der nächsten Version mit
>>> nachgetragen werden.
>>>
>>> mfg
>>>
>>> Christian
>>>
>>> (sry wegen der doppelten Mail, ich hab die Absenderadresse mal wieder
>>> vermurkst...)
>>>
>>> On 21.09.2017 16:02, Adrian Schmutzler wrote:
>>>> From: Christian Dresel <fff@chrisi01.de>
>>>>
>>>> this packages connect to keyxchangev2 after review we must change the
>>>> serveradress! This is only a example
>>>>
>>>> Signed-off-by: Christian Dresel <fff@chrisi01.de>
>>>> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
>>>>
>>>> Update in v2:
>>>>  - clean tabstops
>>>>  - move the json vpn out of the if because we need this after reboot
>>>>
>>>> Update in v5:
>>>> 	!!UNTESTED!!
>>>>  - change hidden AP ip to locallink
>>>>  - Open hidden AP after more checks
>>>>  - Load json File from Gateway if Gateway in Batman in Range
>>>>
>>>> Update in v6:
>>>> 	!!UNTESTED!!
>>>>  - fix hidden station v6
>>>>  - fix -n to -f if
>>>>  - Add function to check for a gateway and use this
>>>>  - remove /etc/community.cfg and variables
>>>>  - send fewer infos to keyxchangev2
>>>>  - add a check if /tmp/keyxchangev2 not downloadable and edit a bit
>>>> on the wgets
>>>>  - change the position from json_load and do this only 1 times
>>>>
>>>> Update in v7:
>>>> 	!!UNTESTED!!
>>>>  - delete keyxchangev2data at start of the script
>>>>  - do only things with keyxchangev2data if available
>>>>  - change keyxchangev2 url
>>>>
>>>> Update in v8/v9:
>>>>  - rebase onto 20170918-beta
>>>> ---
>>>>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
>>>>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
>>>>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
>>>>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205
>> +++++++++++++++++++++
>>>>  4 files changed, 250 insertions(+)
>>>>  create mode 100644 src/packages/fff/fff-hoods/Makefile
>>>>  create mode 100644
>>>> src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>  create mode 100644
>>>> src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>  create mode 100755
>>>> src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>
>>>> diff --git a/src/packages/fff/fff-hoods/Makefile
>>>> b/src/packages/fff/fff-hoods/Makefile
>>>> new file mode 100644
>>>> index 0000000..f85178d
>>>> --- /dev/null
>>>> +++ b/src/packages/fff/fff-hoods/Makefile
>>>> @@ -0,0 +1,39 @@
>>>> +include $(TOPDIR)/rules.mk
>>>> +
>>>> +PKG_NAME:=fff-hoods
>>>> +PKG_VERSION:=0.0.1
>>>> +PKG_RELEASE:=1
>>>> +
>>>> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
>>>> +
>>>> +include $(INCLUDE_DIR)/package.mk
>>>> +
>>>> +define Package/fff-hoods
>>>> +    SECTION:=base
>>>> +    CATEGORY:=Freifunk
>>>> +    TITLE:= Freifunk-Franken hoods
>>>> +    URL:=http://www.freifunk-franken.de
>>>> +    DEPENDS:=+fff-network
>>>> +endef
>>>> +
>>>> +define Package/fff-hoods/description
>>>> +    This package load and configures the current hood endef
>>>> +
>>>> +define Build/Prepare
>>>> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile endef
>>>> +
>>>> +define Build/Configure
>>>> +	# nothing
>>>> +endef
>>>> +
>>>> +define Build/Compile
>>>> +	# nothing
>>>> +endef
>>>> +
>>>> +define Package/fff-hoods/install
>>>> +	$(CP) ./files/* $(1)/
>>>> +endef
>>>> +
>>>> +$(eval $(call BuildPackage,fff-hoods))
>>>> diff --git
>>>> a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>> b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>> new file mode 100644
>>>> index 0000000..49f53e3
>>>> --- /dev/null
>>>> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoo
>>>> +++ ds
>>>> @@ -0,0 +1,5 @@
>>>> +#!/bin/sh
>>>> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
>>>> +       sleep 3
>>>> +       /usr/sbin/configurehood
>>>> +}
>>>> diff --git
>>>> a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>> b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>> new file mode 100644
>>>> index 0000000..ca8d798
>>>> --- /dev/null
>>>> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>> @@ -0,0 +1 @@
>>>> +*/5 * * * * /usr/sbin/configurehood
>>>> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>> new file mode 100755
>>>> index 0000000..bfec822
>>>> --- /dev/null
>>>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>> @@ -0,0 +1,205 @@
>>>> +#!/bin/sh
>>>> +
>>>> +. /usr/share/libubox/jshn.sh
>>>> +. /lib/functions/fff/wireless
>>>> +
>>>> +rm /tmp/keyxchangev2data
>>>> +
>>>> +#Gatewaycheck function
>>>> +isGatewayAvailable() {
>>>> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
>>>> +		return true;
>>>> +	else
>>>> +		return false;
>>>> +	fi
>>>> +}
>>>> +
>>>> +
>>>> +# hidden AP check
>>>> +
>>>> +if [ -f /tmp/hiddenapflag ]; then
>>>> +	if [ isGatewayAvailable ]; then
>>>> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net"
>> "configap" "configap" "1"; then
>>>> +			echo "Can't add AP interface on $radio."
>>>> +			exit 1
>>>> +		else
>>>> +			#we must set here a fix ip adress
>>>> +			uci set network.configap=interface
>>>> +			uci set network.configap.proto='static'
>>>> +			uci set network.configap.ip6addr='fe80::1/64'
>>>> +			uci commit network
>>>> +		fi
>>>> +	else
>>>> +		rm /tmp/hiddenapflag
>>>> +	fi
>>>> +fi
>>>> +
>>>> +
>>>> +lat=$(uci get system.@system[0].latitude) long=$(uci get
>>>> +system.@system[0].longitude) hostname=$(cat
>>>> +/proc/sys/kernel/hostname) [ "$hostname" = "OpenWrt" ] &&
>>>> +hostname=""
>>>> +[ "$hostname" = "" ] &&  hostname="$mac"
>>>> +
>>>> +test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken
>> keyserver
>>>> +test_ipv4_host2="8.8.8.8"        # Google DNS
>>>> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
>>>> +
>>>> +# if we have Internet, we download the Hoodfile from the
>>>> +keyxchangev2 if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
>>>> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
>>>> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
>>>> +	wget -T15 -t5 "http://keyserver.freifunk-
>> franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
>>>> +	#if no Internet, we connect to the hidden AP and download the file
>>>> +from another Node in range else
>>>> +	# connect to wireless hidden ap here and download from the next
>> router the json File -O /tmp/keyxchangev2data
>>>> +	# only to that, when we have no gateway in range. If the
>> Uplinkrouter change the hood, we lost the GW and to this automatically
>> again i think! Nice idea?
>>>> +	if [ ! isGatewayAvailable ]; then
>>>> +		#now we haven't a gateway in Range, we search for a hidden
>> AP to get a keyxchangev2data file!
>>>> +		#first we delete all wifi settings
>>>> +		if ! wifiDelAll; 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
>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>> +				echo "$phy is 2.4 GHz"
>>>> +				radio=$(wifiAddPhy "$phy"
>> "$BATMAN_CHANNEL")
>>>> +				if [ -z "$radio" ]; then
>>>> +					echo "Can't create radio for $phy"
>>>> +					exit 1
>>>> +				fi
>>>> +			fi
>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>> +				echo "$phy is 5 GHz"
>>>> +				radio=$(wifiAddPhy "$phy"
>> "$BATMAN_CHANNEL_5GHZ")
>>>> +				if [ -z "$radio" ]; then
>>>> +					echo "Can't create radio for $phy"
>>>> +					exit 1
>>>> +				fi
>>>> +			fi
>>>> +			#and here we add the station
>>>> +			if ! wifiAddSta "$radio"
> "config.franken.freifunk.net"
>> "configSta"; then
>>>> +				echo "Can't add Sta interface on $radio."
>>>> +				exit 1
>>>> +			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]/keyxchangev2data" -O
>> /tmp/keyxchangev2data
>>>> +	else
>>>> +		echo "We have a Gateway in Range, we load the
>> keyxchangev2data from fe80::1"
>>>> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data"
>> -O /tmp/keyxchangev2data
>>>> +	fi
>>>> +
>>>> +
>>>> +fi
>>>> +
>>>> +if [ -s /tmp/keyxchangev2data ]; then
>>>> +
>>>> +	# we get a json file in this format:
>>>> +	# https://pw.freifunk-franken.de/patch/205/
>>>> +	# but without signature, every hood file we get is valid!
>>>> +
>>>> +	json_load "$(cat /tmp/keyxchangev2data)"
>>>> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
>>>> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d "
>> ")
>>>> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then

[ ! -f /tmp/keyxchangev2data]
wäre richtig, da wir da ja rein wollen wenn die File NICHT existiert.

mfg

Christian

>>
>> möp wichtiges Leerzeichen vor ]
>>
>>>> +		echo "New file detect, we reconfigure the Node";
>>>> +
>>>> +		# copy the file to webroot that other Meshrouter can
>> download them
>>>> +		cp /tmp/keyxchangev2data /www/public/
>>>> +
>>>> +		json_select hood
>>>> +
>>>> +		json_get_var hood name
>>>> +		json_get_var mesh_bssid mesh_bssid
>>>> +		json_get_var mesh_essid mesh_essid
>>>> +		json_get_var essid essid
>>>> +		# i think the next things we don't active this in the first
>> version! we can do it later
>>>> +		#json_get_var channel2 channel2
>>>> +		#json_get_var mode2 mode2
>>>> +		#json_get_var type2 type2
>>>> +		#json_get_var channel5 channel5
>>>> +		#json_get_var mode5 mode5
>>>> +		#json_get_var type5 type5
>>>> +		#json_get_var protocol protocol
>>>> +
>>>> +		echo "Setting hood name: $hood"
>>>> +		uci set system.@system[0].hood=$hood
>>>> +
>>>> +		if ! wifiDelAll; then
>>>> +			echo "Can't delete current wifi setup"
>>>> +			exit 1
>>>> +		fi
>>>> +
>>>> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>> +				echo "$phy is 2.4 GHz"
>>>> +				radio=$(wifiAddPhy "$phy" "1")
>>>> +				if [ -z "$radio" ]; then
>>>> +					echo "Can't create radio for $phy"
>>>> +					exit 1
>>>> +				fi
>>>> +			fi
>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>> +				echo "$phy is 5 GHz"
>>>> +				radio=$(wifiAddPhy "$phy" "13")
>>>> +				if [ -z "$radio" ]; then
>>>> +					echo "Can't create radio for $phy"
>>>> +					exit 1
>>>> +				fi
>>>> +			fi
>>>> +
>>>> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0";
> then
>>>> +				echo "Can't add AP interface on $radio."
>>>> +				exit 1
>>>> +			fi
>>>> +
>>>> +			# here we set a bit for add hidden AP
>>>> +			touch /tmp/hiddenapflag
>>>> +
>>>> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid"
>> "$mesh_bssid"; then
>>>> +				echo "Can't add AP interface on $radio."
>>>> +				exit 1
>>>> +			fi
>>>> +		done
>>>> +
>>>> +		echo "Loading wifi"
>>>> +		wifi
>>>> +
>>>> +
>>>> +	else
>>>> +		echo "we have no new file or we have no file get. We do
>> nothing. We try it again in 5 minutes...";
>>>> +	fi
>>>> +
>>>> +	# and now we read the VPN Data and give this data to fff-vpn
>>
>> hier ist (warum auch immer) ein:
>>
>> json_load "$(cat /tmp/keyxchangev2data)"
>>
>> nötig obwohl es oben schon gemacht wurde, warum? Weiß ich gerade nicht
>> genau aber ohne geht es nicht.
>>
>>>> +
>>>> +	json_select vpn
>>>> +	Index="1"
>>>> +	rm /tmp/fastd_fff_output
>>>> +	touch /tmp/fastd_fff_output
>>>> +	while json_select $Index > /dev/null
>>>> +	do
>>>> +		json_get_var protocol protocol
>>>> +		if [ "$protocol" == "fastd"]; then
>>
>> möp, wichtiges Leerzeichen vor ]
>>
>> mfg
>>
>> Christian
>>
>>>> +			json_get_var servername name
>>>> +			echo "####$servername.conf" >>
>> /tmp/fastd_fff_output
>>>> +			echo "#name \"$servername\";" >>
>> /tmp/fastd_fff_output
>>>> +			json_get_var key key
>>>> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
>>>> +			json_get_var address address
>>>> +			json_get_var port port
>>>> +			echo "remote ipv4 \"$address\" port $port float;" >>
>> /tmp/fastd_fff_output
>>>> +		fi
>>>> +		echo "" >> /tmp/fastd_fff_output
>>>> +		echo "###" >> /tmp/fastd_fff_output
>>>> +	done
>>>> +	#this we do every 5 minutes, because it can change the VPN Protocol
>>>> +	#and now we get to vpn-select Script and load VPNs
>>>> +	sh /usr/sbin/vpn-select
>>>> +fi
>>>
>>>
>>>
>>>
> 
>
Christian Dresel Sept. 27, 2017, 10:30 a.m.
hi

so bevor ich auf Spätschicht gehe und vllt. auch diese Woche und übers
Wochenende zu nix mehr kommen werde, der aktuelle Stand was geht was
nicht und was ungetestet ist.

Mit den gefixten Fehlern aus den letzten Mails und Koordinaten in Fürth
sollte folgendes gehen:

- Uplinkrouter (mit VPN) flashen
- Koordinaten im WebUI nach Fürth setzen (Achtung in der Trainstation
ist aktuell kein Internet, d.h. die Karte läd nicht, da ist noch Kram
Gatewayseitig nötig, Koordinaten per Hand eingeben)
- Internet per IPv4
- weitere ipv6 ULA Adresse beziehen die später geroutet wird, wird
bereits verteilt

ungetestet:
- Meshrouter in Betrieb nehmen (flashen und warten... sollte eigentlich
gehen)

noch sicher kaputt:
- ipv6 ULA Routing (Gateway in Fürth will das nicht routen muss ich noch
gucken woran das liegt)
- Router bekommt noch keine ipv6 ULA IP Adresse auf br-mesh und ist
daher auch nur weiterhin per fdff:: erreichbar
- Im WebUI kann man aktuell weder die Hood manuell setzen noch
festnageln (siehe mantis)

das mal so grob der Zwischenstand, würde mich freuen wenn weitere Leute
das ganze testen aber bitte bedenkt, das ist wirklich alles noch sehr
gefrickelt, mehr als nen Router im Wohnzimmer zum testen würde ich noch
nicht flashen ;)

mfg

Christian

On 27.09.2017 12:15, Christian Dresel wrote:
> hi
> 
> On 27.09.2017 11:25, mail@adrianschmutzler.de wrote:
>> Hallo,
>>
>> ist das so jetzt schon benutzbar?
> 
> es fehlen noch Gateways, wenn du die Router Koordinatentechnisch nach
> Fürth setzt (in der Nähe von
> http://keyserver.freifunk-franken.de/v2/?lat=49.48&long=10.9 damit du
> nicht in Nürnberg landest was noch kein GW hat:
> http://keyserver.freifunk-franken.de/v2/?lat=47.48&long=9.9 ) könnte es
> schon halbwegs klappen (Internetrouting ist noch ungetestet, das mach
> ich jetzt gleich aber per Batman sollte er sich schon verbinden), ich
> bin grad dabei einiges zu fixen und das GW zum laufen zu bringen, ist
> aber noch SEHR testphasig und kann jederzeit noch viel kaputt gehen,
> also bitte nur Router flashen die bei dir daheim zum testen rumstehen.
> 
> Auch das ganze Patchset ist noch experiementell wie man an meinen Mails
> und div. Fehlern die noch auftauchen sieht ;)
> 
>>
>> Würde bei mir ein paar Router testweise flashen ...
>>
>> Durch das neue Batman dürften die ja dann keine Loops mit meiner bestehenden
>> Installation bauen, oder?
> 
> da sich die BSSID ändert sowieso nicht, das Problem wird sich mit dem
> keyxchangev2 komplett lösen da jede Hood ne eigene BSSID hat damit kann
> es gar keine Loops mehr geben (JUCHU keine Arbeit mehr ;))
> 
> Kleine Anmerkung noch Inline im Code, bin auf einen weiteren Fehler
> gestolpert:
> 
>>
>> Grüße
>>
>> Adrian
>>
>>> -----Original Message-----
>>> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
>>> Of Christian Dresel
>>> Sent: Mittwoch, 27. September 2017 10:53
>>> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken-
>>> dev@freifunk.net
>>> Cc: Jan Kraus <mayosemmel@gmail.com>
>>> Subject: Re: [v9,4/4] Add fff-hoods
>>>
>>> Falls jemand damit arbeiten will, einige Syntaxfehler:
>>>
>>> On 27.09.2017 09:54, Christian Dresel wrote:
>>>> hi
>>>>
>>>> Das ganze Paket muss noch in der fff-base aktiviert werden, das hab
>>>> aber wohl schon ich vermasselt da es wohl auch schon in den früheren
>>>> Patchversionen von mir fehlt. Sollte bei der nächsten Version mit
>>>> nachgetragen werden.
>>>>
>>>> mfg
>>>>
>>>> Christian
>>>>
>>>> (sry wegen der doppelten Mail, ich hab die Absenderadresse mal wieder
>>>> vermurkst...)
>>>>
>>>> On 21.09.2017 16:02, Adrian Schmutzler wrote:
>>>>> From: Christian Dresel <fff@chrisi01.de>
>>>>>
>>>>> this packages connect to keyxchangev2 after review we must change the
>>>>> serveradress! This is only a example
>>>>>
>>>>> Signed-off-by: Christian Dresel <fff@chrisi01.de>
>>>>> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
>>>>>
>>>>> Update in v2:
>>>>>  - clean tabstops
>>>>>  - move the json vpn out of the if because we need this after reboot
>>>>>
>>>>> Update in v5:
>>>>> 	!!UNTESTED!!
>>>>>  - change hidden AP ip to locallink
>>>>>  - Open hidden AP after more checks
>>>>>  - Load json File from Gateway if Gateway in Batman in Range
>>>>>
>>>>> Update in v6:
>>>>> 	!!UNTESTED!!
>>>>>  - fix hidden station v6
>>>>>  - fix -n to -f if
>>>>>  - Add function to check for a gateway and use this
>>>>>  - remove /etc/community.cfg and variables
>>>>>  - send fewer infos to keyxchangev2
>>>>>  - add a check if /tmp/keyxchangev2 not downloadable and edit a bit
>>>>> on the wgets
>>>>>  - change the position from json_load and do this only 1 times
>>>>>
>>>>> Update in v7:
>>>>> 	!!UNTESTED!!
>>>>>  - delete keyxchangev2data at start of the script
>>>>>  - do only things with keyxchangev2data if available
>>>>>  - change keyxchangev2 url
>>>>>
>>>>> Update in v8/v9:
>>>>>  - rebase onto 20170918-beta
>>>>> ---
>>>>>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
>>>>>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
>>>>>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
>>>>>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205
>>> +++++++++++++++++++++
>>>>>  4 files changed, 250 insertions(+)
>>>>>  create mode 100644 src/packages/fff/fff-hoods/Makefile
>>>>>  create mode 100644
>>>>> src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>>  create mode 100644
>>>>> src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>>  create mode 100755
>>>>> src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>>
>>>>> diff --git a/src/packages/fff/fff-hoods/Makefile
>>>>> b/src/packages/fff/fff-hoods/Makefile
>>>>> new file mode 100644
>>>>> index 0000000..f85178d
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/Makefile
>>>>> @@ -0,0 +1,39 @@
>>>>> +include $(TOPDIR)/rules.mk
>>>>> +
>>>>> +PKG_NAME:=fff-hoods
>>>>> +PKG_VERSION:=0.0.1
>>>>> +PKG_RELEASE:=1
>>>>> +
>>>>> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
>>>>> +
>>>>> +include $(INCLUDE_DIR)/package.mk
>>>>> +
>>>>> +define Package/fff-hoods
>>>>> +    SECTION:=base
>>>>> +    CATEGORY:=Freifunk
>>>>> +    TITLE:= Freifunk-Franken hoods
>>>>> +    URL:=http://www.freifunk-franken.de
>>>>> +    DEPENDS:=+fff-network
>>>>> +endef
>>>>> +
>>>>> +define Package/fff-hoods/description
>>>>> +    This package load and configures the current hood endef
>>>>> +
>>>>> +define Build/Prepare
>>>>> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile endef
>>>>> +
>>>>> +define Build/Configure
>>>>> +	# nothing
>>>>> +endef
>>>>> +
>>>>> +define Build/Compile
>>>>> +	# nothing
>>>>> +endef
>>>>> +
>>>>> +define Package/fff-hoods/install
>>>>> +	$(CP) ./files/* $(1)/
>>>>> +endef
>>>>> +
>>>>> +$(eval $(call BuildPackage,fff-hoods))
>>>>> diff --git
>>>>> a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>> b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>> new file mode 100644
>>>>> index 0000000..49f53e3
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoo
>>>>> +++ ds
>>>>> @@ -0,0 +1,5 @@
>>>>> +#!/bin/sh
>>>>> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
>>>>> +       sleep 3
>>>>> +       /usr/sbin/configurehood
>>>>> +}
>>>>> diff --git
>>>>> a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> new file mode 100644
>>>>> index 0000000..ca8d798
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> @@ -0,0 +1 @@
>>>>> +*/5 * * * * /usr/sbin/configurehood
>>>>> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> new file mode 100755
>>>>> index 0000000..bfec822
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> @@ -0,0 +1,205 @@
>>>>> +#!/bin/sh
>>>>> +
>>>>> +. /usr/share/libubox/jshn.sh
>>>>> +. /lib/functions/fff/wireless
>>>>> +
>>>>> +rm /tmp/keyxchangev2data
>>>>> +
>>>>> +#Gatewaycheck function
>>>>> +isGatewayAvailable() {
>>>>> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
>>>>> +		return true;
>>>>> +	else
>>>>> +		return false;
>>>>> +	fi
>>>>> +}
>>>>> +
>>>>> +
>>>>> +# hidden AP check
>>>>> +
>>>>> +if [ -f /tmp/hiddenapflag ]; then
>>>>> +	if [ isGatewayAvailable ]; then
>>>>> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net"
>>> "configap" "configap" "1"; then
>>>>> +			echo "Can't add AP interface on $radio."
>>>>> +			exit 1
>>>>> +		else
>>>>> +			#we must set here a fix ip adress
>>>>> +			uci set network.configap=interface
>>>>> +			uci set network.configap.proto='static'
>>>>> +			uci set network.configap.ip6addr='fe80::1/64'
>>>>> +			uci commit network
>>>>> +		fi
>>>>> +	else
>>>>> +		rm /tmp/hiddenapflag
>>>>> +	fi
>>>>> +fi
>>>>> +
>>>>> +
>>>>> +lat=$(uci get system.@system[0].latitude) long=$(uci get
>>>>> +system.@system[0].longitude) hostname=$(cat
>>>>> +/proc/sys/kernel/hostname) [ "$hostname" = "OpenWrt" ] &&
>>>>> +hostname=""
>>>>> +[ "$hostname" = "" ] &&  hostname="$mac"
>>>>> +
>>>>> +test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken
>>> keyserver
>>>>> +test_ipv4_host2="8.8.8.8"        # Google DNS
>>>>> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
>>>>> +
>>>>> +# if we have Internet, we download the Hoodfile from the
>>>>> +keyxchangev2 if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
>>>>> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
>>>>> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
>>>>> +	wget -T15 -t5 "http://keyserver.freifunk-
>>> franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
>>>>> +	#if no Internet, we connect to the hidden AP and download the file
>>>>> +from another Node in range else
>>>>> +	# connect to wireless hidden ap here and download from the next
>>> router the json File -O /tmp/keyxchangev2data
>>>>> +	# only to that, when we have no gateway in range. If the
>>> Uplinkrouter change the hood, we lost the GW and to this automatically
>>> again i think! Nice idea?
>>>>> +	if [ ! isGatewayAvailable ]; then
>>>>> +		#now we haven't a gateway in Range, we search for a hidden
>>> AP to get a keyxchangev2data file!
>>>>> +		#first we delete all wifi settings
>>>>> +		if ! wifiDelAll; 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
>>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>>> +				echo "$phy is 2.4 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy"
>>> "$BATMAN_CHANNEL")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>>> +				echo "$phy is 5 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy"
>>> "$BATMAN_CHANNEL_5GHZ")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			#and here we add the station
>>>>> +			if ! wifiAddSta "$radio"
>> "config.franken.freifunk.net"
>>> "configSta"; then
>>>>> +				echo "Can't add Sta interface on $radio."
>>>>> +				exit 1
>>>>> +			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]/keyxchangev2data" -O
>>> /tmp/keyxchangev2data
>>>>> +	else
>>>>> +		echo "We have a Gateway in Range, we load the
>>> keyxchangev2data from fe80::1"
>>>>> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data"
>>> -O /tmp/keyxchangev2data
>>>>> +	fi
>>>>> +
>>>>> +
>>>>> +fi
>>>>> +
>>>>> +if [ -s /tmp/keyxchangev2data ]; then
>>>>> +
>>>>> +	# we get a json file in this format:
>>>>> +	# https://pw.freifunk-franken.de/patch/205/
>>>>> +	# but without signature, every hood file we get is valid!
>>>>> +
>>>>> +	json_load "$(cat /tmp/keyxchangev2data)"
>>>>> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
>>>>> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d "
>>> ")
>>>>> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then
> 
> [ ! -f /tmp/keyxchangev2data]
> wäre richtig, da wir da ja rein wollen wenn die File NICHT existiert.
> 
> mfg
> 
> Christian
> 
>>>
>>> möp wichtiges Leerzeichen vor ]
>>>
>>>>> +		echo "New file detect, we reconfigure the Node";
>>>>> +
>>>>> +		# copy the file to webroot that other Meshrouter can
>>> download them
>>>>> +		cp /tmp/keyxchangev2data /www/public/
>>>>> +
>>>>> +		json_select hood
>>>>> +
>>>>> +		json_get_var hood name
>>>>> +		json_get_var mesh_bssid mesh_bssid
>>>>> +		json_get_var mesh_essid mesh_essid
>>>>> +		json_get_var essid essid
>>>>> +		# i think the next things we don't active this in the first
>>> version! we can do it later
>>>>> +		#json_get_var channel2 channel2
>>>>> +		#json_get_var mode2 mode2
>>>>> +		#json_get_var type2 type2
>>>>> +		#json_get_var channel5 channel5
>>>>> +		#json_get_var mode5 mode5
>>>>> +		#json_get_var type5 type5
>>>>> +		#json_get_var protocol protocol
>>>>> +
>>>>> +		echo "Setting hood name: $hood"
>>>>> +		uci set system.@system[0].hood=$hood
>>>>> +
>>>>> +		if ! wifiDelAll; then
>>>>> +			echo "Can't delete current wifi setup"
>>>>> +			exit 1
>>>>> +		fi
>>>>> +
>>>>> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
>>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>>> +				echo "$phy is 2.4 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy" "1")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>>> +				echo "$phy is 5 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy" "13")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +
>>>>> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0";
>> then
>>>>> +				echo "Can't add AP interface on $radio."
>>>>> +				exit 1
>>>>> +			fi
>>>>> +
>>>>> +			# here we set a bit for add hidden AP
>>>>> +			touch /tmp/hiddenapflag
>>>>> +
>>>>> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid"
>>> "$mesh_bssid"; then
>>>>> +				echo "Can't add AP interface on $radio."
>>>>> +				exit 1
>>>>> +			fi
>>>>> +		done
>>>>> +
>>>>> +		echo "Loading wifi"
>>>>> +		wifi
>>>>> +
>>>>> +
>>>>> +	else
>>>>> +		echo "we have no new file or we have no file get. We do
>>> nothing. We try it again in 5 minutes...";
>>>>> +	fi
>>>>> +
>>>>> +	# and now we read the VPN Data and give this data to fff-vpn
>>>
>>> hier ist (warum auch immer) ein:
>>>
>>> json_load "$(cat /tmp/keyxchangev2data)"
>>>
>>> nötig obwohl es oben schon gemacht wurde, warum? Weiß ich gerade nicht
>>> genau aber ohne geht es nicht.
>>>
>>>>> +
>>>>> +	json_select vpn
>>>>> +	Index="1"
>>>>> +	rm /tmp/fastd_fff_output
>>>>> +	touch /tmp/fastd_fff_output
>>>>> +	while json_select $Index > /dev/null
>>>>> +	do
>>>>> +		json_get_var protocol protocol
>>>>> +		if [ "$protocol" == "fastd"]; then
>>>
>>> möp, wichtiges Leerzeichen vor ]
>>>
>>> mfg
>>>
>>> Christian
>>>
>>>>> +			json_get_var servername name
>>>>> +			echo "####$servername.conf" >>
>>> /tmp/fastd_fff_output
>>>>> +			echo "#name \"$servername\";" >>
>>> /tmp/fastd_fff_output
>>>>> +			json_get_var key key
>>>>> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
>>>>> +			json_get_var address address
>>>>> +			json_get_var port port
>>>>> +			echo "remote ipv4 \"$address\" port $port float;" >>
>>> /tmp/fastd_fff_output
>>>>> +		fi
>>>>> +		echo "" >> /tmp/fastd_fff_output
>>>>> +		echo "###" >> /tmp/fastd_fff_output
>>>>> +	done
>>>>> +	#this we do every 5 minutes, because it can change the VPN Protocol
>>>>> +	#and now we get to vpn-select Script and load VPNs
>>>>> +	sh /usr/sbin/vpn-select
>>>>> +fi
>>>>
>>>>
>>>>
>>>>
>>
>>
> 
> 
>
Christian Dresel Sept. 27, 2017, 10:35 a.m.
noch ein Fehler:

On 27.09.2017 09:54, Christian Dresel wrote:
> hi
> 
> Das ganze Paket muss noch in der fff-base aktiviert werden, das hab aber
> wohl schon ich vermasselt da es wohl auch schon in den früheren
> Patchversionen von mir fehlt. Sollte bei der nächsten Version mit
> nachgetragen werden.
> 
> mfg
> 
> Christian
> 
> (sry wegen der doppelten Mail, ich hab die Absenderadresse mal wieder
> vermurkst...)
> 
> On 21.09.2017 16:02, Adrian Schmutzler wrote:
>> From: Christian Dresel <fff@chrisi01.de>
>>
>> this packages connect to keyxchangev2
>> after review we must change the serveradress! This is only a example
>>
>> Signed-off-by: Christian Dresel <fff@chrisi01.de>
>> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
>>
>> Update in v2:
>>  - clean tabstops
>>  - move the json vpn out of the if because we need this after reboot
>>
>> Update in v5:
>> 	!!UNTESTED!!
>>  - change hidden AP ip to locallink
>>  - Open hidden AP after more checks
>>  - Load json File from Gateway if Gateway in Batman in Range
>>
>> Update in v6:
>> 	!!UNTESTED!!
>>  - fix hidden station v6
>>  - fix -n to -f if
>>  - Add function to check for a gateway and use this
>>  - remove /etc/community.cfg and variables
>>  - send fewer infos to keyxchangev2
>>  - add a check if /tmp/keyxchangev2 not downloadable and edit a bit  on the wgets
>>  - change the position from json_load and do this only 1 times
>>
>> Update in v7:
>> 	!!UNTESTED!!
>>  - delete keyxchangev2data at start of the script
>>  - do only things with keyxchangev2data if available
>>  - change keyxchangev2 url
>>
>> Update in v8/v9:
>>  - rebase onto 20170918-beta
>> ---
>>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
>>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
>>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
>>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205 +++++++++++++++++++++
>>  4 files changed, 250 insertions(+)
>>  create mode 100644 src/packages/fff/fff-hoods/Makefile
>>  create mode 100644 src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>  create mode 100644 src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>  create mode 100755 src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>
>> diff --git a/src/packages/fff/fff-hoods/Makefile b/src/packages/fff/fff-hoods/Makefile
>> new file mode 100644
>> index 0000000..f85178d
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/Makefile
>> @@ -0,0 +1,39 @@
>> +include $(TOPDIR)/rules.mk
>> +
>> +PKG_NAME:=fff-hoods
>> +PKG_VERSION:=0.0.1
>> +PKG_RELEASE:=1
>> +
>> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
>> +
>> +include $(INCLUDE_DIR)/package.mk
>> +
>> +define Package/fff-hoods
>> +    SECTION:=base
>> +    CATEGORY:=Freifunk
>> +    TITLE:= Freifunk-Franken hoods
>> +    URL:=http://www.freifunk-franken.de
>> +    DEPENDS:=+fff-network
>> +endef
>> +
>> +define Package/fff-hoods/description
>> +    This package load and configures the current hood
>> +endef
>> +
>> +define Build/Prepare
>> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile
>> +endef
>> +
>> +define Build/Configure
>> +	# nothing
>> +endef
>> +
>> +define Build/Compile
>> +	# nothing
>> +endef
>> +
>> +define Package/fff-hoods/install
>> +	$(CP) ./files/* $(1)/
>> +endef
>> +
>> +$(eval $(call BuildPackage,fff-hoods))
>> diff --git a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>> new file mode 100644
>> index 0000000..49f53e3
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>> @@ -0,0 +1,5 @@
>> +#!/bin/sh 
>> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
>> +       sleep 3
>> +       /usr/sbin/configurehood
>> +}
>> diff --git a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>> new file mode 100644
>> index 0000000..ca8d798
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>> @@ -0,0 +1 @@
>> +*/5 * * * * /usr/sbin/configurehood
>> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>> new file mode 100755
>> index 0000000..bfec822
>> --- /dev/null
>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>> @@ -0,0 +1,205 @@
>> +#!/bin/sh
>> +
>> +. /usr/share/libubox/jshn.sh
>> +. /lib/functions/fff/wireless
>> +
>> +rm /tmp/keyxchangev2data
>> +
>> +#Gatewaycheck function
>> +isGatewayAvailable() {
>> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
>> +		return true;
>> +	else
>> +		return false;
>> +	fi
>> +}
>> +
>> +
>> +# hidden AP check
>> +
>> +if [ -f /tmp/hiddenapflag ]; then
>> +	if [ isGatewayAvailable ]; then
>> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net" "configap" "configap" "1"; then

hier ist die Variable $radio noch nicht gesetzt, daher wird dem hidden
AP kein radio mitgegeben, folgende Zeile

wireless.w2configap.device='radio0'

fehlt komplett.

Muss man auch noch irgendwie fixen.

mfg

Christian

>> +			echo "Can't add AP interface on $radio."
>> +			exit 1
>> +		else
>> +			#we must set here a fix ip adress
>> +			uci set network.configap=interface
>> +			uci set network.configap.proto='static'
>> +			uci set network.configap.ip6addr='fe80::1/64'
>> +			uci commit network
>> +		fi
>> +	else
>> +		rm /tmp/hiddenapflag
>> +	fi
>> +fi
>> +
>> +
>> +lat=$(uci get system.@system[0].latitude)
>> +long=$(uci get system.@system[0].longitude)
>> +hostname=$(cat /proc/sys/kernel/hostname)
>> +[ "$hostname" = "OpenWrt" ] && hostname=""
>> +[ "$hostname" = "" ] &&  hostname="$mac"
>> +
>> +test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken keyserver
>> +test_ipv4_host2="8.8.8.8"        # Google DNS
>> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
>> +
>> +# if we have Internet, we download the Hoodfile from the keyxchangev2
>> +if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
>> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
>> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
>> +	wget -T15 -t5 "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
>> +	#if no Internet, we connect to the hidden AP and download the file from another Node in range 
>> +else
>> +	# connect to wireless hidden ap here and download from the next router the json File -O /tmp/keyxchangev2data
>> +	# only to that, when we have no gateway in range. If the Uplinkrouter change the hood, we lost the GW and to this automatically again i think! Nice idea?
>> +	if [ ! isGatewayAvailable ]; then
>> +		#now we haven't a gateway in Range, we search for a hidden AP to get a keyxchangev2data file!
>> +		#first we delete all wifi settings
>> +		if ! wifiDelAll; 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
>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>> +				echo "$phy is 2.4 GHz"
>> +				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>> +				echo "$phy is 5 GHz"
>> +				radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +			#and here we add the station
>> +			if ! wifiAddSta "$radio" "config.franken.freifunk.net" "configSta"; then
>> +				echo "Can't add Sta interface on $radio."
>> +				exit 1
>> +			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]/keyxchangev2data" -O /tmp/keyxchangev2data   
>> +	else
>> +		echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
>> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data" -O /tmp/keyxchangev2data 
>> +	fi
>> +
>> +
>> +fi
>> +
>> +if [ -s /tmp/keyxchangev2data ]; then
>> +
>> +	# we get a json file in this format: 
>> +	# https://pw.freifunk-franken.de/patch/205/
>> +	# but without signature, every hood file we get is valid!
>> +
>> +	json_load "$(cat /tmp/keyxchangev2data)"
>> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
>> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d " ")
>> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then
>> +		echo "New file detect, we reconfigure the Node";
>> +
>> +		# copy the file to webroot that other Meshrouter can download them
>> +		cp /tmp/keyxchangev2data /www/public/
>> +
>> +		json_select hood
>> +
>> +		json_get_var hood name
>> +		json_get_var mesh_bssid mesh_bssid
>> +		json_get_var mesh_essid mesh_essid
>> +		json_get_var essid essid
>> +		# i think the next things we don't active this in the first version! we can do it later
>> +		#json_get_var channel2 channel2
>> +		#json_get_var mode2 mode2
>> +		#json_get_var type2 type2
>> +		#json_get_var channel5 channel5
>> +		#json_get_var mode5 mode5
>> +		#json_get_var type5 type5
>> +		#json_get_var protocol protocol
>> +
>> +		echo "Setting hood name: $hood"
>> +		uci set system.@system[0].hood=$hood
>> +
>> +		if ! wifiDelAll; then
>> +			echo "Can't delete current wifi setup"
>> +			exit 1
>> +		fi
>> +
>> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>> +				echo "$phy is 2.4 GHz"
>> +				radio=$(wifiAddPhy "$phy" "1")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>> +				echo "$phy is 5 GHz"
>> +				radio=$(wifiAddPhy "$phy" "13")
>> +				if [ -z "$radio" ]; then
>> +					echo "Can't create radio for $phy"
>> +					exit 1
>> +				fi
>> +			fi
>> +
>> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0"; then
>> +				echo "Can't add AP interface on $radio."
>> +				exit 1
>> +			fi
>> +
>> +			# here we set a bit for add hidden AP
>> +			touch /tmp/hiddenapflag
>> +
>> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid" "$mesh_bssid"; then
>> +				echo "Can't add AP interface on $radio."
>> +				exit 1
>> +			fi
>> +		done
>> +
>> +		echo "Loading wifi"
>> +		wifi
>> +
>> +
>> +	else
>> +		echo "we have no new file or we have no file get. We do nothing. We try it again in 5 minutes...";
>> +	fi
>> +
>> +	# and now we read the VPN Data and give this data to fff-vpn
>> +
>> +	json_select vpn
>> +	Index="1"
>> +	rm /tmp/fastd_fff_output
>> +	touch /tmp/fastd_fff_output
>> +	while json_select $Index > /dev/null
>> +	do                                                                                                                                                                                            
>> +		json_get_var protocol protocol                                                                                                                                                            
>> +		if [ "$protocol" == "fastd"]; then
>> +			json_get_var servername name
>> +			echo "####$servername.conf" >> /tmp/fastd_fff_output
>> +			echo "#name \"$servername\";" >> /tmp/fastd_fff_output
>> +			json_get_var key key
>> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
>> +			json_get_var address address
>> +			json_get_var port port
>> +			echo "remote ipv4 \"$address\" port $port float;" >> /tmp/fastd_fff_output
>> +		fi
>> +		echo "" >> /tmp/fastd_fff_output
>> +		echo "###" >> /tmp/fastd_fff_output
>> +	done
>> +	#this we do every 5 minutes, because it can change the VPN Protocol
>> +	#and now we get to vpn-select Script and load VPNs
>> +	sh /usr/sbin/vpn-select
>> +fi
> 
> 
> 
>
Christian Dresel Sept. 27, 2017, 10:52 a.m.
und es geht weiter

On 27.09.2017 12:15, Christian Dresel wrote:
> hi
> 
> On 27.09.2017 11:25, mail@adrianschmutzler.de wrote:
>> Hallo,
>>
>> ist das so jetzt schon benutzbar?
> 
> es fehlen noch Gateways, wenn du die Router Koordinatentechnisch nach
> Fürth setzt (in der Nähe von
> http://keyserver.freifunk-franken.de/v2/?lat=49.48&long=10.9 damit du
> nicht in Nürnberg landest was noch kein GW hat:
> http://keyserver.freifunk-franken.de/v2/?lat=47.48&long=9.9 ) könnte es
> schon halbwegs klappen (Internetrouting ist noch ungetestet, das mach
> ich jetzt gleich aber per Batman sollte er sich schon verbinden), ich
> bin grad dabei einiges zu fixen und das GW zum laufen zu bringen, ist
> aber noch SEHR testphasig und kann jederzeit noch viel kaputt gehen,
> also bitte nur Router flashen die bei dir daheim zum testen rumstehen.
> 
> Auch das ganze Patchset ist noch experiementell wie man an meinen Mails
> und div. Fehlern die noch auftauchen sieht ;)
> 
>>
>> Würde bei mir ein paar Router testweise flashen ...
>>
>> Durch das neue Batman dürften die ja dann keine Loops mit meiner bestehenden
>> Installation bauen, oder?
> 
> da sich die BSSID ändert sowieso nicht, das Problem wird sich mit dem
> keyxchangev2 komplett lösen da jede Hood ne eigene BSSID hat damit kann
> es gar keine Loops mehr geben (JUCHU keine Arbeit mehr ;))
> 
> Kleine Anmerkung noch Inline im Code, bin auf einen weiteren Fehler
> gestolpert:
> 
>>
>> Grüße
>>
>> Adrian
>>
>>> -----Original Message-----
>>> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
>>> Of Christian Dresel
>>> Sent: Mittwoch, 27. September 2017 10:53
>>> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken-
>>> dev@freifunk.net
>>> Cc: Jan Kraus <mayosemmel@gmail.com>
>>> Subject: Re: [v9,4/4] Add fff-hoods
>>>
>>> Falls jemand damit arbeiten will, einige Syntaxfehler:
>>>
>>> On 27.09.2017 09:54, Christian Dresel wrote:
>>>> hi
>>>>
>>>> Das ganze Paket muss noch in der fff-base aktiviert werden, das hab
>>>> aber wohl schon ich vermasselt da es wohl auch schon in den früheren
>>>> Patchversionen von mir fehlt. Sollte bei der nächsten Version mit
>>>> nachgetragen werden.
>>>>
>>>> mfg
>>>>
>>>> Christian
>>>>
>>>> (sry wegen der doppelten Mail, ich hab die Absenderadresse mal wieder
>>>> vermurkst...)
>>>>
>>>> On 21.09.2017 16:02, Adrian Schmutzler wrote:
>>>>> From: Christian Dresel <fff@chrisi01.de>
>>>>>
>>>>> this packages connect to keyxchangev2 after review we must change the
>>>>> serveradress! This is only a example
>>>>>
>>>>> Signed-off-by: Christian Dresel <fff@chrisi01.de>
>>>>> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
>>>>>
>>>>> Update in v2:
>>>>>  - clean tabstops
>>>>>  - move the json vpn out of the if because we need this after reboot
>>>>>
>>>>> Update in v5:
>>>>> 	!!UNTESTED!!
>>>>>  - change hidden AP ip to locallink
>>>>>  - Open hidden AP after more checks
>>>>>  - Load json File from Gateway if Gateway in Batman in Range
>>>>>
>>>>> Update in v6:
>>>>> 	!!UNTESTED!!
>>>>>  - fix hidden station v6
>>>>>  - fix -n to -f if
>>>>>  - Add function to check for a gateway and use this
>>>>>  - remove /etc/community.cfg and variables
>>>>>  - send fewer infos to keyxchangev2
>>>>>  - add a check if /tmp/keyxchangev2 not downloadable and edit a bit
>>>>> on the wgets
>>>>>  - change the position from json_load and do this only 1 times
>>>>>
>>>>> Update in v7:
>>>>> 	!!UNTESTED!!
>>>>>  - delete keyxchangev2data at start of the script
>>>>>  - do only things with keyxchangev2data if available
>>>>>  - change keyxchangev2 url
>>>>>
>>>>> Update in v8/v9:
>>>>>  - rebase onto 20170918-beta
>>>>> ---
>>>>>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
>>>>>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
>>>>>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
>>>>>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205
>>> +++++++++++++++++++++
>>>>>  4 files changed, 250 insertions(+)
>>>>>  create mode 100644 src/packages/fff/fff-hoods/Makefile
>>>>>  create mode 100644
>>>>> src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>>  create mode 100644
>>>>> src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>>  create mode 100755
>>>>> src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>>
>>>>> diff --git a/src/packages/fff/fff-hoods/Makefile
>>>>> b/src/packages/fff/fff-hoods/Makefile
>>>>> new file mode 100644
>>>>> index 0000000..f85178d
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/Makefile
>>>>> @@ -0,0 +1,39 @@
>>>>> +include $(TOPDIR)/rules.mk
>>>>> +
>>>>> +PKG_NAME:=fff-hoods
>>>>> +PKG_VERSION:=0.0.1
>>>>> +PKG_RELEASE:=1
>>>>> +
>>>>> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
>>>>> +
>>>>> +include $(INCLUDE_DIR)/package.mk
>>>>> +
>>>>> +define Package/fff-hoods
>>>>> +    SECTION:=base
>>>>> +    CATEGORY:=Freifunk
>>>>> +    TITLE:= Freifunk-Franken hoods
>>>>> +    URL:=http://www.freifunk-franken.de
>>>>> +    DEPENDS:=+fff-network
>>>>> +endef
>>>>> +
>>>>> +define Package/fff-hoods/description
>>>>> +    This package load and configures the current hood endef
>>>>> +
>>>>> +define Build/Prepare
>>>>> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile endef
>>>>> +
>>>>> +define Build/Configure
>>>>> +	# nothing
>>>>> +endef
>>>>> +
>>>>> +define Build/Compile
>>>>> +	# nothing
>>>>> +endef
>>>>> +
>>>>> +define Package/fff-hoods/install
>>>>> +	$(CP) ./files/* $(1)/
>>>>> +endef
>>>>> +
>>>>> +$(eval $(call BuildPackage,fff-hoods))
>>>>> diff --git
>>>>> a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>> b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>> new file mode 100644
>>>>> index 0000000..49f53e3
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoo
>>>>> +++ ds
>>>>> @@ -0,0 +1,5 @@
>>>>> +#!/bin/sh
>>>>> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
>>>>> +       sleep 3
>>>>> +       /usr/sbin/configurehood
>>>>> +}
>>>>> diff --git
>>>>> a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> new file mode 100644
>>>>> index 0000000..ca8d798
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> @@ -0,0 +1 @@
>>>>> +*/5 * * * * /usr/sbin/configurehood
>>>>> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> new file mode 100755
>>>>> index 0000000..bfec822
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> @@ -0,0 +1,205 @@
>>>>> +#!/bin/sh
>>>>> +
>>>>> +. /usr/share/libubox/jshn.sh
>>>>> +. /lib/functions/fff/wireless
>>>>> +
>>>>> +rm /tmp/keyxchangev2data
>>>>> +
>>>>> +#Gatewaycheck function
>>>>> +isGatewayAvailable() {
>>>>> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
>>>>> +		return true;
>>>>> +	else
>>>>> +		return false;
>>>>> +	fi
>>>>> +}
>>>>> +
>>>>> +
>>>>> +# hidden AP check
>>>>> +
>>>>> +if [ -f /tmp/hiddenapflag ]; then
>>>>> +	if [ isGatewayAvailable ]; then
>>>>> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net"
>>> "configap" "configap" "1"; then
>>>>> +			echo "Can't add AP interface on $radio."
>>>>> +			exit 1
>>>>> +		else
>>>>> +			#we must set here a fix ip adress
>>>>> +			uci set network.configap=interface
>>>>> +			uci set network.configap.proto='static'
>>>>> +			uci set network.configap.ip6addr='fe80::1/64'
>>>>> +			uci commit network
>>>>> +		fi
>>>>> +	else
>>>>> +		rm /tmp/hiddenapflag
>>>>> +	fi
>>>>> +fi
>>>>> +
>>>>> +
>>>>> +lat=$(uci get system.@system[0].latitude) long=$(uci get
>>>>> +system.@system[0].longitude) hostname=$(cat
>>>>> +/proc/sys/kernel/hostname) [ "$hostname" = "OpenWrt" ] &&
>>>>> +hostname=""
>>>>> +[ "$hostname" = "" ] &&  hostname="$mac"
>>>>> +
>>>>> +test_ipv4_host1="keyserver.freifunk-franken.de" # Freifunk-Franken
>>> keyserver
>>>>> +test_ipv4_host2="8.8.8.8"        # Google DNS
>>>>> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
>>>>> +
>>>>> +# if we have Internet, we download the Hoodfile from the
>>>>> +keyxchangev2 if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
>>>>> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
>>>>> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
>>>>> +	wget -T15 -t5 "http://keyserver.freifunk-
>>> franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
>>>>> +	#if no Internet, we connect to the hidden AP and download the file
>>>>> +from another Node in range else
>>>>> +	# connect to wireless hidden ap here and download from the next
>>> router the json File -O /tmp/keyxchangev2data
>>>>> +	# only to that, when we have no gateway in range. If the
>>> Uplinkrouter change the hood, we lost the GW and to this automatically
>>> again i think! Nice idea?
>>>>> +	if [ ! isGatewayAvailable ]; then
>>>>> +		#now we haven't a gateway in Range, we search for a hidden
>>> AP to get a keyxchangev2data file!
>>>>> +		#first we delete all wifi settings
>>>>> +		if ! wifiDelAll; 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
>>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>>> +				echo "$phy is 2.4 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy"
>>> "$BATMAN_CHANNEL")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>>> +				echo "$phy is 5 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy"
>>> "$BATMAN_CHANNEL_5GHZ")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			#and here we add the station
>>>>> +			if ! wifiAddSta "$radio"
>> "config.franken.freifunk.net"
>>> "configSta"; then
>>>>> +				echo "Can't add Sta interface on $radio."
>>>>> +				exit 1
>>>>> +			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]/keyxchangev2data" -O
>>> /tmp/keyxchangev2data
>>>>> +	else
>>>>> +		echo "We have a Gateway in Range, we load the
>>> keyxchangev2data from fe80::1"
>>>>> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data"
>>> -O /tmp/keyxchangev2data
>>>>> +	fi
>>>>> +
>>>>> +
>>>>> +fi
>>>>> +
>>>>> +if [ -s /tmp/keyxchangev2data ]; then
>>>>> +
>>>>> +	# we get a json file in this format:
>>>>> +	# https://pw.freifunk-franken.de/patch/205/
>>>>> +	# but without signature, every hood file we get is valid!
>>>>> +
>>>>> +	json_load "$(cat /tmp/keyxchangev2data)"
>>>>> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
>>>>> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d "
>>> ")
>>>>> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; then
> 
> [ ! -f /tmp/keyxchangev2data]

dazu kommt noch, das wir da natürlich rein wollen wenn:

"$sumnew" != "$sumold" ODER ! -f /tmp/keyxchangev2data

also wäre nun richtig:

if [ "$sumnew" != "$sumold" ] || [ ! -f /tmp/keyxchangev2data]; then

mfg

Christian

> wäre richtig, da wir da ja rein wollen wenn die File NICHT existiert.
> 
> mfg
> 
> Christian
> 
>>>
>>> möp wichtiges Leerzeichen vor ]
>>>
>>>>> +		echo "New file detect, we reconfigure the Node";
>>>>> +
>>>>> +		# copy the file to webroot that other Meshrouter can
>>> download them
>>>>> +		cp /tmp/keyxchangev2data /www/public/
>>>>> +
>>>>> +		json_select hood
>>>>> +
>>>>> +		json_get_var hood name
>>>>> +		json_get_var mesh_bssid mesh_bssid
>>>>> +		json_get_var mesh_essid mesh_essid
>>>>> +		json_get_var essid essid
>>>>> +		# i think the next things we don't active this in the first
>>> version! we can do it later
>>>>> +		#json_get_var channel2 channel2
>>>>> +		#json_get_var mode2 mode2
>>>>> +		#json_get_var type2 type2
>>>>> +		#json_get_var channel5 channel5
>>>>> +		#json_get_var mode5 mode5
>>>>> +		#json_get_var type5 type5
>>>>> +		#json_get_var protocol protocol
>>>>> +
>>>>> +		echo "Setting hood name: $hood"
>>>>> +		uci set system.@system[0].hood=$hood
>>>>> +
>>>>> +		if ! wifiDelAll; then
>>>>> +			echo "Can't delete current wifi setup"
>>>>> +			exit 1
>>>>> +		fi
>>>>> +
>>>>> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
>>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>>> +				echo "$phy is 2.4 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy" "1")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>>> +				echo "$phy is 5 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy" "13")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +
>>>>> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0";
>> then
>>>>> +				echo "Can't add AP interface on $radio."
>>>>> +				exit 1
>>>>> +			fi
>>>>> +
>>>>> +			# here we set a bit for add hidden AP
>>>>> +			touch /tmp/hiddenapflag
>>>>> +
>>>>> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid"
>>> "$mesh_bssid"; then
>>>>> +				echo "Can't add AP interface on $radio."
>>>>> +				exit 1
>>>>> +			fi
>>>>> +		done
>>>>> +
>>>>> +		echo "Loading wifi"
>>>>> +		wifi
>>>>> +
>>>>> +
>>>>> +	else
>>>>> +		echo "we have no new file or we have no file get. We do
>>> nothing. We try it again in 5 minutes...";
>>>>> +	fi
>>>>> +
>>>>> +	# and now we read the VPN Data and give this data to fff-vpn
>>>
>>> hier ist (warum auch immer) ein:
>>>
>>> json_load "$(cat /tmp/keyxchangev2data)"
>>>
>>> nötig obwohl es oben schon gemacht wurde, warum? Weiß ich gerade nicht
>>> genau aber ohne geht es nicht.
>>>
>>>>> +
>>>>> +	json_select vpn
>>>>> +	Index="1"
>>>>> +	rm /tmp/fastd_fff_output
>>>>> +	touch /tmp/fastd_fff_output
>>>>> +	while json_select $Index > /dev/null
>>>>> +	do
>>>>> +		json_get_var protocol protocol
>>>>> +		if [ "$protocol" == "fastd"]; then
>>>
>>> möp, wichtiges Leerzeichen vor ]
>>>
>>> mfg
>>>
>>> Christian
>>>
>>>>> +			json_get_var servername name
>>>>> +			echo "####$servername.conf" >>
>>> /tmp/fastd_fff_output
>>>>> +			echo "#name \"$servername\";" >>
>>> /tmp/fastd_fff_output
>>>>> +			json_get_var key key
>>>>> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
>>>>> +			json_get_var address address
>>>>> +			json_get_var port port
>>>>> +			echo "remote ipv4 \"$address\" port $port float;" >>
>>> /tmp/fastd_fff_output
>>>>> +		fi
>>>>> +		echo "" >> /tmp/fastd_fff_output
>>>>> +		echo "###" >> /tmp/fastd_fff_output
>>>>> +	done
>>>>> +	#this we do every 5 minutes, because it can change the VPN Protocol
>>>>> +	#and now we get to vpn-select Script and load VPNs
>>>>> +	sh /usr/sbin/vpn-select
>>>>> +fi
>>>>
>>>>
>>>>
>>>>
>>
>>
> 
> 
>
Adrian Schmutzler Sept. 27, 2017, 11:49 a.m.
Ich bau morgen abend nen neuen Patch und teste den dann evtl. ...

Grüße

Adrian

-----Original Message-----
From: Christian Dresel [mailto:fff@chrisi01.de] 
Sent: Mittwoch, 27. September 2017 12:53
To: mail@adrianschmutzler.de; franken-dev@freifunk.net
Subject: Re: [v9,4/4] Add fff-hoods

und es geht weiter

On 27.09.2017 12:15, Christian Dresel wrote:
> hi
> 
> On 27.09.2017 11:25, mail@adrianschmutzler.de wrote:
>> Hallo,
>>
>> ist das so jetzt schon benutzbar?
> 
> es fehlen noch Gateways, wenn du die Router Koordinatentechnisch nach 
> Fürth setzt (in der Nähe von
> http://keyserver.freifunk-franken.de/v2/?lat=49.48&long=10.9 damit du 
> nicht in Nürnberg landest was noch kein GW hat:
> http://keyserver.freifunk-franken.de/v2/?lat=47.48&long=9.9 ) könnte 
> es schon halbwegs klappen (Internetrouting ist noch ungetestet, das 
> mach ich jetzt gleich aber per Batman sollte er sich schon verbinden), 
> ich bin grad dabei einiges zu fixen und das GW zum laufen zu bringen, 
> ist aber noch SEHR testphasig und kann jederzeit noch viel kaputt 
> gehen, also bitte nur Router flashen die bei dir daheim zum testen
rumstehen.
> 
> Auch das ganze Patchset ist noch experiementell wie man an meinen 
> Mails und div. Fehlern die noch auftauchen sieht ;)
> 
>>
>> Würde bei mir ein paar Router testweise flashen ...
>>
>> Durch das neue Batman dürften die ja dann keine Loops mit meiner 
>> bestehenden Installation bauen, oder?
> 
> da sich die BSSID ändert sowieso nicht, das Problem wird sich mit dem
> keyxchangev2 komplett lösen da jede Hood ne eigene BSSID hat damit 
> kann es gar keine Loops mehr geben (JUCHU keine Arbeit mehr ;))
> 
> Kleine Anmerkung noch Inline im Code, bin auf einen weiteren Fehler
> gestolpert:
> 
>>
>> Grüße
>>
>> Adrian
>>
>>> -----Original Message-----
>>> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On 
>>> Behalf Of Christian Dresel
>>> Sent: Mittwoch, 27. September 2017 10:53
>>> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken- 
>>> dev@freifunk.net
>>> Cc: Jan Kraus <mayosemmel@gmail.com>
>>> Subject: Re: [v9,4/4] Add fff-hoods
>>>
>>> Falls jemand damit arbeiten will, einige Syntaxfehler:
>>>
>>> On 27.09.2017 09:54, Christian Dresel wrote:
>>>> hi
>>>>
>>>> Das ganze Paket muss noch in der fff-base aktiviert werden, das hab 
>>>> aber wohl schon ich vermasselt da es wohl auch schon in den 
>>>> früheren Patchversionen von mir fehlt. Sollte bei der nächsten 
>>>> Version mit nachgetragen werden.
>>>>
>>>> mfg
>>>>
>>>> Christian
>>>>
>>>> (sry wegen der doppelten Mail, ich hab die Absenderadresse mal 
>>>> wieder
>>>> vermurkst...)
>>>>
>>>> On 21.09.2017 16:02, Adrian Schmutzler wrote:
>>>>> From: Christian Dresel <fff@chrisi01.de>
>>>>>
>>>>> this packages connect to keyxchangev2 after review we must change 
>>>>> the serveradress! This is only a example
>>>>>
>>>>> Signed-off-by: Christian Dresel <fff@chrisi01.de>
>>>>> Signed-off-by: Jan Kraus <mayosemmel@gmail.com>
>>>>>
>>>>> Update in v2:
>>>>>  - clean tabstops
>>>>>  - move the json vpn out of the if because we need this after 
>>>>> reboot
>>>>>
>>>>> Update in v5:
>>>>> 	!!UNTESTED!!
>>>>>  - change hidden AP ip to locallink
>>>>>  - Open hidden AP after more checks
>>>>>  - Load json File from Gateway if Gateway in Batman in Range
>>>>>
>>>>> Update in v6:
>>>>> 	!!UNTESTED!!
>>>>>  - fix hidden station v6
>>>>>  - fix -n to -f if
>>>>>  - Add function to check for a gateway and use this
>>>>>  - remove /etc/community.cfg and variables
>>>>>  - send fewer infos to keyxchangev2
>>>>>  - add a check if /tmp/keyxchangev2 not downloadable and edit a 
>>>>> bit on the wgets
>>>>>  - change the position from json_load and do this only 1 times
>>>>>
>>>>> Update in v7:
>>>>> 	!!UNTESTED!!
>>>>>  - delete keyxchangev2data at start of the script
>>>>>  - do only things with keyxchangev2data if available
>>>>>  - change keyxchangev2 url
>>>>>
>>>>> Update in v8/v9:
>>>>>  - rebase onto 20170918-beta
>>>>> ---
>>>>>  src/packages/fff/fff-hoods/Makefile                |  39 ++++
>>>>>  .../files/etc/hotplug.d/iface/50-fff-hoods         |   5 +
>>>>>  .../fff/fff-hoods/files/usr/lib/micron.d/fff-hoods |   1 +
>>>>>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 205
>>> +++++++++++++++++++++
>>>>>  4 files changed, 250 insertions(+)  create mode 100644 
>>>>> src/packages/fff/fff-hoods/Makefile
>>>>>  create mode 100644
>>>>> src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hoods
>>>>>  create mode 100644
>>>>> src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>>  create mode 100755
>>>>> src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>>
>>>>> diff --git a/src/packages/fff/fff-hoods/Makefile
>>>>> b/src/packages/fff/fff-hoods/Makefile
>>>>> new file mode 100644
>>>>> index 0000000..f85178d
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/Makefile
>>>>> @@ -0,0 +1,39 @@
>>>>> +include $(TOPDIR)/rules.mk
>>>>> +
>>>>> +PKG_NAME:=fff-hoods
>>>>> +PKG_VERSION:=0.0.1
>>>>> +PKG_RELEASE:=1
>>>>> +
>>>>> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-hoods
>>>>> +
>>>>> +include $(INCLUDE_DIR)/package.mk
>>>>> +
>>>>> +define Package/fff-hoods
>>>>> +    SECTION:=base
>>>>> +    CATEGORY:=Freifunk
>>>>> +    TITLE:= Freifunk-Franken hoods
>>>>> +    URL:=http://www.freifunk-franken.de
>>>>> +    DEPENDS:=+fff-network
>>>>> +endef
>>>>> +
>>>>> +define Package/fff-hoods/description
>>>>> +    This package load and configures the current hood endef
>>>>> +
>>>>> +define Build/Prepare
>>>>> +	echo "all: " > $(PKG_BUILD_DIR)/Makefile endef
>>>>> +
>>>>> +define Build/Configure
>>>>> +	# nothing
>>>>> +endef
>>>>> +
>>>>> +define Build/Compile
>>>>> +	# nothing
>>>>> +endef
>>>>> +
>>>>> +define Package/fff-hoods/install
>>>>> +	$(CP) ./files/* $(1)/
>>>>> +endef
>>>>> +
>>>>> +$(eval $(call BuildPackage,fff-hoods))
>>>>> diff --git
>>>>> a/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hood
>>>>> s 
>>>>> b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-hood
>>>>> s
>>>>> new file mode 100644
>>>>> index 0000000..49f53e3
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/etc/hotplug.d/iface/50-fff-
>>>>> +++ hoo
>>>>> +++ ds
>>>>> @@ -0,0 +1,5 @@
>>>>> +#!/bin/sh
>>>>> +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
>>>>> +       sleep 3
>>>>> +       /usr/sbin/configurehood
>>>>> +}
>>>>> diff --git
>>>>> a/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> new file mode 100644
>>>>> index 0000000..ca8d798
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/usr/lib/micron.d/fff-hoods
>>>>> @@ -0,0 +1 @@
>>>>> +*/5 * * * * /usr/sbin/configurehood
>>>>> diff --git 
>>>>> a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> new file mode 100755
>>>>> index 0000000..bfec822
>>>>> --- /dev/null
>>>>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>>>>> @@ -0,0 +1,205 @@
>>>>> +#!/bin/sh
>>>>> +
>>>>> +. /usr/share/libubox/jshn.sh
>>>>> +. /lib/functions/fff/wireless
>>>>> +
>>>>> +rm /tmp/keyxchangev2data
>>>>> +
>>>>> +#Gatewaycheck function
>>>>> +isGatewayAvailable() {
>>>>> +	if [ "$(batctl gwl | wc -l)" -gt 2 ]; then
>>>>> +		return true;
>>>>> +	else
>>>>> +		return false;
>>>>> +	fi
>>>>> +}
>>>>> +
>>>>> +
>>>>> +# hidden AP check
>>>>> +
>>>>> +if [ -f /tmp/hiddenapflag ]; then
>>>>> +	if [ isGatewayAvailable ]; then
>>>>> +		if ! wifiAddAP "$radio" "config.franken.freifunk.net"
>>> "configap" "configap" "1"; then
>>>>> +			echo "Can't add AP interface on $radio."
>>>>> +			exit 1
>>>>> +		else
>>>>> +			#we must set here a fix ip adress
>>>>> +			uci set network.configap=interface
>>>>> +			uci set network.configap.proto='static'
>>>>> +			uci set network.configap.ip6addr='fe80::1/64'
>>>>> +			uci commit network
>>>>> +		fi
>>>>> +	else
>>>>> +		rm /tmp/hiddenapflag
>>>>> +	fi
>>>>> +fi
>>>>> +
>>>>> +
>>>>> +lat=$(uci get system.@system[0].latitude) long=$(uci get
>>>>> +system.@system[0].longitude) hostname=$(cat
>>>>> +/proc/sys/kernel/hostname) [ "$hostname" = "OpenWrt" ] && 
>>>>> +hostname=""
>>>>> +[ "$hostname" = "" ] &&  hostname="$mac"
>>>>> +
>>>>> +test_ipv4_host1="keyserver.freifunk-franken.de" # 
>>>>> +Freifunk-Franken
>>> keyserver
>>>>> +test_ipv4_host2="8.8.8.8"        # Google DNS
>>>>> +test_ipv6_host1="heise.de"       # heise Zeitschriftenverlag
>>>>> +
>>>>> +# if we have Internet, we download the Hoodfile from the
>>>>> +keyxchangev2 if ping -w5 -c3 "$test_ipv4_host1" &>/dev/null ||
>>>>> +	ping -w5 -c3 "$test_ipv4_host2" &>/dev/null ||
>>>>> +	ping6 -w5 -c3 "$test_ipv6_host1" &>/dev/null; then
>>>>> +	wget -T15 -t5 "http://keyserver.freifunk-
>>> franken.de/v2/?lat=$lat&long=$long" -O /tmp/keyxchangev2data
>>>>> +	#if no Internet, we connect to the hidden AP and download the 
>>>>> +file from another Node in range else
>>>>> +	# connect to wireless hidden ap here and download from the next
>>> router the json File -O /tmp/keyxchangev2data
>>>>> +	# only to that, when we have no gateway in range. If the
>>> Uplinkrouter change the hood, we lost the GW and to this 
>>> automatically again i think! Nice idea?
>>>>> +	if [ ! isGatewayAvailable ]; then
>>>>> +		#now we haven't a gateway in Range, we search for a hidden
>>> AP to get a keyxchangev2data file!
>>>>> +		#first we delete all wifi settings
>>>>> +		if ! wifiDelAll; 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
>>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>>> +				echo "$phy is 2.4 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy"
>>> "$BATMAN_CHANNEL")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>>> +				echo "$phy is 5 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy"
>>> "$BATMAN_CHANNEL_5GHZ")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			#and here we add the station
>>>>> +			if ! wifiAddSta "$radio"
>> "config.franken.freifunk.net"
>>> "configSta"; then
>>>>> +				echo "Can't add Sta interface on $radio."
>>>>> +				exit 1
>>>>> +			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]/keyxchangev2data" -O
>>> /tmp/keyxchangev2data
>>>>> +	else
>>>>> +		echo "We have a Gateway in Range, we load the
>>> keyxchangev2data from fe80::1"
>>>>> +		wget -T15 -t5 "http://[fe80::1%br-mesh]/keyxchangev2data"
>>> -O /tmp/keyxchangev2data
>>>>> +	fi
>>>>> +
>>>>> +
>>>>> +fi
>>>>> +
>>>>> +if [ -s /tmp/keyxchangev2data ]; then
>>>>> +
>>>>> +	# we get a json file in this format:
>>>>> +	# https://pw.freifunk-franken.de/patch/205/
>>>>> +	# but without signature, every hood file we get is valid!
>>>>> +
>>>>> +	json_load "$(cat /tmp/keyxchangev2data)"
>>>>> +	sumnew=$(sha256sum /tmp/keyxchangev2data | cut -f1 -d " ")
>>>>> +	sumold=$(sha256sum /www/public/keyxchangev2data | cut -f1 -d "
>>> ")
>>>>> +	if [ "$sumnew" != "$sumold" ] && [ -f /tmp/keyxchangev2data]; 
>>>>> +then
> 
> [ ! -f /tmp/keyxchangev2data]

dazu kommt noch, das wir da natürlich rein wollen wenn:

"$sumnew" != "$sumold" ODER ! -f /tmp/keyxchangev2data

also wäre nun richtig:

if [ "$sumnew" != "$sumold" ] || [ ! -f /tmp/keyxchangev2data]; then

mfg

Christian

> wäre richtig, da wir da ja rein wollen wenn die File NICHT existiert.
> 
> mfg
> 
> Christian
> 
>>>
>>> möp wichtiges Leerzeichen vor ]
>>>
>>>>> +		echo "New file detect, we reconfigure the Node";
>>>>> +
>>>>> +		# copy the file to webroot that other Meshrouter can
>>> download them
>>>>> +		cp /tmp/keyxchangev2data /www/public/
>>>>> +
>>>>> +		json_select hood
>>>>> +
>>>>> +		json_get_var hood name
>>>>> +		json_get_var mesh_bssid mesh_bssid
>>>>> +		json_get_var mesh_essid mesh_essid
>>>>> +		json_get_var essid essid
>>>>> +		# i think the next things we don't active this in the first
>>> version! we can do it later
>>>>> +		#json_get_var channel2 channel2
>>>>> +		#json_get_var mode2 mode2
>>>>> +		#json_get_var type2 type2
>>>>> +		#json_get_var channel5 channel5
>>>>> +		#json_get_var mode5 mode5
>>>>> +		#json_get_var type5 type5
>>>>> +		#json_get_var protocol protocol
>>>>> +
>>>>> +		echo "Setting hood name: $hood"
>>>>> +		uci set system.@system[0].hood=$hood
>>>>> +
>>>>> +		if ! wifiDelAll; then
>>>>> +			echo "Can't delete current wifi setup"
>>>>> +			exit 1
>>>>> +		fi
>>>>> +
>>>>> +		for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
>>>>> +			if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>>>>> +				echo "$phy is 2.4 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy" "1")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +			if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>>>>> +				echo "$phy is 5 GHz"
>>>>> +				radio=$(wifiAddPhy "$phy" "13")
>>>>> +				if [ -z "$radio" ]; then
>>>>> +					echo "Can't create radio for $phy"
>>>>> +					exit 1
>>>>> +				fi
>>>>> +			fi
>>>>> +
>>>>> +			if ! wifiAddAP "$radio" "$essid" "mesh" "ap" "0";
>> then
>>>>> +				echo "Can't add AP interface on $radio."
>>>>> +				exit 1
>>>>> +			fi
>>>>> +
>>>>> +			# here we set a bit for add hidden AP
>>>>> +			touch /tmp/hiddenapflag
>>>>> +
>>>>> +			if ! wifiAddAdHocMesh "$radio" "$mesh_essid"
>>> "$mesh_bssid"; then
>>>>> +				echo "Can't add AP interface on $radio."
>>>>> +				exit 1
>>>>> +			fi
>>>>> +		done
>>>>> +
>>>>> +		echo "Loading wifi"
>>>>> +		wifi
>>>>> +
>>>>> +
>>>>> +	else
>>>>> +		echo "we have no new file or we have no file get. We do
>>> nothing. We try it again in 5 minutes...";
>>>>> +	fi
>>>>> +
>>>>> +	# and now we read the VPN Data and give this data to fff-vpn
>>>
>>> hier ist (warum auch immer) ein:
>>>
>>> json_load "$(cat /tmp/keyxchangev2data)"
>>>
>>> nötig obwohl es oben schon gemacht wurde, warum? Weiß ich gerade 
>>> nicht genau aber ohne geht es nicht.
>>>
>>>>> +
>>>>> +	json_select vpn
>>>>> +	Index="1"
>>>>> +	rm /tmp/fastd_fff_output
>>>>> +	touch /tmp/fastd_fff_output
>>>>> +	while json_select $Index > /dev/null
>>>>> +	do
>>>>> +		json_get_var protocol protocol
>>>>> +		if [ "$protocol" == "fastd"]; then
>>>
>>> möp, wichtiges Leerzeichen vor ]
>>>
>>> mfg
>>>
>>> Christian
>>>
>>>>> +			json_get_var servername name
>>>>> +			echo "####$servername.conf" >>
>>> /tmp/fastd_fff_output
>>>>> +			echo "#name \"$servername\";" >>
>>> /tmp/fastd_fff_output
>>>>> +			json_get_var key key
>>>>> +			echo "key \"$key\";" >> /tmp/fastd_fff_output
>>>>> +			json_get_var address address
>>>>> +			json_get_var port port
>>>>> +			echo "remote ipv4 \"$address\" port $port float;" >>
>>> /tmp/fastd_fff_output
>>>>> +		fi
>>>>> +		echo "" >> /tmp/fastd_fff_output
>>>>> +		echo "###" >> /tmp/fastd_fff_output
>>>>> +	done
>>>>> +	#this we do every 5 minutes, because it can change the VPN Protocol
>>>>> +	#and now we get to vpn-select Script and load VPNs
>>>>> +	sh /usr/sbin/vpn-select
>>>>> +fi
>>>>
>>>>
>>>>
>>>>
>>
>>
> 
> 
>