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