From c700c97cb992cdc3eb62d93a52e1bf56ed5ea585 Mon Sep 17 00:00:00 2001 From: ttrask Date: Tue, 17 Mar 2009 20:39:56 +0000 Subject: Changed the way startstop works in core to add a list of allowed actions. Modified all ACFs that don't use the standard functions to work with new library method. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1730 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/modelfunctions.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/modelfunctions.lua') diff --git a/lib/modelfunctions.lua b/lib/modelfunctions.lua index 076d1bb..d7be73d 100644 --- a/lib/modelfunctions.lua +++ b/lib/modelfunctions.lua @@ -16,10 +16,15 @@ function getenabled(processname) return result end -function startstop_service(servicename, action) - -- action is validated in daemoncontrol - local cmdmessage,cmderror = processinfo.daemoncontrol(servicename, action) - return cfe({ value=cmdmessage or "", errtxt=cmderror, label="Start/Stop result" }) +function startstop_service(servicename, action, actions) + -- action is validated against actions in daemoncontrol + local result = {} + result.actions = cfe({ type="list", value=actions or {"start", "stop", "restart"}, label="Start/Stop actions" }) + if action then + local cmdmessage,cmderror = processinfo.daemoncontrol(servicename, action, result.actions.value) + result.result = cfe({ value=cmdmessage or "", errtxt=cmderror, label="Start/Stop result" }) + end + return cfe({ type="group", value=result, label="Start/Stop result" }) end function getstatus(processname, packagename, label, servicename) -- cgit v1.2.3