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

gluon-core: convert generated upgrade scripts to Lua

parent d31ea9eb
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-core
PKG_VERSION:=2
PKG_RELEASE:=1
PKG_RELEASE:=$(GLUON_VERSION)
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
......@@ -12,7 +12,7 @@ define Package/gluon-core
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Base files of Gluon
DEPENDS:=+gluon-config +odhcp6c
DEPENDS:=+gluon-config +luci-lib-core +odhcp6c
endef
define Package/gluon-core/description
......@@ -31,7 +31,6 @@ endef
define Package/gluon-core/install
$(CP) ./files/* $(1)/
$(GLUON_GENERATE) ./generate/* $(1)/
$(INSTALL_DIR) $(1)/lib/gluon
echo "$(GLUON_VERSION)" > $(1)/lib/gluon/gluon-version
......
#!/usr/bin/lua
local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig'
local uci = require 'luci.model.uci'
local c = uci.cursor()
local system = c:get_first('system', 'system')
c:set('system', system, 'hostname', site.hostname_prefix .. '-' .. string.gsub(sysconfig.primary_mac, ':', ''))
c:set('system', system, 'timezone', site.timezone)
c:save('system')
c:commit('system')
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require 'luci.model.uci'
if not site.ntp_servers or #site.ntp_servers == 0 then
os.exit(0)
end
local c = uci.cursor()
c:delete('system', 'ntp', 'server')
c:set_list('system', 'ntp', 'server', site.ntp_servers)
c:save('system')
c:commit('system')
local sysconfigdir = '/lib/gluon/core/sysconfig/'
local function get(_, name)
local ret = nil
local f = io.open(sysconfigdir .. name)
if f then
ret = f:read('*line')
f:close()
end
return ret
end
local function set(_, name, val)
local ret = nil
local f = io.open(sysconfigdir .. name, 'w+')
f:write(val)
f:close()
end
local sysconfig = {}
local mt = {
__index = get,
__newindex = set,
}
setmetatable(sysconfig, mt)
return sysconfig
#!/bin/sh
. /lib/functions.sh
. /lib/gluon/functions/sysconfig.sh
macaddr=$(sysconfig primary_mac)
uci_set system '@system[0]' hostname "@hostname_prefix@-${macaddr//:/}"
uci_set system '@system[0]' timezone '@timezone@'
uci_commit system
#!/bin/sh
[ -n "$(echo @ntp_servers@)" ] || exit 0
uci delete system.ntp.server
for server in @ntp_servers@; do
uci add_list system.ntp.server="$server"
done
uci commit system
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment