1 $NetBSD: patch-library_service,v 1.1 2013/02/26 00:13:00 hubertf Exp $
3 --- library/service.orig 2013-02-09 19:55:06.000000000 +0000
5 @@ -551,6 +551,65 @@ class OpenBsdService(Service):
6 return self.execute_command("%s %s" % (self.svc_cmd, self.action))
8 # ===========================================
11 +class NetBsdService(Service):
13 + This is the NetBSD Service manipulation class - it uses the /etc/rc.conf
14 + file for controlling services started at boot, check status and perform
15 + direct service manipulation. Init scripts in /etc/rcd are used for
16 + controlling services (start/stop) as well as for controlling the current
23 + def get_service_tools(self):
24 + initpaths = [ '/etc/rc.d' ] # better: $rc_directories - how to get in here? Run: sh -c '. /etc/rc.conf ; echo $rc_directories'
26 + for initdir in initpaths:
27 + initscript = "%s/%s" % (initdir,self.name)
28 + if os.path.isfile(initscript):
29 + self.svc_initscript = initscript
31 + if not self.svc_initscript:
32 + self.module.fail_json(msg='unable to find rc.d script')
34 + def service_enable(self):
36 + self.rcconf_value = "YES"
38 + self.rcconf_value = "NO"
40 + rcfiles = [ '/etc/rc.conf' ] # Overkill?
41 + for rcfile in rcfiles:
42 + if os.path.isfile(rcfile):
43 + self.rcconf_file = rcfile
45 + self.rcconf_key = "%s" % self.name
47 + return self.service_enable_rcconf()
49 + def get_service_status(self):
50 + self.svc_cmd = "%s" % self.svc_initscript
51 + rc, stdout, stderr = self.execute_command("%s %s" % (self.svc_cmd, 'onestatus'))
53 + self.running = False
57 + def service_control(self):
58 + if self.action is "start":
59 + self.action = "onestart"
60 + if self.action is "stop":
61 + self.action = "onestop"
63 + self.svc_cmd = "%s" % self.svc_initscript
64 + return self.execute_command("%s %s" % (self.svc_cmd, self.action), daemonize=True)
67 +# ===========================================