Skip to content
Snippets Groups Projects
Commit 5fa97f8f authored by Nils Schneider's avatar Nils Schneider
Browse files

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

parent d87cf05c
No related branches found
No related tags found
No related merge requests found
return require('gluon.sysconfig').primary_mac:gsub(':', '') return require('gluon.util').node_id()
return require('gluon.sysconfig').primary_mac:gsub(':', '') return require('gluon.util').node_id()
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig' local util = require 'gluon.util'
local uci = require 'luci.model.uci' local uci = require 'luci.model.uci'
local c = uci.cursor() local c = uci.cursor()
local system = c:get_first('system', 'system') 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:set('system', system, 'timezone', site.timezone)
c:save('system') c:save('system')
......
...@@ -25,6 +25,7 @@ end ...@@ -25,6 +25,7 @@ end
local os = os local os = os
local string = string local string = string
local require = require
module 'gluon.util' module 'gluon.util'
...@@ -50,3 +51,8 @@ end ...@@ -50,3 +51,8 @@ end
function unlock(file) function unlock(file)
exec('lock', '-u', file) exec('lock', '-u', file)
end end
function node_id()
local sysconfig = require 'gluon.sysconfig'
return string.gsub(sysconfig.primary_mac, ':', '')
end
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