Skip to content

Commit

Permalink
Merge branch 'libremesh:master' into feature/mesh-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
javierbrk committed Aug 27, 2024
2 parents ba6e26c + a3d751c commit d4332af
Show file tree
Hide file tree
Showing 50 changed files with 89 additions and 50 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Start an ImageBuilder of your choice, for example ath79-generic if your device i

```shell
mkdir ./images/
docker run -it -v $(pwd)/images:/images/ ghcr.io/openwrt/imagebuilder:ath79-generic-v22.03.5
docker run -it -v $(pwd)/images:/images/ ghcr.io/openwrt/imagebuilder:ath79-generic-v23.05.3
```

If your device is not part of ath79-generic profiles, you can replace it with another <target>-<subtarget> combination. For knowing which target and subtarget is best suited for your router, check out the page about it in the [OpenWrt's Table of Hardware][OpenWrt-ToH].
Expand All @@ -65,6 +65,7 @@ Within the container, add the `lime-packages` feeds:

```shell
echo "src/gz libremesh https://feed.libremesh.org/master" >> repositories.conf
echo "src/gz libremesh_profiles https://feed.libremesh.org/profiles" >> repositories.conf
echo "src/gz libremesh_arch_packages https://feed.libremesh.org/arch_packages/master/mips_24kc" >> repositories.conf
echo "untrusted comment: signed by libremesh.org key a71b3c8285abd28b" > keys/a71b3c8285abd28b
echo "RWSnGzyChavSiyQ+vLk3x7F0NqcLa4kKyXCdriThMhO78ldHgxGljM/8" >> keys/a71b3c8285abd28b
Expand Down Expand Up @@ -95,6 +96,7 @@ Go to <https://firmware-selector.openwrt.org/>. Find your device. Click on the f

```shell
echo "src/gz libremesh https://feed.libremesh.org/master" >> repositories.conf
echo "src/gz libremesh_profiles https://feed.libremesh.org/profiles" >> repositories.conf
echo "src/gz libremesh_arch_packages https://feed.libremesh.org/arch_packages/master/mips_24kc" >> repositories.conf
echo "untrusted comment: signed by libremesh.org key a71b3c8285abd28b" > keys/a71b3c8285abd28b
echo "RWSnGzyChavSiyQ+vLk3x7F0NqcLa4kKyXCdriThMhO78ldHgxGljM/8" >> keys/a71b3c8285abd28b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bw_test() {
while [ -z "$bw" -a $try -lt $TRIES ]; do
test=$({ wget -T5 -q $1 -O- | pv -n -b -t >/dev/null; } 2>&1)
bw=$(echo $test | awk '{printf "%.0f",$NF/$(NF-1)*8}')
try=$(($try+1))
try=$((try+1))
done
echo $bw
}
Expand Down
2 changes: 1 addition & 1 deletion packages/check-date-http/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Gioacchino Mazzurco <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+libuci-lua +lua +random-numgen \
DEPENDS:=+libuci-lua +lua \
+luci-lib-httpclient
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/20 * * * * ((sleep $(($(random-numgen) % 600)); check-date-http &> /dev/null)&)'\
'*/20 * * * * ((sleep $((RANDOM % 600)); check-date-http &> /dev/null)&)'\
/etc/crontabs/root
2 changes: 1 addition & 1 deletion packages/eupgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define Package/$(PKG_NAME)
CATEGORY:=Utilities
TITLE:=$(PKG_NAME) provides semi automated firmware upgrades
MAINTAINER:=Santiago Piccinini <[email protected]>
DEPENDS:=+lua +lime-system +luci-lib-jsonc +luci-lib-nixio +libubus-lua +libuci-lua +random-numgen
DEPENDS:=+lua +lime-system +luci-lib-jsonc +luci-lib-nixio +libubus-lua +libuci-lua
PKGARCH:=all
endef

Expand Down
2 changes: 1 addition & 1 deletion packages/eupgrade/files/etc/uci-defaults/99-eupgrades-cron
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'0 */6 * * * ((sleep $(($(random-numgen) % 120)); eupgrade-check &> /dev/null)&)'\
'0 */6 * * * ((sleep $((RANDOM % 120)); eupgrade-check &> /dev/null)&)'\
/etc/crontabs/root
2 changes: 1 addition & 1 deletion packages/hotplug-initd-services/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Gioacchino Mazzurco <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+libubox-lua +libubus-lua +random-numgen \
DEPENDS:=+libubox-lua +libubus-lua \
+lua +luci-lib-nixio
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state-multiwriter sync reference_state_nodes_info &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state-multiwriter sync reference_state_nodes_info &> /dev/null)&)'\
/etc/crontabs/root
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state-multiwriter sync reference_state_wifi_links_info &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state-multiwriter sync reference_state_wifi_links_info &> /dev/null)&)'\
/etc/crontabs/root
4 changes: 2 additions & 2 deletions packages/lime-docs/files/www/docs/lime-example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ config net wirelessclientbackbone
# list protocols 'wan' # Some of these protocols require the relative package "lime-proto-..."
# list protocols 'static' # Set up a static IP (both IPv4 and IPv6 supported)
# option static_ipv4 '192.168.1.2/24'
# option static_gateway_ipv4 '192.168.1.1'
# option static_gateway_ipv4 '192.168.1.1' # in static protocol, specifying an IP for the gateway is optional. Skip this line if no default route should be added on this interface.
# option static_ipv6 '2a00:1508:0a00::1234/64'
# option static_gateway_ipv6 'fe80::1'
# option static_gateway_ipv6 'fe80::1' # in static protocol, specifying an IP for the gateway is optional. Skip this line if no default route should be added on this interface.

## (optional) configure lan1 for connection to other nodes, not for users connection:
config net
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-state-async/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ PKG_VERSION=$(GIT_COMMIT_DATE)-$(GIT_COMMIT_TSTAMP)

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/libremesh/shared-state-async.git
PKG_SOURCE_VERSION:=575a4774a5fa38e6d5549e08e217f6299dc16742
PKG_SOURCE_VERSION:=db58e3d16e8658417956f9bb42e7e87f6aadcd4d
PKG_MAINTAINER:=Asociación Civil Altermundi <[email protected]>
PKG_LICENSE:=AGPL-3.0

Expand Down
21 changes: 21 additions & 0 deletions packages/shared-state-async/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,24 @@ https://openwrt.org/docs/guide-developer/gdb
VoCore2: Develop for OpenWrt on Qt Creator
https://vonger.cn/?p=14657

=== Plugin related notes
Plugins must be registered into shared-state-async by using the config file. UCI infrastructure is preferred

[source,console]
--------------------------------------------------------------------------------
mSc="plugin_name"
uci set shared-state.${mSc}=dataType
uci set shared-state.${mSc}.name='plugin-name'
uci set shared-state.${mSc}.scope='community'
uci set shared-state.${mSc}.ttl='1200'
uci set shared-state.${mSc}.update_interval='120'
uci commit shared-state
--------------------------------------------------------------------------------

Publishers must be located at +/usr/share/shared-state/publishers+
All Publishers will be called at least once using shared-state-async-publish-all

Sync is called automatically by shared-state-async according to "update_interval" parameter
"ttl" stands for "time to live" and will decrease until 0.
Data contents will be erased if "ttl" reaches 0.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ start_service()
procd_set_param stderr 1
procd_set_param term_timeout 10
procd_close_instance

#wait 10 secconds in detached mode and call publishres
((sleep 10; shared-state-async-publish-all)&)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ uci set shared-state.${mSc}.update_interval='120'
uci commit shared-state

unique_append \
'*/3 * * * * ((sleep $(($RANDOM % 120)); shared-state-async insert net-stats < /tmp/shared-state/network_statistics.json &> /dev/null)&)' \
'*/3 * * * * ((sleep $((RANDOM % 120)); shared-state-async insert net-stats < /tmp/shared-state/network_statistics.json &> /dev/null)&)' \
/etc/crontabs/root
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

unique_append()
{
grep -qF "$1" "$2" || echo "$1" >> "$2"
}

unique_append \
'*/30 * * * * ((sleep $((RANDOM % 120)); shared-state-async-publish-all &> /dev/null)&)' \
/etc/crontabs/root
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

for publisher in /usr/share/shared-state/publishers/* ; do
[ -x "$publisher" ] && "$publisher";
done
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sinc_args=""

case "$1" in
list)
echo '{ "sync": { "data_type": "str", "peers_ip": "str" }, "get": { "data_type": "str" } }'
echo '{ "sync": { "data_type": "str", "peers_ip": "str" }, "get": { "data_type": "str" }, "publish": { "data_type": "str" }, "publish_all": { } }'
;;
call)
# source jshn shell library
Expand All @@ -33,6 +33,14 @@ case "$1" in
shared-state-async sync $data_type ${peers_ip//,/ } > /dev/null 2>&1
echo {\"data\": {} , \"error\": $? }
;;
publish)
/usr/share/shared-state/publishers/shared-state-publish_$data_type > /dev/null 2>&1
echo {\"data\": {} , \"error\": $? }
;;
publish_all)
shared-state-async-publish-all > /dev/null 2>&1
echo {\"data\": {} , \"error\": $? }
;;
*)
echo '{\"data\" {} ,\"error\" = "Method not found"}'
;;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-state-babel_links_info/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define Package/$(PKG_NAME)
TITLE:=Babel links module for shared-state
MAINTAINER:=Asociación Civil Altermundi <[email protected]>
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \
+libubus-lua +random-numgen shared-state-async
+libubus-lua shared-state-async
PKGARCH:=all
endef

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ uci set shared-state.babel_links_info.ttl='2400'
uci set shared-state.babel_links_info.update_interval='30'
uci commit shared-state

unique_append \
'*/30 * * * * ((sleep $(($RANDOM % 120)); shared-state-publish_babel_links_info &> /dev/null)&)' \
/etc/crontabs/root
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Tests network_nodes #network_nodes', function()
end)

it('a simple test to get babel info and assert requiered fields are present', function()
package.path = package.path .. ";packages/shared-state-babel_links_info/files/usr/bin/?;;"
package.path = package.path .. ";packages/shared-state-babel_links_info/files/usr/share/shared-state/publishers/?;;"
require("shared-state-publish_babel_links_info")

babelinfo = get_babel_links_info()
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-state-babeld_hosts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Gioacchino Mazzurco <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+hotplug-initd-services +random-numgen \
DEPENDS:=+hotplug-initd-services \
+lua +luci-lib-jsonc shared-state
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($(random-numgen) % 120)); shared-state sync babeld-hosts &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state sync babeld-hosts &> /dev/null)&)'\
/etc/crontabs/root
2 changes: 1 addition & 1 deletion packages/shared-state-bat_hosts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define Package/$(PKG_NAME)
MAINTAINER:=Asociación Civil Altermundi <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+libubus-lua +lime-system +lua +luci-lib-jsonc +luci-lib-nixio \
shared-state-async
+shared-state-async
PKGARCH:=all
endef

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
[ "x$ACTION" == "xifup" ] && ((sleep 30; shared-state-publish_bat_hosts; shared-state-async sync bat-hosts)&)
[ "x$ACTION" == "xifup" ] && ((sleep 30; /usr/share/shared-state/publishers/shared-state-publish_bat_hosts)&)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ uci set shared-state.bat_hosts.ttl='2400'
uci set shared-state.bat_hosts.update_interval='30'
uci commit shared-state

unique_append \
'*/30 * * * * ((sleep $(($RANDOM % 120)); shared-state-publish_bat_hosts &> /dev/null)&)' \
/etc/crontabs/root
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
[ "x$ACTION" == "xifup" ] && ((sleep 30; /usr/share/shared-state/publishers/shared-state-publish_bat_links)&)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ uci set shared-state.bat_links_info.scope='community'
uci set shared-state.bat_links_info.ttl='2400'
uci set shared-state.bat_links_info.update_interval='30'
uci commit shared-state

unique_append \
'*/30 * * * * ((sleep $(($RANDOM % 120)); shared-state-publish_bat_links_info &> /dev/null)&)' \
/etc/crontabs/root
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('Tests bat_links_info #bat_links_info', function ()
return iwinfo.mocks.wlan1_mesh_mac
end)

package.path = package.path .. ";packages/shared-state-bat_links_info/files/usr/bin/?;;"
package.path = package.path .. ";packages/shared-state-bat_links_info/files/usr/share/shared-state/publishers/?;;"
require ("shared-state-publish_bat_links_info")

it('a simple test to get node info and assert requiered fields are present', function()
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-state-dnsmasq_hosts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Gioacchino Mazzurco <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+lua +luci-lib-jsonc +random-numgen \
DEPENDS:=+lua +luci-lib-jsonc \
shared-state
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($(random-numgen) % 120)); shared-state sync dnsmasq-hosts &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state sync dnsmasq-hosts &> /dev/null)&)'\
/etc/crontabs/root
2 changes: 1 addition & 1 deletion packages/shared-state-dnsmasq_leases/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Gioacchino Mazzurco <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+libuci-lua +lua +random-numgen \
DEPENDS:=+libuci-lua +lua \
+luci-lib-jsonc shared-state +shared-state-dnsmasq_hosts \
+luci-lib-nixio
PKGARCH:=all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($(random-numgen) % 120)); shared-state sync dnsmasq-leases &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state sync dnsmasq-leases &> /dev/null)&)'\
/etc/crontabs/root

exit 0
2 changes: 1 addition & 1 deletion packages/shared-state-dnsmasq_servers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Gui iribarren <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+lua +luci-lib-jsonc +random-numgen \
DEPENDS:=+lua +luci-lib-jsonc \
shared-state
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($(random-numgen) % 120)); shared-state sync dnsmasq-servers &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state sync dnsmasq-servers &> /dev/null)&)'\
/etc/crontabs/root
2 changes: 1 addition & 1 deletion packages/shared-state-network_nodes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define Package/$(PKG_NAME)
TITLE:=$(PKG_NAME) provides data-type for network nodes marked as reliable by user
MAINTAINER:=Asociacion Civil Altermundi <[email protected]>
DEPENDS:=+shared-state +shared-state-nodes_and_links +lime-system +luci-lib-jsonc \
+libubus-lua +random-numgen
+libubus-lua
PKGARCH:=all
endef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($(random-numgen) % 120)); shared-state-multiwriter sync network_nodes &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state-multiwriter sync network_nodes &> /dev/null)&)'\
/etc/crontabs/root
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state sync node_info &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state sync node_info &> /dev/null)&)'\
/etc/crontabs/root
2 changes: 1 addition & 1 deletion packages/shared-state-nodes_and_links/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Nicolas Pace <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+lua +luci-lib-jsonc +random-numgen \
DEPENDS:=+lua +luci-lib-jsonc \
shared-state +ubus-lime-location
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($(random-numgen) % 120)); shared-state sync nodes_and_links &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state sync nodes_and_links &> /dev/null)&)'\
/etc/crontabs/root
2 changes: 1 addition & 1 deletion packages/shared-state-pirania/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LibreMesh
MAINTAINER:=Asociación Civil AlterMundi <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+lua +luci-lib-jsonc +random-numgen shared-state
DEPENDS:=+lua +luci-lib-jsonc shared-state
PKGARCH:=all
endef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ unique_append()
}

unique_append \
'*/2 * * * * ((sleep $(($(random-numgen) % 30)); /etc/shared-state/publishers/shared-state-publish_vouchers && shared-state sync pirania-vouchers &> /dev/null)&)'\
'*/2 * * * * ((sleep $((RANDOM % 30)); /etc/shared-state/publishers/shared-state-publish_vouchers && shared-state sync pirania-vouchers &> /dev/null)&)'\
/etc/crontabs/root

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ unique_append()
}

unique_append \
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state sync wifi_links_info &> /dev/null)&)'\
'*/5 * * * * ((sleep $((RANDOM % 120)); shared-state sync wifi_links_info &> /dev/null)&)'\
/etc/crontabs/root
Loading

0 comments on commit d4332af

Please sign in to comment.