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
2495b39
commit 991fa73
Showing
7 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/shared-state-node_info/files/etc/shared-state/ref_state/node_info_ref
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 @@ | ||
{} |
1 change: 1 addition & 0 deletions
1
packages/shared-state-ref_sate_commons/files/usr/bin/shared-state-update_refstate
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/usr/bin/lua | ||
|
||
--! LibreMesh | ||
--! Generic hook to be called as a symbolic link for each ref type | ||
--! Copyright (C) 2024 Javier Jorge | ||
--! Copyright (C) 2024 Asociación Civil Altermundi <[email protected]> | ||
--! SPDX-License-Identifier: AGPL-3.0-only | ||
|
46 changes: 46 additions & 0 deletions
46
...e-ref_sate_commons/files/usr/share/shared-state/publishers/shared-state-publish_node_info
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,46 @@ | ||
#!/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() | ||
local uci = config.get_uci_cursor() | ||
local coords = location.get_node() or location.get_community() or | ||
{lat="FIXME", long="FIXME"} | ||
local fw_version = "no version" | ||
pcall(function () fw_version = utils.release_info()['DISTRIB_RELEASE'] end) | ||
local board = "no board" | ||
pcall(function () board = utils.current_board() end) | ||
local ipv4 = uci:get("network", "lan", "ipaddr") | ||
local ipv6 = uci:get("network", "lan", "ip6addr") | ||
if ipv6 then ipv6 = ipv6:gsub("/.*$", "") end | ||
local uptime = utils.uptime_s() | ||
local macs = network.get_own_macs("*") | ||
return {hostname=hostname, firmware_version=fw_version, board=board, | ||
ipv4=ipv4, ipv6=ipv6,coordinates=coords,macs= macs,uptime = uptime, | ||
device = "Router" } | ||
end | ||
|
||
local result = { [hostname] = get_node_info() } | ||
io.popen("shared-state-async insert node_info", "w"):write(JSON.stringify(result)) |
19 changes: 19 additions & 0 deletions
19
...te-ref_sate_commons/files/usr/share/shared-state/publishers/shared-state-publish_refstate
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,19 @@ | ||
#!/usr/bin/lua | ||
|
||
--! LibreMesh | ||
--! Copyright (C) 2024 Javier Jorge | ||
--! Copyright (C) 2024 Asociación Civil Altermundi <[email protected]> | ||
--! SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
local JSON = require("luci.jsonc") | ||
local utils = require "lime.utils" | ||
local fs = require("nixio.fs") | ||
|
||
|
||
local ref_file_folder = "/etc/shared-state/ref_state/" | ||
--get data_type from publisher | ||
for data_type in fs.dir(ref_file_folder) do | ||
local path = ref_file_folder .. data_type | ||
local result = { [utils.hostname()] = utils.read_file(path .. data_type) } | ||
io.popen("shared-state-async insert " .. data_type, "w"):write(JSON.stringify(result)) | ||
end |
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
1 change: 1 addition & 0 deletions
1
packages/shared-state-wifi_links_info/files/etc/shared-state/ref_state/wifi_links_info_ref
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 @@ | ||
{} |
1 change: 1 addition & 0 deletions
1
..._info/files/usr/share/shared-state/hooks/wifi_links_info_ref/shared-state-update_refstate
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-update_refstate |