gluon-core: add node_id() to gluon.util

This commit is contained in:
Nils Schneider 2014-09-11 12:10:55 +02:00
parent d87cf05c95
commit 5fa97f8fdb
4 changed files with 10 additions and 4 deletions

View File

@ -1 +1 @@
return require('gluon.sysconfig').primary_mac:gsub(':', '')
return require('gluon.util').node_id()

View File

@ -1 +1 @@
return require('gluon.sysconfig').primary_mac:gsub(':', '')
return require('gluon.util').node_id()

View File

@ -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')

View File

@ -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