Skip to content
Snippets Groups Projects
Commit 216c9ce3 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

Merge gluon packages

The gluon packages will be maintained in the gluon main repository in the
future.
parents 750d9587 c4f7a526
No related branches found
No related tags found
No related merge requests found
Showing
with 163 additions and 0 deletions
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-alfred
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/gluon-alfred
SECTION:=gluon
CATEGORY:=Gluon
DEPENDS:=+gluon-core +gluon-announce +gluon-cron +alfred
TITLE:=Configure alfred
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/gluon-alfred/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,gluon-alfred))
* * * * * /lib/gluon/announce/collect.lua nodeinfo | gzip | alfred -s 158; /lib/gluon/announce/collect.lua statistics | gzip | alfred -s 159; /lib/gluon/announce/collect.lua neighbours | gzip | alfred -s 160
#!/usr/bin/lua
local uci = require 'luci.model.uci'
local c = uci.cursor()
c:delete('alfred', 'alfred')
c:section('alfred', 'alfred', 'alfred',
{
interface = 'br-client',
mode = 'slave',
batmanif = 'bat0',
start_vis = '1',
run_facters = '0',
}
)
c:save('alfred')
c:commit('alfred')
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-announce
PKG_VERSION:=1
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/gluon-announce
SECTION:=gluon
CATEGORY:=Gluon
DEPENDS:=+gluon-core +luci-lib-json +lua-ethtool-stats
TITLE:=Lua scripts announcing various information
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/gluon-announce/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,gluon-announce))
#!/usr/bin/lua
local announce = require 'gluon.announce'
local json = require 'luci.json'
local ltn12 = require 'luci.ltn12'
local announce_dir = '/lib/gluon/announce/' .. arg[1] .. '.d'
encoder = json.Encoder(announce.collect_dir(announce_dir))
ltn12.pump.all(encoder:source(), ltn12.sink.file(io.stdout))
return require('gluon.util').node_id()
return require('platform_info').get_model()
return uci:get_first('system', 'system', 'hostname')
return require('gluon.sysconfig').primary_mac
return require('gluon.util').node_id()
return {
base = 'gluon-' .. util.trim(fs.readfile('/lib/gluon/gluon-version')),
release = util.trim(fs.readfile('/lib/gluon/release')),
}
local site = require 'gluon.site_config'
return site.site_code
return tonumber(fs.readfile('/proc/uptime'):match('^[^ ]+ ([^ ]+)'))
return tonumber(fs.readfile('/proc/loadavg'):match('^([^ ]+) '))
local data = fs.readfile('/proc/meminfo')
local fields = {}
for k, v in data:gmatch('([^\n:]+):%s*(%d+) kB') do
fields[k] = tonumber(v)
end
return {
total = fields.MemTotal,
free = fields.MemFree,
buffers = fields.Buffers,
cached = fields.Cached,
}
return require('gluon.util').node_id()
local running, total = fs.readfile('/proc/loadavg'):match('^[^ ]+ [^ ]+ [^ ]+ (%d+)/(%d+)')
return { running = tonumber(running), total = tonumber(total) }
local fs = require "nixio.fs"
local st = fs.statvfs("/")
return 1 - st.bfree / st.blocks
return tonumber(fs.readfile('/proc/uptime'):match('^([^ ]+) '))
#!/usr/bin/lua
module('gluon.announce', package.seeall)
fs = require 'luci.fs'
uci = require('luci.model.uci').cursor()
util = require 'luci.util'
local function collect_entry(entry)
if fs.isdirectory(entry) then
return collect_dir(entry)
else
return setfenv(loadfile(entry), _M)()
end
end
function collect_dir(dir)
local ret = {}
for _, entry in ipairs(fs.dir(dir)) do
if entry:sub(1, 1) ~= '.' then
local ok, val = pcall(collect_entry, dir .. '/' .. entry)
if ok then
ret[entry] = val
else
io.stderr:write(val, '\n')
end
end
end
return ret
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment