blob: 2ed84e80d7df8c0f05264ae6230954e3b243bb21 (
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
|
--[[
Copyright (c) 2012-2013 Kaarle Ritvanen
See LICENSE file for license details
--]]
local model = require('acf2.model.model')
local super = require('acf2.object').super
local DataStore = require('acf2.persistence')
return function(name)
local res = model.new()
local function afunc(action)
return function() os.execute('rc-service '..name..' '..action) end
end
local reload = afunc('reload')
function res:init(context)
DataStore:trigger(context.addr, reload)
super(self, res):init(context)
end
for _, action in ipairs{'start', 'stop', 'restart'} do
res[action] = model.Action{func=afunc(action)}
end
return res
end
|