From 559321a85c50815cba832ec35baf4a3546cc3abe Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Sat, 17 Nov 2007 00:12:34 +0000 Subject: added initial syslog git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@330 ab2d0c66-481e-0410-8bed-d214d4d58bed --- syslog-model.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 syslog-model.lua (limited to 'syslog-model.lua') diff --git a/syslog-model.lua b/syslog-model.lua new file mode 100644 index 0000000..7391cfe --- /dev/null +++ b/syslog-model.lua @@ -0,0 +1,44 @@ +module(..., package.seeall) + +require("pidof") +require("split") + +-- we actually need root permissions to get the process list +priv = {} +function priv.is_enabled() + return (pidof.pidof("syslogd")) +end + +function priv.enable(opts) + if opts and opts.remote then + local f = io.open("/etc/conf.d/syslog", "w") + if f == nil then + return nil + end + f:write("# this file was written by and will be overwritten by acf\n") + f:write("SYSLOGD_OPTS=\"-R "..opts.remote.."\"") + f:close() + end + os.system("/etc/init.d/syslogd restart; rc_add -k -s 20 syslog") +end + + +-- this func does not need privileges +function readopts() + local opts = {} + local line + local f = io.open("/etc/conf.d/syslog", "r") + if f == nil then + return nil + end + for line in f:lines() do + local optstr = string.match(line, "^SYSLOGD_OPTS=\"?(.*)\"?") + if optstr then + opts.remote = string.match(optstr, "-R%s*(.*)%s*.*$") + opts.optstr = optstr + end + end + return opts +end + + -- cgit v1.2.3