From 4d2325161be2448fb521b1aacc02965e9dfaba64 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Sat, 26 Apr 2008 09:59:53 +0000 Subject: Saving work for today. Create new configfile starts working. Delete configfile (work in progress - still not working). Added information on filesize/modifydate on each configfile. git-svn-id: svn://svn.alpinelinux.org/acf/tinydns/trunk@1048 ab2d0c66-481e-0410-8bed-d214d4d58bed --- tinydns-model.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tinydns-model.lua') diff --git a/tinydns-model.lua b/tinydns-model.lua index 3b91cb3..7ac2495 100644 --- a/tinydns-model.lua +++ b/tinydns-model.lua @@ -7,6 +7,7 @@ require("fs") require("format") require("processinfo") require("daemoncontrol") +require("validator") -- Set variables local configdir @@ -362,12 +363,19 @@ function getconfig(self,filter_type) local config = {} local listenaddr = getopts.getoptsfromfile_onperline(configfile,"IP") or {} + config.listen = cfe({ name = "listen", label="IP address to listen on", value=listenaddr.IP or "", }) + config.baseurl = cfe({ + name = "baseurl", + label="Baseurl for configfiles", + value=baseurl, + }) + return config end @@ -712,3 +720,17 @@ function updatefilecontent (self, filetochange) end return false, "Something went wrong!" end + +function createconfigfile (self, path) + local validfilepath, filepatherror = validator.is_valid_filename(path,baseurl) + if (fs.is_file(path)) then + return false,"File already exists" + end + if (validfilepath) then + fs.write_file(path, "") + return true,nil + else + return false, filepatherror + end + return false, "Something went wrong!" +end -- cgit v1.2.3