aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xapt-panopticon.lua106
1 files changed, 77 insertions, 29 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index a3857b3..26ef4ac 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -70,8 +70,6 @@ options =
70} 70}
71 71
72local defaultURL = {scheme = "http"} 72local defaultURL = {scheme = "http"}
73local downloadLock = "flock -n results/wget-"
74local download = "wget --timeout=300 -np -N -r -P results " -- Note wget has a default read timeout of 900 seconds (15 minutes).
75local releases = {"jessie", "ascii", "beowulf", "ceres"} 73local releases = {"jessie", "ascii", "beowulf", "ceres"}
76local releaseFiles = 74local releaseFiles =
77{ 75{
@@ -609,28 +607,66 @@ checkHost = function (orig, host, path, ip, file)
609 end 607 end
610end 608end
611 609
612local downloads = function (cut, host, URL) 610
613 if 0 ~= cut then cd = " --cut-dirs=" .. cut .. " " else cd = "" end 611local addDownload = function(host, URL, f, r, k)
612 f:write('url "' .. 'http://' .. host .. URL .. '/merged/dists/' .. r .. k .. '"\n')
613 f:write('output "results/' .. host .. '/merged/dists/' .. r .. k .. '"\n')
614 -- Curls "check timestamp and overwrite file" stuff sucks.
615 -- Can only do ONE timestamp check per command.
616 -- Will DELETE the existing file if the timestamp fails to download a new one, unless we change directory first, which wont work here.
617 os.execute("if [ -f results/" .. host .. "/merged/dists/" .. r .. k .. " ]; then mv" ..
618 " results/" .. host .. "/merged/dists/" .. r .. k ..
619 " results/" .. host .. "/merged/dists/" .. r .. k .. ".old; fi")
620end
621
622local postDownload = function(host, r, k)
623 os.execute("if [ -f results/" .. host .. "/merged/dists/" .. r .. k .. ".old ]" ..
624 " && [ ! -f results/" .. host .. "/merged/dists/" .. r .. k .. " ]; then cp" ..
625 " results/" .. host .. "/merged/dists/" .. r .. k .. ".old" ..
626 " results/" .. host .. "/merged/dists/" .. r .. k .. "; fi")
627end
628
629local downloadLock = "flock -n results/curl-"
630local download = "curl --connect-timeout " .. options.timeout.value .. " --create-dirs -L -z 'results/stamp.old' -v -R "
631local downloads = function(host, URL, release, list)
614 if nil == URL then URL = "/" end 632 if nil == URL then URL = "/" end
615 local lock = "%s-" .. host .. ".log " 633 local lock = "%s-" .. host .. ".lock"
616 local log = " --rejected-log=results/wget-%s_REJECTS-" .. host .. ".log -a results/wget-%s-" .. host .. ".log " 634 local log = " --stderr results/curl-%s_" .. host .. ".log"
617 I("starting file download commands for " .. host .. " " .. URL) 635 local cm = "ionice -c3 nice -n 19 " .. downloadLock .. lock:format("META") .. " " .. download .. log:format("META") .. " -K results/" .. host .. ".curl"
618 local cm = "ionice -c3 " .. downloadLock .. lock:format("debs") .. download .. log:format("debs", "debs") .. cd 636 if testing("IPv4") and (not testing("IPv6")) then cm = cm .. ' -4' end
619 for i, s in pairs(referenceDevs) do 637 if (not testing("IPv4")) and testing("IPv6") then cm = cm .. ' -6' end
620 cm = cm .. " https://" .. host .. URL .. "/" .. s 638 f, e = io.open("results/" .. host .. ".curl", "a+")
621 end 639 if nil == f then C("opening curl file - " .. e); return end
622 for i, s in pairs(referenceDebs) do 640
623 cm = cm .. " https://" .. host .. URL .. "/" .. s 641 if nil ~= list then
624 end 642 if "" ~= list then
625 for i, s in pairs(releases) do 643 for l in list:gmatch("\n*([^\n]+)\n*") do
626 fork(cm) 644 addDownload(host, URL, f, release, "/" .. l)
627 cm = "ionice -c3 " .. downloadLock .. lock:format(s) .. download .. log:format(s, s) .. cd 645 end
628 if repoExists(s .. k) then 646 f:close()
647 return
648 end
649 else
650
651--[[
652 for i, s in pairs(referenceDevs) do
653 cm = cm .. " https://" .. host .. URL .. "/" .. s
654 end
655 for i, s in pairs(referenceDebs) do
656 cm = cm .. " https://" .. host .. URL .. "/" .. s
657 end
658 execute(cm)
659]]
660
661 for i, s in pairs(releases) do
629 for j, k in pairs(releaseFiles) do 662 for j, k in pairs(releaseFiles) do
630 cm = cm .. " https://" .. host .. URL .. "/merged/dists/" .. s .. k 663 if repoExists(s .. k) then
664 addDownload(host, URL, f, s, k)
665 end
631 end 666 end
632 end 667 end
633 end 668 end
669 f:close()
634 fork(cm) 670 fork(cm)
635end 671end
636 672
@@ -796,17 +832,13 @@ if 0 < #arg then
796 results[v] = tests 832 results[v] = tests
797 end 833 end
798 end 834 end
799
800 if testing("Integrity") or testing("Updated") then 835 if testing("Integrity") or testing("Updated") then
801 if nil == arg[3] then 836 if nil == arg[2] then
802 if not keep then execute("rm -fr results/" .. pu.host) end 837 I("Starting file downloads for " .. pu.host)
803 cut = 0 838-- if not keep then execute("rm -fr results/" .. pu.host) end
804 for t in arg[1]:gmatch("(/)") do 839 downloads(pu.host, pu.path)
805 cut = cut + 1 840-- checkExes("apt-panopticon.lua " .. sendArgs)
806 end 841-- checkExes(downloadLock)
807 downloads(cut, pu.host, pu.path)
808 checkExes("apt-panopticon.lua " .. sendArgs)
809 checkExes(downloadLock)
810 end 842 end
811 end 843 end
812 if origin then 844 if origin then
@@ -815,6 +847,21 @@ if 0 < #arg then
815 checkHost(pu.host, pu.host, pu.path, arg[2], arg[3]) 847 checkHost(pu.host, pu.host, pu.path, arg[2], arg[3])
816 end 848 end
817 849
850 if testing("Integrity") or testing("Updated") then
851 if nil == arg[2] then
852 while 0 < checkExes(downloadLock .. "META-" .. pu.host .. ".lock") do os.execute("sleep 10") end
853 os.execute("rm -f results/" .. pu.host .. ".curl")
854 for i, n in pairs(releases) do
855 for l, o in pairs(releaseFiles) do
856 if repoExists(i .. o) then
857 postDownload(pu.host, n, o)
858 end
859 end
860
861 end
862 end
863 end
864
818 local f = pu.host 865 local f = pu.host
819 if "" ~= ip then f = f .. "_" .. ip end 866 if "" ~= ip then f = f .. "_" .. ip end
820 local rfile, e = io.open("results/" .. f .. ".lua", "w+") 867 local rfile, e = io.open("results/" .. f .. ".lua", "w+")
@@ -826,6 +873,7 @@ if 0 < #arg then
826 logFile:close() 873 logFile:close()
827else 874else
828 if not keep then 875 if not keep then
876 os.execute("rm -f results/*.curl")
829 os.execute("rm -f results/*.log") 877 os.execute("rm -f results/*.log")
830 os.execute("rm -f results/*.html") 878 os.execute("rm -f results/*.html")
831 os.execute("rm -f results/*.txt") 879 os.execute("rm -f results/*.txt")