summaryrefslogtreecommitdiffstats
path: root/syslog-model.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-29 16:19:42 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-29 16:19:42 +0000
commita1e005f1c2cf658dfbb6a23fc99b44b6316d2830 (patch)
tree59cab256dc86161d6b1f394086688e0fcceb8093 /syslog-model.lua
parent7e224ea050d1be68daf2c2fac9db94f00bc668ee (diff)
downloadacf-alpine-baselayout-a1e005f1c2cf658dfbb6a23fc99b44b6316d2830.tar.bz2
acf-alpine-baselayout-a1e005f1c2cf658dfbb6a23fc99b44b6316d2830.tar.xz
Now you can save configs in config-tab.
It works but is still unstable. git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@660 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'syslog-model.lua')
-rw-r--r--syslog-model.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index a2a6eb2..f8563fc 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -71,6 +71,9 @@ function getconfig()
errors["configfile"] = "Config file '".. configfile .. "' is missing!"
end
-- Next section is to set/show default values when a option is not configured in the configfile
+ if not (config["SYSLOGD_OPTS"]) then
+ config["SYSLOGD_OPTS"] = {}
+ end
config["SYSLOGD_OPTS"]["-O"] = config["SYSLOGD_OPTS"]["-O"] or "/var/log/messages"
config["SYSLOGD_OPTS"]["-l_list"] = getloglevels()
config["SYSLOGD_OPTS"]["-R"] = config["SYSLOGD_OPTS"]["-R"] or ""
@@ -83,6 +86,9 @@ function getconfig()
else
config["SYSLOGD_OPTS"]["-l"] = config["SYSLOGD_OPTS"]["-l"] or 8
end
+ if (config["SYSLOGD_OPTS"]["-L"] ~= nil) and (config["SYSLOGD_OPTS"]["-R"] == "") then
+ errors["SYSLOGD_OPTS"]["-L"] = "Logging to local and network is possible unless you define a host for remote logging."
+ end
return config, errors
end
@@ -106,9 +112,18 @@ service_control = function ( self, srvcmd )
return retval
end
-function setconfigs(self,value)
- --TODO: Validate so that user cant add values with '-'
+function setconfigs(self,variable,parameter,value)
+ --TODO: Validate so that user cant add values with '-' (could cause major breakage next time you do getopts)
+ --If file is missing... then create a new one
+-- if not (fs.is_file(configfile)) then fs.write_file(configfile, "SYSLOGD_OPTS=\"\"\nKLOGD_OPTS=\"\"") end
+ if not (variable) or not (parameter) then return nil, "Usage setconfigs(variable,parameter,value)" end
+ if not (string.find(parameter, "-%a$")) then return nil, "Parameter must be formated '-a' (where a is one upper/lowercase letter [a-z])" end
+ -- Set specific variables (and their values
+ if (value) and ((parameter == "-S") or (parameter == "-L")) then value = "" end
+ local retval, errors = getopts.setoptsinfile(configfile,variable,parameter,value)
+ return retval, errors
end
+
function update_filecontent (self, modifications)
local path = configfile
local file_result,err = fs.write_file(path, format.dostounix(modifications))