From 052e08e77158e09322ccc9baa155e072e214e30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Tue, 13 Dec 2022 22:56:39 +0100 Subject: [PATCH 1/4] gluon-mesh-olsrd: example site --- contrib/ci/olsr-site/i18n | 1 + contrib/ci/olsr-site/modules | 1 + contrib/ci/olsr-site/site.conf | 176 +++++++++++++++++++++++++++++++++ contrib/ci/olsr-site/site.mk | 57 +++++++++++ 4 files changed, 235 insertions(+) create mode 120000 contrib/ci/olsr-site/i18n create mode 120000 contrib/ci/olsr-site/modules create mode 100644 contrib/ci/olsr-site/site.conf create mode 100644 contrib/ci/olsr-site/site.mk diff --git a/contrib/ci/olsr-site/i18n b/contrib/ci/olsr-site/i18n new file mode 120000 index 00000000..57a3c397 --- /dev/null +++ b/contrib/ci/olsr-site/i18n @@ -0,0 +1 @@ +../minimal-site/i18n \ No newline at end of file diff --git a/contrib/ci/olsr-site/modules b/contrib/ci/olsr-site/modules new file mode 120000 index 00000000..72d21398 --- /dev/null +++ b/contrib/ci/olsr-site/modules @@ -0,0 +1 @@ +../minimal-site/modules \ No newline at end of file diff --git a/contrib/ci/olsr-site/site.conf b/contrib/ci/olsr-site/site.conf new file mode 100644 index 00000000..868d3d56 --- /dev/null +++ b/contrib/ci/olsr-site/site.conf @@ -0,0 +1,176 @@ +-- This is an example site configuration for Gluon v2022.1 +-- +-- Take a look at the documentation located at +-- https://gluon.readthedocs.io/ for details. +-- +-- This configuration will not work as is. You're required to make +-- community specific changes to it! +{ + -- Used for generated hostnames, e.g. freifunk-abcdef123456. (optional) + -- hostname_prefix = 'freifunk-', + + -- Name of the community. + site_name = 'Continuous Integration', + + -- Shorthand of the community. + site_code = 'ci', + + -- 32 bytes of random data, encoded in hexadecimal + -- This data must be unique among all sites and domains! + -- Can be generated using: echo $(hexdump -v -n 32 -e '1/1 "%02x"' >' "$2" +# to decide if a version is newer or not. + +DEFAULT_GLUON_RELEASE := 0.6+exp$(shell date '+%Y%m%d') + +# Variables set with ?= can be overwritten from the command line + +## GLUON_RELEASE +# call make with custom GLUON_RELEASE flag, to use your own release version scheme. +# e.g.: +# $ make images GLUON_RELEASE=23.42+5 +# would generate images named like this: +# gluon-ff%site_code%-23.42+5-%router_model%.bin + +GLUON_RELEASE ?= $(DEFAULT_GLUON_RELEASE) + +# Default priority for updates. +GLUON_PRIORITY ?= 0 + +# Region code required for some images; supported values: us eu +GLUON_REGION ?= eu + +# Languages to include +GLUON_LANGS ?= en de From ad378ce60f850e3ded6ed4706961dcd62643fc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Fri, 30 Dec 2022 10:22:50 +0100 Subject: [PATCH 2/4] gluon-mesh-olsrd: add olsr2 support --- package/gluon-mesh-olsrd/Makefile | 19 ++ package/gluon-mesh-olsrd/check_site.lua | 1 + .../core/mesh/post-setup.d/30-reload-olsr | 10 ++ .../gluon/core/mesh/teardown.d/70-reload-olsr | 10 ++ .../files/lib/gluon/respondd/client.dev | 1 + .../files/usr/lib/autoupdater/abort.d/10olsrd | 7 + .../usr/lib/autoupdater/upgrade.d/10olsrd | 7 + .../upgrade/360-gluon-mesh-olsrd-setup-intf | 163 ++++++++++++++++++ .../upgrade/370-gluon-mesh-olsrd-setup-fw | 10 ++ .../usr/lib/autoupdater/abort.d/10olsrd | 6 + .../usr/lib/autoupdater/upgrade.d/10olsrd | 6 + ...pport-to-check-if-service-is-running.patch | 20 +++ targets/generic | 2 + 13 files changed, 262 insertions(+) create mode 100644 package/gluon-mesh-olsrd/Makefile create mode 100644 package/gluon-mesh-olsrd/check_site.lua create mode 100755 package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr create mode 100755 package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr create mode 100644 package/gluon-mesh-olsrd/files/lib/gluon/respondd/client.dev create mode 100755 package/gluon-mesh-olsrd/files/usr/lib/autoupdater/abort.d/10olsrd create mode 100755 package/gluon-mesh-olsrd/files/usr/lib/autoupdater/upgrade.d/10olsrd create mode 100755 package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/360-gluon-mesh-olsrd-setup-intf create mode 100755 package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/370-gluon-mesh-olsrd-setup-fw create mode 100755 package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd create mode 100755 package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd create mode 100644 patches/packages/routing/0004-oonf-olsrd2-add-support-to-check-if-service-is-running.patch diff --git a/package/gluon-mesh-olsrd/Makefile b/package/gluon-mesh-olsrd/Makefile new file mode 100644 index 00000000..55926ea5 --- /dev/null +++ b/package/gluon-mesh-olsrd/Makefile @@ -0,0 +1,19 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-mesh-olsrd +PKG_VERSION=1 + +include ../gluon.mk + +define Package/gluon-mesh-olsrd + TITLE:=olsrd mesh + DEPENDS:= \ + +gluon-core \ + @IPV6 \ + +oonf-olsrd2 \ + +firewall \ + +gluon-mesh-layer3-common + PROVIDES:=gluon-mesh-provider +endef + +$(eval $(call BuildPackageGluon,gluon-mesh-olsrd)) diff --git a/package/gluon-mesh-olsrd/check_site.lua b/package/gluon-mesh-olsrd/check_site.lua new file mode 100644 index 00000000..3e136790 --- /dev/null +++ b/package/gluon-mesh-olsrd/check_site.lua @@ -0,0 +1 @@ +need_table({'mesh', 'olsrd', 'v2', 'config'}, nil, false) diff --git a/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr new file mode 100755 index 00000000..7f12096c --- /dev/null +++ b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr @@ -0,0 +1,10 @@ +#!/bin/sh + +reload_running() { + if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled && /etc/init.d/"$1" running; then + echo "(post-setup.d:$IFNAME) Reloading $1..." + /etc/init.d/"$1" reload + fi +} + +reload_running olsrd2 diff --git a/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr new file mode 100755 index 00000000..f69bf08d --- /dev/null +++ b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr @@ -0,0 +1,10 @@ +#!/bin/sh + +reload_running() { + if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled && /etc/init.d/"$1" running; then + echo "(teardown.d:$IFNAME) Reloading $1..." + /etc/init.d/"$1" reload + fi +} + +reload_running olsrd2 diff --git a/package/gluon-mesh-olsrd/files/lib/gluon/respondd/client.dev b/package/gluon-mesh-olsrd/files/lib/gluon/respondd/client.dev new file mode 100644 index 00000000..202a2374 --- /dev/null +++ b/package/gluon-mesh-olsrd/files/lib/gluon/respondd/client.dev @@ -0,0 +1 @@ +mmfd diff --git a/package/gluon-mesh-olsrd/files/usr/lib/autoupdater/abort.d/10olsrd b/package/gluon-mesh-olsrd/files/usr/lib/autoupdater/abort.d/10olsrd new file mode 100755 index 00000000..8f39df99 --- /dev/null +++ b/package/gluon-mesh-olsrd/files/usr/lib/autoupdater/abort.d/10olsrd @@ -0,0 +1,7 @@ +#!/bin/sh + +. /lib/gluon/autoupdater/lib.sh + + +start_enabled olsrd2 +wifi up diff --git a/package/gluon-mesh-olsrd/files/usr/lib/autoupdater/upgrade.d/10olsrd b/package/gluon-mesh-olsrd/files/usr/lib/autoupdater/upgrade.d/10olsrd new file mode 100755 index 00000000..c9cd9a8c --- /dev/null +++ b/package/gluon-mesh-olsrd/files/usr/lib/autoupdater/upgrade.d/10olsrd @@ -0,0 +1,7 @@ +#!/bin/sh + +. /lib/gluon/autoupdater/lib.sh + + +stop olsrd2 +wifi down diff --git a/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/360-gluon-mesh-olsrd-setup-intf b/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/360-gluon-mesh-olsrd-setup-intf new file mode 100755 index 00000000..880dc31f --- /dev/null +++ b/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/360-gluon-mesh-olsrd-setup-intf @@ -0,0 +1,163 @@ +#!/usr/bin/lua + +local uci = require('simple-uci').cursor() +local site = require 'gluon.site' +local util = require 'gluon.util' +local wireless = require 'gluon.wireless' +local mesh_interfaces = util.get_role_interfaces(uci, 'mesh') +local uplink_interfaces = util.get_role_interfaces(uci, 'uplink') +local client_interfaces = util.get_role_interfaces(uci, 'client') + +local mesh_interfaces_uplink = {} +local mesh_interfaces_client = {} +local mesh_interfaces_other = {} +for _, iface in ipairs(mesh_interfaces) do + if util.contains(uplink_interfaces, iface) then + table.insert(mesh_interfaces_uplink, iface) + elseif util.contains(client_interfaces, iface) then + table.insert(mesh_interfaces_client, iface) + else + table.insert(mesh_interfaces_other, iface) + end +end + +local intf = { + wired_mesh = {}, + vpn_mesh = {}, + radio_mesh = {}, +} + +intf.all_intfs = {} + +for _, l in ipairs({ intf.wired_mesh, intf.vpn_mesh, intf.radio_mesh }) do + for _, n in ipairs(l) do + table.insert(intf.all_intfs, n) + end +end + +-- get all mesh radios and mesh lans and then add them to olsrd +wireless.foreach_radio(uci, function(radio, _, _) + local radio_name = radio['.name'] + table.insert(intf.radio_mesh, 'mesh_' .. radio_name) +end) + +if pcall(function() require 'gluon.mesh-vpn' end) then + local vpn_core = require 'gluon.mesh-vpn' + + if vpn_core.enabled() then + -- mesh_vpn is a interface that has the right ifname + -- we can't use mesh-vpn (dash instead of underscore) since it's not a uci interface + table.insert(intf.vpn_mesh, 'mesh_vpn') + end +end + +table.insert(intf.wired_mesh, 'loopback') + +local has_uplink_mesh = false +local has_other_mesh = false + +for _,i in pairs(mesh_interfaces) do + if util.contains(uplink_interfaces, i) then + has_uplink_mesh = true + else + has_other_mesh = true + end +end + +if has_uplink_mesh then + table.insert(intf.wired_mesh, 'mesh_uplink') +end + +if has_other_mesh then + table.insert(intf.wired_mesh, 'mesh_other') +end + +uci:delete_all('olsrd2', 'interface') + +if site.mesh.olsrd.v2.enable(true) then + os.execute('/etc/init.d/olsrd2 enable') + + local addrs = { } + local lan = { } + local cfg = site.mesh.olsrd.v2 + local config = uci:get_first("olsrd2", "olsrv2") + + -- set global config + local olsr2Config = { + failfast = 'no', + pidfile = '/var/run/olsrd2.pid', + lockfile = '/var/lock/olsrd2' + } + + local extraConf = cfg.config() + if extraConf then + for k, _ in pairs(extraConf) do + olsr2Config[k] = extraConf[k] + end + end + + uci:delete_all('olsrd2', 'global') + uci:section('olsrd2', 'global', 'global', olsr2Config) + + uci:delete_all('olsrd2', 'telnet') + uci:section('olsrd2', 'telnet', 'telnet', { + + }) + + uci:delete_all('olsrd2', 'http') + uci:section('olsrd2', 'http', 'http', { + + }) + + if cfg.lan() then + lan = cfg.lan() + end + + table.insert(addrs, '-127.0.0.1/8') + table.insert(addrs, '-::1/128') + + table.insert(addrs, 'default_accept') + + uci:set("olsrd2", config, "originator", addrs) + uci:set("olsrd2", config, "lan", lan) + + if #intf.wired_mesh then + uci:section('olsrd2', 'interface', 'wired_mesh', { + ifname = intf.wired_mesh, + bindto = addrs, + }) + end + + if #intf.vpn_mesh then + uci:section('olsrd2', 'interface', 'vpn_mesh', { + ifname = intf.vpn_mesh, + bindto = addrs, + }) + end + + if #intf.radio_mesh then + uci:section('olsrd2', 'interface', 'radio_mesh', { + ifname = intf.radio_mesh, + bindto = addrs, + }) + end + + uci:section('olsrd2', 'interface', 'loopback', { + ifname = { 'loopback' }, + bindto = addrs, + }) + + uci:section('firewall', 'rule', 'allow_olsr2_mesh', { + src = 'mesh', + dest_port = '269', + proto = 'udp', + target = 'ACCEPT', + }) +else + -- site.mesh.olsrd.v2.enable false + os.execute('/etc/init.d/olsrd2 disable') + uci:delete('firewall', 'allow_olsr2_mesh') +end +uci:save('olsrd2') +uci:save('firewall') +uci:save('network') diff --git a/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/370-gluon-mesh-olsrd-setup-fw b/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/370-gluon-mesh-olsrd-setup-fw new file mode 100755 index 00000000..65387e87 --- /dev/null +++ b/package/gluon-mesh-olsrd/luasrc/lib/gluon/upgrade/370-gluon-mesh-olsrd-setup-fw @@ -0,0 +1,10 @@ +#!/usr/bin/lua + +local uci = require('simple-uci').cursor() +local util = require 'gluon.util' + +local networks = uci:get_list('firewall', 'drop', 'network') +util.remove_from_set(networks, 'client') +uci:set_list('firewall', 'drop', 'network', networks) + +uci:save('firewall') diff --git a/package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd b/package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd new file mode 100755 index 00000000..ae0c4f36 --- /dev/null +++ b/package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd @@ -0,0 +1,6 @@ +#!/bin/sh + +. /lib/gluon/autoupdater/lib.sh + + +start_enabled olsrd2 diff --git a/package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd b/package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd new file mode 100755 index 00000000..bbb6b545 --- /dev/null +++ b/package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd @@ -0,0 +1,6 @@ +#!/bin/sh + +. /lib/gluon/autoupdater/lib.sh + + +stop olsrd2 diff --git a/patches/packages/routing/0004-oonf-olsrd2-add-support-to-check-if-service-is-running.patch b/patches/packages/routing/0004-oonf-olsrd2-add-support-to-check-if-service-is-running.patch new file mode 100644 index 00000000..4b8c9aad --- /dev/null +++ b/patches/packages/routing/0004-oonf-olsrd2-add-support-to-check-if-service-is-running.patch @@ -0,0 +1,20 @@ +From: Maciej Krüger +Date: Sun, 10 Apr 2022 01:58:41 +0200 +Subject: oonf-olsrd2: add support to check if service is running + +diff --git a/oonf-olsrd2/files/olsrd2.init b/oonf-olsrd2/files/olsrd2.init +index debae9883258b821a5ea0aecebe879ddc84e29eb..b6c1e9a5522788005db850ceaf6699aa1eee6877 100755 +--- a/oonf-olsrd2/files/olsrd2.init ++++ b/oonf-olsrd2/files/olsrd2.init +@@ -3,4 +3,11 @@ + START=82 + DAEMON='olsrd2' + ++running() { ++ test -e "/tmp/run/olsrd2.pid" && test -e "/proc/$(cat "/tmp/run/olsrd2.pid")" && return 0 ++ return 1 ++} ++ ++extra_command "running" "Check if service is running" ++ + . /lib/functions/oonf_init.sh diff --git a/targets/generic b/targets/generic index c9bce1e0..20111220 100644 --- a/targets/generic +++ b/targets/generic @@ -68,6 +68,8 @@ config('KERNEL_SECCOMP', false) -- use try_config, so enabling the package is still possible try_config('PACKAGE_kmod-mt7915e', false) +try_config('OONF_GENERIC_HTTP', true) + config('COLLECT_KERNEL_DEBUG', true) config('TARGET_MULTI_PROFILE', true) From 5baa8e07f15e9e293ca56ca686fb654a5536d2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Mon, 9 Jan 2023 14:04:06 +0100 Subject: [PATCH 3/4] gluon-mesh-olsrd: editorconfig/whitespace fixup --- package/gluon-mesh-olsrd/Makefile | 6 +++--- .../files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr | 8 ++++---- .../files/lib/gluon/core/mesh/teardown.d/70-reload-olsr | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package/gluon-mesh-olsrd/Makefile b/package/gluon-mesh-olsrd/Makefile index 55926ea5..adf1a07a 100644 --- a/package/gluon-mesh-olsrd/Makefile +++ b/package/gluon-mesh-olsrd/Makefile @@ -6,14 +6,14 @@ PKG_VERSION=1 include ../gluon.mk define Package/gluon-mesh-olsrd - TITLE:=olsrd mesh - DEPENDS:= \ + TITLE:=olsrd mesh + DEPENDS:= \ +gluon-core \ @IPV6 \ +oonf-olsrd2 \ +firewall \ +gluon-mesh-layer3-common - PROVIDES:=gluon-mesh-provider + PROVIDES:=gluon-mesh-provider endef $(eval $(call BuildPackageGluon,gluon-mesh-olsrd)) diff --git a/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr index 7f12096c..e96dcce2 100755 --- a/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr +++ b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/post-setup.d/30-reload-olsr @@ -1,10 +1,10 @@ #!/bin/sh reload_running() { - if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled && /etc/init.d/"$1" running; then - echo "(post-setup.d:$IFNAME) Reloading $1..." - /etc/init.d/"$1" reload - fi + if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled && /etc/init.d/"$1" running; then + echo "(post-setup.d:$IFNAME) Reloading $1..." + /etc/init.d/"$1" reload + fi } reload_running olsrd2 diff --git a/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr index f69bf08d..0eb0e58c 100755 --- a/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr +++ b/package/gluon-mesh-olsrd/files/lib/gluon/core/mesh/teardown.d/70-reload-olsr @@ -1,10 +1,10 @@ #!/bin/sh reload_running() { - if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled && /etc/init.d/"$1" running; then - echo "(teardown.d:$IFNAME) Reloading $1..." - /etc/init.d/"$1" reload - fi + if [ -x /etc/init.d/"$1" ] && /etc/init.d/"$1" enabled && /etc/init.d/"$1" running; then + echo "(teardown.d:$IFNAME) Reloading $1..." + /etc/init.d/"$1" reload + fi } reload_running olsrd2 From 37b88cf7900bfce535c3c75c334619e7abc6144a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Wed, 15 Feb 2023 21:40:31 +0100 Subject: [PATCH 4/4] gluon-mesh-olsrd: remove unused files --- .../gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd | 6 ------ .../gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd | 6 ------ 2 files changed, 12 deletions(-) delete mode 100755 package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd delete mode 100755 package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd diff --git a/package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd b/package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd deleted file mode 100755 index ae0c4f36..00000000 --- a/package/gluon-mesh-olsrd/usr/lib/autoupdater/abort.d/10olsrd +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -. /lib/gluon/autoupdater/lib.sh - - -start_enabled olsrd2 diff --git a/package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd b/package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd deleted file mode 100755 index bbb6b545..00000000 --- a/package/gluon-mesh-olsrd/usr/lib/autoupdater/upgrade.d/10olsrd +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -. /lib/gluon/autoupdater/lib.sh - - -stop olsrd2