aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apt-panopticon-update-data.lua
blob: 8adad4d35f6ef19110e99740eac2e285af08f5f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env luajit

local APT = require 'apt-panopticommon'
local D = APT.D
local I = APT.I
local T = APT.T
local W = APT.W
local E = APT.E
local C = APT.C
local arg, sendArgs = APT.parseArgs({...})



local files = io.popen('ls -1 results_*.tar.xz')
for l in files:lines() do
    print('tar -xf ' .. l)
    os.execute('tar -xf ' .. l)
end

os.execute('rm -fr rrd')
local files = io.popen('ls -d1 results_*')
for l in files:lines() do
    if ('results_old' ~= l) and ('.tar.xz' ~= l:sub(25, -1)) then
	if APT.checkFile(l .. '/stamp') then
	    local status, whn = APT.execute('TZ="GMT" ls -d1 --time-style="+%s" ' .. l .. ' | cut -d " " -f 6-6')
	    whn = whn:sub(2, -2)
	    local status, new = APT.execute('TZ="GMT" date -d "' .. whn:sub(9, 18) .. ' ' .. whn:sub(20, 21) .. ':' .. whn:sub(23, 24) .. '" "+%s"')
	    APT.now = tonumber("0" .. new:sub(2, -2))
	    if 0 ~= APT.now then
		print(l .. ' -> ' .. APT.now)
		APT.mirrors = loadfile(l .. "/mirrors.lua")()
		for k, v in pairs(APT.mirrors) do
		    APT.doRRD(l, k, v)
		end
	    else
		print(l)
	    end
	else
	    print(l)
	end
    end
end

local files = io.popen('ls -1 results_*.tar.xz')
for l in files:lines() do
    print('tar -c --xz  ' .. l:sub(1, 24) .. ' -f ' .. l .. '; rm -fr ' .. l:sub(1, 24))
    os.execute('tar -c --xz  ' .. l:sub(1, 24) .. ' -f ' .. l .. '; rm -fr ' .. l:sub(1, 24))
end