aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--apt-panopticommon.lua16
-rwxr-xr-xapt-panopticon.lua14
2 files changed, 17 insertions, 13 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua
index d8ab129..54e2be1 100644
--- a/apt-panopticommon.lua
+++ b/apt-panopticommon.lua
@@ -315,7 +315,18 @@ APT.results = {}
315APT.logFile = nil 315APT.logFile = nil
316APT.html = false 316APT.html = false
317 317
318APT.logPre = function() 318APT.logName = function(host, a2, a3)
319 local name = host
320 if nil ~= a2 then name = name .. "_" .. a2 end
321 if nil ~= a3 then name = name .. "_" .. a3 end
322 return 'results/LOG_' .. name .. '.html'
323end
324
325APT.logOpen = function(host, a2, a3)
326 local name = APT.logName(host, a2, a3)
327 if APT.checkFile(name) then return false end
328 APT.logFile, e = io.open(name, "a+")
329 if nil == APT.logFile then C('opening log file (' .. name .. ') - ' .. e); return false end
319 if nil ~= APT.logFile then 330 if nil ~= APT.logFile then
320 APT.logFile:write("<html><head>\n") 331 APT.logFile:write("<html><head>\n")
321 APT.logFile:write("</head><body bgcolor='black' text='white' alink='red' link='blue' vlink='purple'>\n") 332 APT.logFile:write("</head><body bgcolor='black' text='white' alink='red' link='blue' vlink='purple'>\n")
@@ -323,10 +334,13 @@ APT.logPre = function()
323 APT.logFile:write(APT.dumpTable(APT.args, '', 'Arguments')) 334 APT.logFile:write(APT.dumpTable(APT.args, '', 'Arguments'))
324 APT.logFile:write("</pre>\n") 335 APT.logFile:write("</pre>\n")
325 end 336 end
337 return true
326end 338end
339
327APT.logPost = function() 340APT.logPost = function()
328 if nil ~= APT.logFile then 341 if nil ~= APT.logFile then
329 APT.logFile:write("</body></html> \n") 342 APT.logFile:write("</body></html> \n")
343 APT.logFile:close()
330 end 344 end
331end 345end
332 346
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index 45a591f..649346a 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -922,13 +922,7 @@ if 0 < #arg then
922 922
923 if APT.origin or APT.redir then APT.results["IPs"] = gatherIPs(pu.host) end 923 if APT.origin or APT.redir then APT.results["IPs"] = gatherIPs(pu.host) end
924 924
925 local logname = pu.host 925 if not APT.logOpen(pu.host, arg[2], arg[3]) then return end
926 if nil ~= arg[2] then logname = logname .. "_" .. arg[2] end
927 if nil ~= arg[3] then logname = logname .. "_" .. arg[3] end
928 if APT.checkFile("results/LOG_" .. logname .. ".html") then return end
929 APT.logFile, e = io.open("results/LOG_" .. logname .. ".html", "a+")
930 if nil == APT.logFile then C("opening log file - " .. e); return end
931 APT.logPre()
932 I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", ")) 926 I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", "))
933 if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end 927 if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end
934 if nil ~= arg[3] then I(" Using file " .. arg[3]); end 928 if nil ~= arg[3] then I(" Using file " .. arg[3]); end
@@ -1005,7 +999,6 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them.
1005 end 999 end
1006 1000
1007 APT.logPost() 1001 APT.logPost()
1008 APT.logFile:close()
1009else 1002else
1010 local fadt = io.popen("ls -dl results_old 2>/dev/null | cut -d '>' -f 2 | cut -d ' ' -f 2") 1003 local fadt = io.popen("ls -dl results_old 2>/dev/null | cut -d '>' -f 2 | cut -d ' ' -f 2")
1011 local adt = fadt:read('*l') 1004 local adt = fadt:read('*l')
@@ -1024,9 +1017,7 @@ else
1024 os.execute("rm -f results/*.txt 2>/dev/null") 1017 os.execute("rm -f results/*.txt 2>/dev/null")
1025 end 1018 end
1026 1019
1027 APT.logFile, e = io.open("results/LOG_apt-panopticon.html", "a+") 1020 if not APT.logOpen('apt-panopticon') then return end
1028 if nil == APT.logFile then C("opening log file - " .. e); return end
1029 APT.logPre()
1030 I("Starting tests " .. table.concat(APT.options.tests.value, ", ")) 1021 I("Starting tests " .. table.concat(APT.options.tests.value, ", "))
1031 os.execute("mkdir -p results") 1022 os.execute("mkdir -p results")
1032 APT.mirrors = getMirrors() 1023 APT.mirrors = getMirrors()
@@ -1069,5 +1060,4 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them.
1069 1060
1070 I('Total run time was ' .. (os.time() - now) .. ' seconds.') 1061 I('Total run time was ' .. (os.time() - now) .. ' seconds.')
1071 APT.logPost() 1062 APT.logPost()
1072 APT.logFile:close()
1073end 1063end