"gluon-node-info": add section system and option role; add announce script to announce the role as nodeinfo;
add invariant script "001-node-system" to add section "system" if not exist; add invariant script "010-node-role" to add section "system" if not exist; add invariant script "010-node-role" to set role to default value (site.roles.default) if not exist; depends on new site.conf section
This commit is contained in:
parent
78b43b1dd6
commit
ba81359c60
@ -6,7 +6,7 @@ PKG_RELEASE:=1
|
|||||||
|
|
||||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(GLUONDIR)/include/package.mk
|
||||||
|
|
||||||
define Package/gluon-node-info
|
define Package/gluon-node-info
|
||||||
SECTION:=gluon
|
SECTION:=gluon
|
||||||
@ -33,4 +33,9 @@ define Package/gluon-node-info/install
|
|||||||
$(CP) ./files/* $(1)/
|
$(CP) ./files/* $(1)/
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define Package/gluon-node-info/postinst
|
||||||
|
#!/bin/sh
|
||||||
|
$(call GluonCheckSite,check_site.lua)
|
||||||
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,gluon-node-info))
|
$(eval $(call BuildPackage,gluon-node-info))
|
||||||
|
8
package/gluon-node-info/check_site.lua
Normal file
8
package/gluon-node-info/check_site.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
local function check_role(k, _)
|
||||||
|
local role = string.format('roles.list[%q]', k)
|
||||||
|
|
||||||
|
need_string(role)
|
||||||
|
end
|
||||||
|
|
||||||
|
need_string('roles.default', false)
|
||||||
|
need_table('roles.list', check_role, false)
|
@ -2,3 +2,5 @@ config location
|
|||||||
option share_location '0'
|
option share_location '0'
|
||||||
|
|
||||||
config owner
|
config owner
|
||||||
|
|
||||||
|
config system
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
local role = uci:get_first('gluon-node-info', 'system', 'role', '')
|
||||||
|
if role ~= '' then
|
||||||
|
return role
|
||||||
|
end
|
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
|
||||||
|
local config = 'gluon-node-info'
|
||||||
|
|
||||||
|
if not uci:get_first(config, 'system') then
|
||||||
|
uci:section(config, 'system')
|
||||||
|
uci:save(config)
|
||||||
|
uci:commit(config)
|
||||||
|
end
|
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local site = require 'gluon.site_config'
|
||||||
|
local uci = require('luci.model.uci').cursor()
|
||||||
|
|
||||||
|
local config = 'gluon-node-info'
|
||||||
|
local role = uci:get(config, uci:get_first(config, 'system'), 'role')
|
||||||
|
|
||||||
|
if site.roles then
|
||||||
|
default_role = site.roles.default
|
||||||
|
else
|
||||||
|
default_role = ''
|
||||||
|
end
|
||||||
|
|
||||||
|
if not role then
|
||||||
|
uci:set(config, uci:get_first(config, 'system'), 'role', default_role)
|
||||||
|
uci:save(config)
|
||||||
|
uci:commit(config)
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user