From patchwork Sat Oct 14 20:38:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [SQUASHED,v18,6/8] Remove references to community.cfg From: Tim Niemeyer X-Patchwork-Id: 579 Message-Id: <20171014203840.29696-7-tim@tn-x.org> To: franken-dev@freifunk.net Cc: Adrian Schmutzler Date: Sat, 14 Oct 2017 22:38:38 +0200 From: Adrian Schmutzler This removes all references to community.cfg except in the buildscript and except the file itself. Signed-off-by: Adrian Schmutzler Tested-by: Adrian Schmutzler Signed-off-by: Tim Niemeyer --- Changes in v18: - Add jshn.sh to lib/functions/fff/keyxchange Changes in v17: None Changes in v16: None Changes in v15: None Changes in v14: - Removed interface ID for timeserver Changes in v13: - Fixed timeserver and upgrade path to be set by keyxchange Changes in v12: None Changes in v11: None Changes in v10: None Changes in v9: None Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None .../fff-fastd/files/etc/uci-defaults/55_fff-fastd | 41 +++++++++++----------- .../fff-hoods/files/lib/functions/fff/keyxchange | 17 +++++++++ .../fff/fff-hoods/files/usr/sbin/configurehood | 6 ++++ .../fff/fff-support/files/usr/sbin/show_info | 1 - src/packages/fff/fff-sysupgrade/Makefile | 4 +-- .../fff/fff-sysupgrade/files/etc/sysupgrade.sh | 9 ++++- src/packages/fff/fff-timeserver/Makefile | 2 +- .../files/etc/uci-defaults/51-fff-timeserver | 3 +- 8 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange mode change 100755 => 100644 src/packages/fff/fff-timeserver/files/etc/uci-defaults/51-fff-timeserver diff --git a/src/packages/fff/fff-fastd/files/etc/uci-defaults/55_fff-fastd b/src/packages/fff/fff-fastd/files/etc/uci-defaults/55_fff-fastd index 8ce8425..72970bd 100644 --- a/src/packages/fff/fff-fastd/files/etc/uci-defaults/55_fff-fastd +++ b/src/packages/fff/fff-fastd/files/etc/uci-defaults/55_fff-fastd @@ -1,28 +1,27 @@ -/etc/init.d/fastd disable +#!/bin/sh -. /etc/community.cfg -project="$VPN_PROJECT" +/etc/init.d/fastd disable >/etc/config/fastd uci batch < /etc/fastd/${project}/up.sh -echo "ip link set up dev ${project}VPN" >> /etc/fastd/${project}/up.sh -echo "echo enable > /sys/devices/virtual/net/${project}VPN/batman_adv/no_rebroadcast" >> /etc/fastd/${project}/up.sh -echo "batctl if add ${project}VPN" >> /etc/fastd/${project}/up.sh -chmod +x /etc/fastd/${project}/up.sh +[ ! -d /etc/fastd/fff ] && mkdir -p /etc/fastd/fff +ln -s /tmp/fastd_fff_peers /etc/fastd/fff/peers +echo "#!/bin/sh" > /etc/fastd/fff/up.sh +echo "ip link set up dev fffVPN" >> /etc/fastd/fff/up.sh +echo "echo enable > /sys/devices/virtual/net/fffVPN/batman_adv/no_rebroadcast" >> /etc/fastd/fff/up.sh +echo "batctl if add fffVPN" >> /etc/fastd/fff/up.sh +chmod +x /etc/fastd/fff/up.sh diff --git a/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange b/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange new file mode 100644 index 0000000..be27e5a --- /dev/null +++ b/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright 2017 Adrian Schmutzler +# License GPLv3 + +. /usr/share/libubox/jshn.sh + +getUpgradePath() { + if [ -s /tmp/keyxchangev2data ]; then + json_load "$(cat /tmp/keyxchangev2data)" + json_select hood + json_get_var upath upgrade_path + echo "$upath" + else + return 1 + fi + return 0 +} diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood index 9acd275..4057cd0 100755 --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood @@ -2,6 +2,7 @@ . /usr/share/libubox/jshn.sh . /lib/functions/fff/wireless +. /lib/functions/fff/timeserver rm -f /tmp/keyxchangev2data @@ -121,6 +122,7 @@ if [ -s /tmp/keyxchangev2data ]; then json_get_var mesh_bssid mesh_bssid json_get_var mesh_essid mesh_essid json_get_var essid essid + json_get_var ntpip ntp_ip # 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 @@ -162,6 +164,10 @@ if [ -s /tmp/keyxchangev2data ]; then echo "Loading wifi" wifi + oldntp="$(uci -q get system.ntp.server)" + newntp="${ntpip}" # requires routable address, no link-local + [ "$newntp" = "$oldntp" ] || setTimeserver "${newntp}" # only rewrite if changed + # copy the file to webroot so that other Meshrouter can download it; # copy only after all other steps so IF can be reentered if something goes wrong cp /tmp/keyxchangev2data /www/public/ diff --git a/src/packages/fff/fff-support/files/usr/sbin/show_info b/src/packages/fff/fff-support/files/usr/sbin/show_info index fc7cffb..3914391 100755 --- a/src/packages/fff/fff-support/files/usr/sbin/show_info +++ b/src/packages/fff/fff-support/files/usr/sbin/show_info @@ -1,6 +1,5 @@ #!/bin/sh -. /etc/community.cfg . /etc/firmware_release board_name=$(uci -q get board.model.name) diff --git a/src/packages/fff/fff-sysupgrade/Makefile b/src/packages/fff/fff-sysupgrade/Makefile index 3224662..f29cf73 100644 --- a/src/packages/fff/fff-sysupgrade/Makefile +++ b/src/packages/fff/fff-sysupgrade/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fff-sysupgrade -PKG_VERSION:=0.0.4 +PKG_VERSION:=5 PKG_RELEASE:=4 PKG_BUILD_DIR:=$(BUILD_DIR)/fff-sysupgrade @@ -13,7 +13,7 @@ define Package/fff-sysupgrade CATEGORY:=Freifunk TITLE:=Freifunk-Franken sysupgrade URL:=http://www.freifunk-franken.de - DEPENDS:=+fff-boardname +@BUSYBOX_CONFIG_WGET + DEPENDS:=+fff-boardname +fff-hoods +@BUSYBOX_CONFIG_WGET endef define Package/fff-sysupgrade/description diff --git a/src/packages/fff/fff-sysupgrade/files/etc/sysupgrade.sh b/src/packages/fff/fff-sysupgrade/files/etc/sysupgrade.sh index df9d519..8aaa924 100755 --- a/src/packages/fff/fff-sysupgrade/files/etc/sysupgrade.sh +++ b/src/packages/fff/fff-sysupgrade/files/etc/sysupgrade.sh @@ -1,9 +1,16 @@ #!/bin/sh cd /tmp/ +. /lib/functions/fff/keyxchange . /etc/firmware_release -. /etc/community.cfg +UPGRADE_PATH="$(getUpgradePath)" + +if [ -z "$UPGRADE_PATH" ]; then + echo "Upgrade path not set! Aborting." + echo "" + exit 1 +fi BOARD=$(uci get board.model.name) diff --git a/src/packages/fff/fff-timeserver/Makefile b/src/packages/fff/fff-timeserver/Makefile index 4a2decd..d88d646 100644 --- a/src/packages/fff/fff-timeserver/Makefile +++ b/src/packages/fff/fff-timeserver/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fff-timeserver -PKG_VERSION:=0.0.1 +PKG_VERSION:=2 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/fff-timeserver diff --git a/src/packages/fff/fff-timeserver/files/etc/uci-defaults/51-fff-timeserver b/src/packages/fff/fff-timeserver/files/etc/uci-defaults/51-fff-timeserver old mode 100755 new mode 100644 index aa485ab..fe5979d --- a/src/packages/fff/fff-timeserver/files/etc/uci-defaults/51-fff-timeserver +++ b/src/packages/fff/fff-timeserver/files/etc/uci-defaults/51-fff-timeserver @@ -1,9 +1,8 @@ #!/bin/sh . /lib/functions/fff/timeserver -. /etc/community.cfg -setTimeserver "${NTPD_IP}" +# No initialization here, this is done in configurehood uci -q set "system.@system[0].timezone=CET-1CEST,M3.5.0,M10.5.0/3"