Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use either service binary OR rc.d script, for compatibility with pre-…

…8.1 FreeBSD
  • Loading branch information...
commit fba7b935b0e84ccb90002f0789ed58f1fe4c287c 1 parent e7ce017
@jwarlander authored
Showing with 20 additions and 5 deletions.
  1. +20 −5 library/system/service
View
25 library/system/service
@@ -764,15 +764,24 @@ class FreeBsdService(Service):
platform = 'FreeBSD'
distribution = None
+ use_service = True
def get_service_tools(self):
- self.svc_cmd = self.module.get_bin_path('service', True)
+ self.svc_cmd = self.module.get_bin_path('service')
if not self.svc_cmd:
- self.module.fail_json(msg='unable to find service binary')
+ self.use_service = False
+ self.svc_cmd = self.module.get_bin_path('/usr/local/etc/rc.d/%s' % self.name)
+ if not self.svc_cmd:
+ self.svc_cmd = self.module.get_bin_path('/etc/rc.d/%s' % self.name)
+ if not self.svc_cmd:
+ self.module.fail_json(msg='unable to find service binary or rc.d script for %s' % self.name)
def get_service_status(self):
- rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'onestatus', self.arguments))
+ if self.use_service:
+ rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'onestatus', self.arguments))
+ else:
+ rc, stdout, stderr = self.execute_command("%s %s %s" % (self.svc_cmd, 'onestatus', self.arguments))
if rc == 1:
self.running = False
elif rc == 0:
@@ -789,7 +798,10 @@ class FreeBsdService(Service):
if os.path.isfile(rcfile):
self.rcconf_file = rcfile
- rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'rcvar', self.arguments))
+ if self.use_service:
+ rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'rcvar', self.arguments))
+ else:
+ rc, stdout, stderr = self.execute_command("%s %s %s" % (self.svc_cmd, 'rcvar', self.arguments))
cmd = "%s %s %s %s" % (self.svc_cmd, self.name, 'rcvar', self.arguments)
rcvars = shlex.split(stdout, comments=True)
@@ -820,7 +832,10 @@ class FreeBsdService(Service):
if self.action is "reload":
self.action = "onereload"
- return self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, self.action, self.arguments))
+ if self.use_service:
+ return self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, self.action, self.arguments))
+ else:
+ return self.execute_command("%s %s %s" % (self.svc_cmd, self.action, self.arguments))
# ===========================================
# Subclass: OpenBSD
Please sign in to comment.
Something went wrong with that request. Please try again.