aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--apt-panopticommon.lua59
-rwxr-xr-xapt-panopticon.lua5
2 files changed, 62 insertions, 2 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua
index c9194fa..a19f1e3 100644
--- a/apt-panopticommon.lua
+++ b/apt-panopticommon.lua
@@ -450,6 +450,65 @@ APT.fork = function(s)
450 os.execute(s .. " &") 450 os.execute(s .. " &")
451end 451end
452 452
453
454APT.exe = function(c)
455 local exe = {status = 0, result = ''}
456 exe.cmd = c .. ' '
457 exe.log = false
458
459 function exe:log()
460 self.log = true
461 return self
462 end
463 function exe:Nice(c)
464 self.cmd = self.cmd .. 'ionice -c3 nice -n 19 ' .. c .. ' '
465 return self
466 end
467 function exe:And(c)
468 if nil == c then c = '' else c = ' ' .. c end
469 self.cmd = self.cmd .. '&&' .. c .. ' '
470 return self
471 end
472 function exe:Or(c)
473 if nil == c then c = '' end
474 self.cmd = self.cmd .. '|| ' .. c .. ' '
475 return self
476 end
477 function exe:noErr()
478 self.cmd = self.cmd .. '2>/dev/null '
479 return self
480 end
481 function exe:wait(w)
482 self.cmd = self.cmd .. '&& touch ' .. w .. ' '
483 return self
484 end
485 function exe:Do()
486 if self.log then D(" executing - &nbsp; <code>" .. self.cmd .. "</code>") end
487 --[[ Damn os.execute()
488 Lua 5.1 says it returns "a status code, which is system-dependent"
489 Lua 5.2 says it returns true/nil, "exit"/"signal", the status code.
490 I'm getting 7168 or 0. No idea what the fuck that is.
491 local ok, rslt, status = os.execute(s)
492 ]]
493 local f = io.popen(self.cmd .. ' ; echo "$?"', 'r')
494 -- The last line will be the command's returned status, collect everything else in result.
495 for l in f:lines() do
496 self.result = self.result .. self.status .. "\n"
497 self.status = l
498 end
499 self.status = tonumber(self.status)
500 return self
501 end
502 function exe:fork()
503 self.cmd = '{ ' .. self.cmd .. '; } &'
504 if self.log then D(" forking - &nbsp; <code>" .. self.cmd .. "</code>") end
505 os.execute(self.cmd)
506 return self
507 end
508 return exe
509end
510
511
453APT.checkExes = function (exe) 512APT.checkExes = function (exe)
454 local count = io.popen('ps x | grep "' .. exe .. '" | grep -v " grep " | grep -v "flock -n apt-panopticon.lock " | wc -l'):read("*l") 513 local count = io.popen('ps x | grep "' .. exe .. '" | grep -v " grep " | grep -v "flock -n apt-panopticon.lock " | wc -l'):read("*l")
455 D(count .. " " .. exe .. " commands still running.") 514 D(count .. " " .. exe .. " commands still running.")
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index e54e553..a97a974 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -1065,8 +1065,9 @@ else
1065 local adt = fadt:read('*l') 1065 local adt = fadt:read('*l')
1066 fadt:close() 1066 fadt:close()
1067 if (nil ~= adt) and APT.checkFile(adt) then 1067 if (nil ~= adt) and APT.checkFile(adt) then
1068 os.execute('{ mkdir -p ' .. adt:sub(1, 18) .. ' && ionice -c3 nice -n 19' .. 1068 APT.exe('mkdir -p ' .. adt:sub(1, 18))
1069 ' tar -c --xz ' .. adt .. ' -f ' .. adt:sub(1, 18) .. '/' .. adt .. '.tar.xz && rm -fr ' .. adt .. ' 2>/dev/null; } &') 1069 :And():Nice('tar -c --xz ' .. adt .. ' -f ' .. adt:sub(1, 18) .. '/' .. adt .. '.tar.xz')
1070 :And('rm -fr ' .. adt):noErr():fork()
1070 end 1071 end
1071 local dt = os.date('!%F-%H-%M') 1072 local dt = os.date('!%F-%H-%M')
1072 local fodt = io.popen('TZ="GMT" date -r results/stamp +%F-%H-%M 2>/dev/null', 'r') 1073 local fodt = io.popen('TZ="GMT" date -r results/stamp +%F-%H-%M 2>/dev/null', 'r')