simplified update-rc.d enable/disable handling, removed forced defaults
creation as that breaks local customizations
This commit is contained in:
parent
44ec0d735e
commit
f4a709ad7c
1 changed files with 17 additions and 32 deletions
|
@ -105,6 +105,7 @@ import shlex
|
||||||
import select
|
import select
|
||||||
import time
|
import time
|
||||||
import string
|
import string
|
||||||
|
import glob
|
||||||
|
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
|
@ -734,44 +735,28 @@ class LinuxService(Service):
|
||||||
# update-rc.d style
|
# update-rc.d style
|
||||||
#
|
#
|
||||||
if self.enable_cmd.endswith("update-rc.d"):
|
if self.enable_cmd.endswith("update-rc.d"):
|
||||||
if self.enable:
|
|
||||||
action = 'enable'
|
|
||||||
else:
|
|
||||||
action = 'disable'
|
|
||||||
|
|
||||||
if self.enable:
|
enabled = False
|
||||||
# make sure the init.d symlinks are created
|
links = glob.glob('/etc/rc?.d/S??' + self.name)
|
||||||
# otherwise enable might not work
|
if links:
|
||||||
(rc, out, err) = self.execute_command("%s %s defaults" \
|
enabled = True
|
||||||
% (self.enable_cmd, self.name))
|
|
||||||
|
if self.enable != enabled:
|
||||||
|
self.changed = True
|
||||||
|
|
||||||
|
if self.enable:
|
||||||
|
action = 'enable'
|
||||||
|
else:
|
||||||
|
action = 'disable'
|
||||||
|
|
||||||
|
(rc, out, err) = self.execute_command("%s %s %s" % (self.enable_cmd, self.name, action))
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
if err:
|
if err:
|
||||||
self.module.fail_json(msg=err)
|
self.module.fail_json(msg=err)
|
||||||
else:
|
else:
|
||||||
self.module.fail_json(msg=out)
|
self.module.fail_json(msg=out) % (self.enable_cmd, self.name, action)
|
||||||
|
|
||||||
(rc, out, err) = self.execute_command("%s -n %s %s" \
|
return
|
||||||
% (self.enable_cmd, self.name, action))
|
|
||||||
self.changed = False
|
|
||||||
for line in out.splitlines():
|
|
||||||
if line.startswith('rename'):
|
|
||||||
self.changed = True
|
|
||||||
break
|
|
||||||
elif self.enable and 'do not exist' in line:
|
|
||||||
self.changed = True
|
|
||||||
break
|
|
||||||
elif not self.enable and 'already exist' in line:
|
|
||||||
self.changed = True
|
|
||||||
break
|
|
||||||
|
|
||||||
# Debian compatibility
|
|
||||||
for line in err.splitlines():
|
|
||||||
if self.enable and 'no runlevel symlinks to modify' in line:
|
|
||||||
self.changed = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if not self.changed:
|
|
||||||
return
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# If we've gotten to the end, the service needs to be updated
|
# If we've gotten to the end, the service needs to be updated
|
||||||
|
|
Loading…
Reference in a new issue