blob: d2fe0cbd71513eab404121de137dea5a69eb1fa4 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
module(..., package.seeall)
-- Load libraries
require("modelfunctions")
require("fs")
-- ################################################################################
-- SET VARIABLES
local packagename="vlc-daemon"
local packagename="vlc"
local processname="vlc"
local configfile = "/etc/conf.d/"..tostring(processname)
local logfile = "/var/log/vlc/vlc.log"
function set_processname(p)
processname = p
configfile = "/etc/conf.d/"..tostring(processname)
end
-- ################################################################################
-- LOCAL FUNCTIONS
-- ################################################################################
-- PUBLIC FUNCTIONS
function startstop_service(action)
return modelfunctions.startstop_service(processname, action)
end
function getstatus()
return modelfunctions.getstatus(processname, packagename, tostring(processname).." Status")
end
function getconfigfile()
-- FIXME Validate
return modelfunctions.getfiledetails(configfile)
end
get_filedetails = function (path)
local path=logfile
for line in string.gmatch(fs.read_file(configfile), "(.-)\n") do
path=string.match(line,"^VLC_OPTS.*%-%-logfile%s+(%S+)") or path
end
local file = path
local st = fs.stat(path)
if st and st.type then
while st.type == "link" do
st = fs.stat(posix.readlink(st.path))
end
file = st.path
end
local filedetails = modelfunctions.getfiledetails(file)
filedetails.value.filename.value = path
return filedetails
end
function setconfigfile(filedetails)
-- FIXME Validate
return modelfunctions.setfiledetails(filedetails, {configfile})
end
function getleases()
return modelfunctions.getfiledetails(leasefile)
end
|