forked from libremesh/lime-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5f59c2
commit 288f202
Showing
5 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Copyright (C) 2023 Javier Jorge <[email protected]> | ||
# Copyright (C) 2023 Asociación Civil Altermundi <[email protected]> | ||
# This is free software, licensed under the GNU Affero General Public License v3. | ||
# | ||
|
||
include ../../libremesh.mk | ||
|
||
define Package/$(PKG_NAME) | ||
SECTION:=lime | ||
CATEGORY:=LibreMesh | ||
TITLE:=Mesh wide upgrade module for shared-state | ||
MAINTAINER:= Javier <[email protected]> | ||
DEPENDS:=+lua +luci-lib-jsonc +ubus-lime-utils \ | ||
+lime-system +ubus-lime-location shared-state | ||
PKGARCH:=all | ||
endef | ||
|
||
define Package/$(PKG_NAME)/description | ||
Syncronize node information to achieve mesh wide firmware upgrades | ||
endef | ||
|
||
$(eval $(call BuildPackage,$(PKG_NAME))) |
25 changes: 25 additions & 0 deletions
25
...ared-state-mesh_wide_upgrade/files/etc/shared-state/hooks/mesh_wide_upgrade/report_status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/lua | ||
|
||
--! LibreMesh | ||
--! Copyright (C) 2019 Gioacchino Mazzurco <[email protected]> | ||
--! | ||
--! This program is free software: you can redistribute it and/or modify | ||
--! it under the terms of the GNU Affero General Public License as | ||
--! published by the Free Software Foundation, either version 3 of the | ||
--! License, or (at your option) any later version. | ||
--! | ||
--! This program is distributed in the hope that it will be useful, | ||
--! but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
--! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
--! GNU Affero General Public License for more details. | ||
--! | ||
--! You should have received a copy of the GNU Affero General Public License | ||
--! along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
local JSON = require("luci.jsonc") | ||
local utils = require "lime.utils" | ||
|
||
for key,value in pairs(JSON.parse(io.stdin:read("*all")) ) do | ||
utils.log("hoock +++++ ",value.data, key) | ||
end | ||
|
1 change: 1 addition & 0 deletions
1
...esh_wide_upgrade/files/etc/shared-state/publishers/shared-state-publish_mesh_wide_upgrade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../usr/bin/shared-state-publish_mesh_wide_upgrade |
9 changes: 9 additions & 0 deletions
9
...shared-state-mesh_wide_upgrade/files/etc/uci-defaults/shared-state_mesh_wide_upgrade_cron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
unique_append() | ||
{ | ||
grep -qF "$1" "$2" || echo "$1" >> "$2" | ||
} | ||
|
||
unique_append \ | ||
'*/5 * * * * ((sleep $(($RANDOM % 120)); shared-state sync mesh_wide_upgrade &> /dev/null)&)'\ | ||
/etc/crontabs/root |
38 changes: 38 additions & 0 deletions
38
packages/shared-state-mesh_wide_upgrade/files/usr/bin/shared-state-publish_mesh_wide_upgrade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/lua | ||
|
||
--! LibreMesh | ||
--! Copyright (C) 2023 Javier Jorge <[email protected]> | ||
--! Copyright (C) 2023 Asociación Civil Altermundi <[email protected]> | ||
--! | ||
--! This program is free software: you can redistribute it and/or modify | ||
--! it under the terms of the GNU Affero General Public License as | ||
--! published by the Free Software Foundation, either version 3 of the | ||
--! License, or (at your option) any later version. | ||
--! | ||
--! This program is distributed in the hope that it will be useful, | ||
--! but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
--! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
--! GNU Affero General Public License for more details. | ||
--! | ||
--! You should have received a copy of the GNU Affero General Public License | ||
--! along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
local JSON = require("luci.jsonc") | ||
local network = require ("lime.network") | ||
local location = require("lime.location") | ||
local utils = require('lime.utils') | ||
local config = require("lime.config") | ||
|
||
local hostname = utils.hostname() | ||
function get_node_info() | ||
return { | ||
transaction_hash= "", | ||
state= "downloading", | ||
error= 0, | ||
safe_upgrade_status= "", | ||
eup_STATUS= "" | ||
} | ||
end | ||
|
||
local result = { [hostname] = get_node_info() } | ||
io.popen("shared-state insert mesh_wide_upgrade", "w"):write(JSON.stringify(result)) |