Changeset View
Changeset View
Standalone View
Standalone View
head/stand/lua/config.lua
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
local MSG_FAILEXAF = "Failed to execute '%s' after loading '%s'" | local MSG_FAILEXAF = "Failed to execute '%s' after loading '%s'" | ||||
local MSG_MALFORMED = "Malformed line (%d):\n\t'%s'" | local MSG_MALFORMED = "Malformed line (%d):\n\t'%s'" | ||||
local MSG_DEFAULTKERNFAIL = "No kernel set, failed to load from module_path" | local MSG_DEFAULTKERNFAIL = "No kernel set, failed to load from module_path" | ||||
local MSG_KERNFAIL = "Failed to load kernel '%s'" | local MSG_KERNFAIL = "Failed to load kernel '%s'" | ||||
local MSG_XENKERNFAIL = "Failed to load Xen kernel '%s'" | local MSG_XENKERNFAIL = "Failed to load Xen kernel '%s'" | ||||
local MSG_XENKERNLOADING = "Loading Xen kernel..." | local MSG_XENKERNLOADING = "Loading Xen kernel..." | ||||
local MSG_KERNLOADING = "Loading kernel..." | local MSG_KERNLOADING = "Loading kernel..." | ||||
local MSG_MODLOADING = "Loading configured modules..." | local MSG_MODLOADING = "Loading configured modules..." | ||||
local MSG_MODBLACKLIST = "Not loading blacklisted module '%s'" | |||||
local MSG_MODLOADFAIL = "Could not load one or more modules!" | local MSG_MODLOADFAIL = "Could not load one or more modules!" | ||||
local MODULEEXPR = '([%w-_]+)' | local MODULEEXPR = '([%w-_]+)' | ||||
local QVALEXPR = "\"([%w%s%p]-)\"" | local QVALEXPR = "\"([%w%s%p]-)\"" | ||||
local QVALREPL = QVALEXPR:gsub('%%', '%%%%') | local QVALREPL = QVALEXPR:gsub('%%', '%%%%') | ||||
local WORDEXPR = "([%w]+)" | local WORDEXPR = "([%w]+)" | ||||
local WORDREPL = WORDEXPR:gsub('%%', '%%%%') | local WORDREPL = WORDEXPR:gsub('%%', '%%%%') | ||||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | if line ~= nil then | ||||
end | end | ||||
if s == nil then | if s == nil then | ||||
return false | return false | ||||
end | end | ||||
end | end | ||||
return true | return true | ||||
end | end | ||||
local function getBlacklist() | |||||
local blacklist_str = loader.getenv('module_blacklist') | |||||
if blacklist_str == nil then | |||||
return nil | |||||
end | |||||
local blacklist = {} | |||||
for mod in blacklist_str:gmatch("[;, ]?([%w-_]+)[;, ]?") do | |||||
blacklist[mod] = true | |||||
end | |||||
return blacklist | |||||
end | |||||
local function loadModule(mod, silent) | local function loadModule(mod, silent) | ||||
local status = true | local status = true | ||||
local blacklist = getBlacklist() | |||||
local pstatus | local pstatus | ||||
for k, v in pairs(mod) do | for k, v in pairs(mod) do | ||||
if v.load ~= nil and v.load:lower() == "yes" then | if v.load ~= nil and v.load:lower() == "yes" then | ||||
local module_name = v.name or k | |||||
if blacklist[module_name] ~= nil then | |||||
if not silent then | |||||
print(MSG_MODBLACKLIST:format(module_name)) | |||||
end | |||||
goto continue | |||||
end | |||||
local str = "load " | local str = "load " | ||||
if v.type ~= nil then | if v.type ~= nil then | ||||
str = str .. "-t " .. v.type .. " " | str = str .. "-t " .. v.type .. " " | ||||
end | end | ||||
if v.name ~= nil then | str = str .. module_name | ||||
str = str .. v.name | |||||
else | |||||
str = str .. k | |||||
end | |||||
if v.flags ~= nil then | if v.flags ~= nil then | ||||
str = str .. " " .. v.flags | str = str .. " " .. v.flags | ||||
end | end | ||||
if v.before ~= nil then | if v.before ~= nil then | ||||
pstatus = cli_execute_unparsed(v.before) == 0 | pstatus = cli_execute_unparsed(v.before) == 0 | ||||
if not pstatus and not silent then | if not pstatus and not silent then | ||||
print(MSG_FAILEXBEF:format(v.before, k)) | print(MSG_FAILEXBEF:format(v.before, k)) | ||||
end | end | ||||
Show All 14 Lines | if v.load ~= nil and v.load:lower() == "yes" then | ||||
pstatus = cli_execute_unparsed(v.after) == 0 | pstatus = cli_execute_unparsed(v.after) == 0 | ||||
if not pstatus and not silent then | if not pstatus and not silent then | ||||
print(MSG_FAILEXAF:format(v.after, k)) | print(MSG_FAILEXAF:format(v.after, k)) | ||||
end | end | ||||
status = status and pstatus | status = status and pstatus | ||||
end | end | ||||
end | end | ||||
::continue:: | |||||
end | end | ||||
return status | return status | ||||
end | end | ||||
local function readConfFiles(loaded_files) | local function readConfFiles(loaded_files) | ||||
local f = loader.getenv("loader_conf_files") | local f = loader.getenv("loader_conf_files") | ||||
if f ~= nil then | if f ~= nil then | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |