Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #24 #25

Merged
merged 2 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libremap-agent/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=libremap-agent
PKG_RELEASE:=0.1.8
PKG_RELEASE:=0.1.8.1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk
Expand Down Expand Up @@ -75,6 +75,7 @@ $(eval $(call BuildPlugin,system,system,))
$(eval $(call BuildPlugin,wireless,wireless,))
$(eval $(call BuildPlugin,babel,babel,))
$(eval $(call BuildPlugin,bmx6,bmx6,))
$(eval $(call BuildPlugin,qmp,qmp,))

define Package/libremap-agent
SECTION:=utilities
Expand Down
3 changes: 3 additions & 0 deletions libremap-agent/files/etc/uci-defaults/80_libremap-agent
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ config plugin 'babel'

config plugin 'bmx6'
option enabled '0'

config plugin 'qmp'
option enabled '0'
EOF
}

Expand Down
29 changes: 29 additions & 0 deletions libremap-agent/luasrc/libremap/plugins/qmp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--[[

Copyright 2017 Roger Pueyo Centelles <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

]]--

local uci = (require 'uci').cursor()

function insert(doc, options)
-- get values from qMp config
local community_name = tostring(uci:get('qmp', 'node', 'community_name'))
local mesh_name = tostring(uci:get('qmp', 'node', 'mesh_name'))
local device_id = tostring(uci:get('qmp', 'node', 'device_id'))

-- store in doc
doc.community_name = community_name
doc.mesh_name = mesh_name
doc.device_id = device_id
end

return {
insert = insert
}
17 changes: 10 additions & 7 deletions libremap-agent/luasrc/libremap/plugins/system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ http://www.apache.org/licenses/LICENSE-2.0

]]--

sys = require 'luci.sys'
sys = require 'luci.sys'
util = require 'luci.util'

return {
insert = function(doc, options)
local name, model, memtotal = sys.sysinfo()
local system = {
name = name:match('[^\n]+'),
model = model:match('[^\n]+'),
memtotal = memtotal
}
local sysinfo = util.ubus("system", "info") or { }
local sysboard = util.ubus("system", "board") or { }

local system = { }
system["name"] = sysinfo["hostname"]
system["model"] = sysboard["system"]
system["memtotal"] = sysinfo["memory"]["total"]

doc.attributes = doc.attributes or {}
doc.attributes.system = system
end
Expand Down