aboutsummaryrefslogtreecommitdiffstats
path: root/_.lua
diff options
context:
space:
mode:
authordvs12024-10-22 17:03:41 +1000
committerdvs12024-10-22 17:03:41 +1000
commitd0c90692ab3438b332f6da1e485617f9de9a7412 (patch)
tree18b924affc7016eee5078ea161fc71d1bcffd033 /_.lua
parentMake the user command STOP, so stop is for SysV. (diff)
downloadJackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.zip
JackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.tar.gz
JackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.tar.bz2
JackOnAllDevices-d0c90692ab3438b332f6da1e485617f9de9a7412.tar.xz
Rearrange those logging globals and a few other things in _.
Diffstat (limited to '_.lua')
-rwxr-xr-x_.lua77
1 files changed, 34 insertions, 43 deletions
diff --git a/_.lua b/_.lua
index 42c3b4a..19b73b4 100755
--- a/_.lua
+++ b/_.lua
@@ -3,21 +3,41 @@
3 3
4-- Most of this _ stuff was copied from apt-panopticon. 4-- Most of this _ stuff was copied from apt-panopticon.
5local _ = {} 5local _ = {}
6
7_.version = '0.0 crap' 6_.version = '0.0 crap'
8 7
9_.D = function(s) print('DEBUG ' .. s) end 8
10_.I = function(s) print('INFO ' .. s) end 9D = function(s) print('DEBUG ' .. s) end
11_.T = function(s) print('TIMEOUT ' .. s) end 10I = function(s) print('INFO ' .. s) end
12_.W = function(s) print('WARNING ' .. s) end 11T = function(s) print('TIMEOUT ' .. s) end
13_.E = function(s) print('ERROR ' .. s) end 12W = function(s) print('WARNING ' .. s) end
14_.C = function(s) print('CRITICAL ' .. s) end 13E = function(s) print('ERROR ' .. s) end
15local D = _.D 14C = function(s) print('CRITICAL ' .. s) end
16local I = _.I 15
17local T = _.T 16
18local W = _.W 17_.runnable = function(c)
19local E = _.E 18 return ( 0 == __('which ' .. c):Do().status )
20local C = _.C 19end
20
21_.running = function(c)
22 return ( 1 ~= tonumber(__("pgrep -u $USER -cf " .. c):Do().lines[1]) )
23end
24
25_.exists = function(f)
26 local h, e = io.open(f, "r")
27 if nil == h then return false else h:close(); return true end
28end
29
30_.killEmAll = function(all)
31 for i,l in ipairs(all) do
32 local c = 0
33 while 0 ~= tonumber(__("pgrep -u $USER -xc " .. l):Do().lines[1]) do
34 local s = 'TERM'
35 if c > 1 then s = 'KILL'; __("sleep " .. c):Do() end
36 __("pkill -" .. s .. " -u $USER -x " .. l):log():Do()
37 c = c + 1
38 end
39 end
40end
21 41
22 42
23_.readCmd = function(cmd) 43_.readCmd = function(cmd)
@@ -33,8 +53,7 @@ _.readCmd = function(cmd)
33 return result 53 return result
34end 54end
35 55
36 56__ = function(c)
37_._ = function(c)
38 local exe = {status = 0, lines = {}, logging = false, showing = false, cmd = '', command = c} 57 local exe = {status = 0, lines = {}, logging = false, showing = false, cmd = '', command = c}
39 local n = 0 58 local n = 0
40 59
@@ -165,33 +184,5 @@ _._ = function(c)
165 return exe 184 return exe
166end 185end
167 186
168local __ = _._
169
170_.runnable = function(c)
171 return ( 0 == __('which ' .. c):Do().status )
172end
173
174_.running = function(c)
175 return ( 1 ~= tonumber(__("pgrep -u $USER -cf " .. c):Do().lines[1]) )
176end
177
178_.exists = function(f)
179 local h, e = io.open(f, "r")
180 if nil == h then return false else h:close(); return true end
181end
182
183_.killEmAll = function(all)
184 for i,l in ipairs(all) do
185 local c = 0
186 while 0 ~= tonumber(__("pgrep -u $USER -xc " .. l):Do().lines[1]) do
187 local s = 'TERM'
188 if c > 1 then s = 'KILL'; __("sleep " .. c):Do() end
189 __("pkill -" .. s .. " -u $USER -x " .. l):log():Do()
190 c = c + 1
191 end
192 end
193end
194
195
196 187
197return _ 188return _