From 5fa97f8fdb24bd582d60ee5412c4109d8aa10dd5 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Thu, 11 Sep 2014 12:10:55 +0200 Subject: [PATCH] gluon-core: add node_id() to gluon.util --- .../files/lib/gluon/announce/nodeinfo.d/node_id | 2 +- .../files/lib/gluon/announce/statistics.d/node_id | 2 +- .../files/lib/gluon/upgrade/core/initial/010-gluon-system | 4 ++-- package/gluon-core/files/usr/lib/lua/gluon/util.lua | 6 ++++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package/gluon-announce/files/lib/gluon/announce/nodeinfo.d/node_id b/package/gluon-announce/files/lib/gluon/announce/nodeinfo.d/node_id index 7ff75b2d..66303f4c 100644 --- a/package/gluon-announce/files/lib/gluon/announce/nodeinfo.d/node_id +++ b/package/gluon-announce/files/lib/gluon/announce/nodeinfo.d/node_id @@ -1 +1 @@ -return require('gluon.sysconfig').primary_mac:gsub(':', '') +return require('gluon.util').node_id() diff --git a/package/gluon-announce/files/lib/gluon/announce/statistics.d/node_id b/package/gluon-announce/files/lib/gluon/announce/statistics.d/node_id index 7ff75b2d..66303f4c 100644 --- a/package/gluon-announce/files/lib/gluon/announce/statistics.d/node_id +++ b/package/gluon-announce/files/lib/gluon/announce/statistics.d/node_id @@ -1 +1 @@ -return require('gluon.sysconfig').primary_mac:gsub(':', '') +return require('gluon.util').node_id() diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/010-gluon-system b/package/gluon-core/files/lib/gluon/upgrade/core/initial/010-gluon-system index 27b052c4..bf5d7816 100755 --- a/package/gluon-core/files/lib/gluon/upgrade/core/initial/010-gluon-system +++ b/package/gluon-core/files/lib/gluon/upgrade/core/initial/010-gluon-system @@ -1,13 +1,13 @@ #!/usr/bin/lua local site = require 'gluon.site_config' -local sysconfig = require 'gluon.sysconfig' +local util = require 'gluon.util' 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, 'hostname', site.hostname_prefix .. '-' .. util.node_id()) c:set('system', system, 'timezone', site.timezone) c:save('system') diff --git a/package/gluon-core/files/usr/lib/lua/gluon/util.lua b/package/gluon-core/files/usr/lib/lua/gluon/util.lua index 8bfc8cdf..4c067736 100644 --- a/package/gluon-core/files/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/files/usr/lib/lua/gluon/util.lua @@ -25,6 +25,7 @@ end local os = os local string = string +local require = require module 'gluon.util' @@ -50,3 +51,8 @@ end function unlock(file) exec('lock', '-u', file) end + +function node_id() + local sysconfig = require 'gluon.sysconfig' + return string.gsub(sysconfig.primary_mac, ':', '') +end