nuageinit: Silence luacheck warnings and fix typos
No functional change intended. Reviewed by: bapt, dtxdf, kevans MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53238
This commit is contained in:
@@ -69,7 +69,7 @@ local function errmsg(str, prepend)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function chmod(path, mode)
|
local function chmod(path, mode)
|
||||||
local mode = tonumber(mode, 8)
|
mode = tonumber(mode, 8)
|
||||||
local _, err, msg = sys_stat.chmod(path, mode)
|
local _, err, msg = sys_stat.chmod(path, mode)
|
||||||
if err then
|
if err then
|
||||||
errmsg("chmod(" .. path .. ", " .. mode .. ") failed: " .. msg)
|
errmsg("chmod(" .. path .. ", " .. mode .. ") failed: " .. msg)
|
||||||
@@ -150,8 +150,6 @@ local function splitlines(s)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function getgroups()
|
local function getgroups()
|
||||||
local ret = {}
|
|
||||||
|
|
||||||
local root = os.getenv("NUAGE_FAKE_ROOTDIR")
|
local root = os.getenv("NUAGE_FAKE_ROOTDIR")
|
||||||
local cmd = "pw "
|
local cmd = "pw "
|
||||||
if root then
|
if root then
|
||||||
@@ -579,7 +577,7 @@ local function settimezone(timezone)
|
|||||||
root = "/"
|
root = "/"
|
||||||
end
|
end
|
||||||
|
|
||||||
f, _, rc = os.execute("tzsetup -s -C " .. root .. " " .. timezone)
|
local f, _, rc = os.execute("tzsetup -s -C " .. root .. " " .. timezone)
|
||||||
|
|
||||||
if not f then
|
if not f then
|
||||||
warnmsg("Impossible to configure time zone ( rc = " .. rc .. " )")
|
warnmsg("Impossible to configure time zone ( rc = " .. rc .. " )")
|
||||||
|
|||||||
+11
-13
@@ -229,10 +229,10 @@ local function nameservers(interface, obj)
|
|||||||
|
|
||||||
local resolv_conf = root .. "/etc/resolv.conf"
|
local resolv_conf = root .. "/etc/resolv.conf"
|
||||||
|
|
||||||
resolv_conf_attr = lfs.attributes(resolv_conf)
|
local resolv_conf_attr = lfs.attributes(resolv_conf)
|
||||||
|
|
||||||
if resolv_conf_attr == nil then
|
if resolv_conf_attr == nil then
|
||||||
resolv_conf_handler = open_resolv_conf()
|
local resolv_conf_handler = open_resolv_conf()
|
||||||
resolv_conf_handler:close()
|
resolv_conf_handler:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -295,10 +295,11 @@ local function match_rules(rules)
|
|||||||
-- with the matching interfaces must be returned. This changes the way we initially
|
-- with the matching interfaces must be returned. This changes the way we initially
|
||||||
-- thought about our implementation, since at first we only needed one interface,
|
-- thought about our implementation, since at first we only needed one interface,
|
||||||
-- but cloud-init performs actions on a group of matching interfaces.
|
-- but cloud-init performs actions on a group of matching interfaces.
|
||||||
|
local interface
|
||||||
local interfaces = {}
|
local interfaces = {}
|
||||||
if rules.macaddress then
|
if rules.macaddress then
|
||||||
local ifaces = get_ifaces_by_mac()
|
local ifaces = get_ifaces_by_mac()
|
||||||
local interface = ifaces[rules.macaddress]
|
interface = ifaces[rules.macaddress]
|
||||||
if not interface then
|
if not interface then
|
||||||
nuage.warn("not interface matching by MAC address: " .. rules.macaddress)
|
nuage.warn("not interface matching by MAC address: " .. rules.macaddress)
|
||||||
return
|
return
|
||||||
@@ -348,11 +349,11 @@ local function write_files(files, defer)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function write_files_not_defered(obj)
|
local function write_files_not_deferred(obj)
|
||||||
write_files(obj.write_files, false)
|
write_files(obj.write_files, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function write_files_defered(obj)
|
local function write_files_deferred(obj)
|
||||||
write_files(obj.write_files, true)
|
write_files(obj.write_files, true)
|
||||||
end
|
end
|
||||||
-- Set network configuration from user_data
|
-- Set network configuration from user_data
|
||||||
@@ -381,6 +382,7 @@ local function network_config(obj)
|
|||||||
extra_opts = extra_opts .. " wol"
|
extra_opts = extra_opts .. " wol"
|
||||||
end
|
end
|
||||||
if v.mtu then
|
if v.mtu then
|
||||||
|
local mtu
|
||||||
if type(v.mtu) == "number" then
|
if type(v.mtu) == "number" then
|
||||||
mtu = tostring(v.mtu)
|
mtu = tostring(v.mtu)
|
||||||
else
|
else
|
||||||
@@ -680,14 +682,14 @@ if line == "#cloud-config" then
|
|||||||
network_config,
|
network_config,
|
||||||
ssh_pwauth,
|
ssh_pwauth,
|
||||||
runcmd,
|
runcmd,
|
||||||
write_files_not_defered,
|
write_files_not_deferred,
|
||||||
}
|
}
|
||||||
|
|
||||||
local post_network_calls = {
|
local post_network_calls = {
|
||||||
packages,
|
packages,
|
||||||
users,
|
users,
|
||||||
chpasswd,
|
chpasswd,
|
||||||
write_files_defered,
|
write_files_deferred,
|
||||||
}
|
}
|
||||||
|
|
||||||
f = io.open(ni_path .. "/" .. ud)
|
f = io.open(ni_path .. "/" .. ud)
|
||||||
@@ -704,12 +706,8 @@ if line == "#cloud-config" then
|
|||||||
|
|
||||||
for i = 1, #calls_table do
|
for i = 1, #calls_table do
|
||||||
if citype == "nocloud" and calls_table[i] == network_config then
|
if citype == "nocloud" and calls_table[i] == network_config then
|
||||||
netobj = parse_network_config()
|
local netobj = parse_network_config() or obj
|
||||||
if netobj == nil then
|
network_config(netobj)
|
||||||
network_config(obj)
|
|
||||||
else
|
|
||||||
network_config(netobj)
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
calls_table[i](obj)
|
calls_table[i](obj)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ if str ~= f.content then
|
|||||||
n.err("Invalid file content")
|
n.err("Invalid file content")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- the file is overwriten
|
-- the file is overwritten
|
||||||
f.content = "test"
|
f.content = "test"
|
||||||
|
|
||||||
str = addfile_and_getres(f)
|
str = addfile_and_getres(f)
|
||||||
|
|||||||
@@ -890,7 +890,7 @@ EOF
|
|||||||
atf_check -o inline:"plop" cat file1
|
atf_check -o inline:"plop" cat file1
|
||||||
atf_check -o inline:"" cat emptyfile
|
atf_check -o inline:"" cat emptyfile
|
||||||
atf_check -o inline:"bla\n" cat file_base64
|
atf_check -o inline:"bla\n" cat file_base64
|
||||||
test -f foo && atf_fail "foo creation should have been defered"
|
test -f foo && atf_fail "foo creation should have been deferred"
|
||||||
atf_check -o match:"^-rwxr-xr-x.*nobody" ls -l file_base64
|
atf_check -o match:"^-rwxr-xr-x.*nobody" ls -l file_base64
|
||||||
rm file1 emptyfile file_base64
|
rm file1 emptyfile file_base64
|
||||||
atf_check -o empty /usr/libexec/nuageinit "${PWD}"/media/nuageinit postnet
|
atf_check -o empty /usr/libexec/nuageinit "${PWD}"/media/nuageinit postnet
|
||||||
|
|||||||
Reference in New Issue
Block a user