Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Better detect upstart and sysv services, fix #1915

  • Loading branch information...
commit 396d404aae8f4d9669de6e6dac4f25314e42ad7a 1 parent 2be4529
Thomas S Hatch thatch45 authored

Showing 1 changed file with 21 additions and 8 deletions. Show diff stats Hide diff stats

  1. +21 8 salt/modules/upstart.py
29 salt/modules/upstart.py
@@ -29,7 +29,7 @@
29 29 start on ((((filesystem and runlevel [!06]) and started dbus) and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1 or stopped udev-fallback-graphics)) or runlevel PREVLEVEL=S)
30 30 stop on runlevel [016]
31 31
32   -DO NOT use this module on red hat systems, as red hat systems should use the
  32 +DO NOT use this module on Red Hat systems, as Red Hat systems should use the
33 33 rh_service module, since red hat systems support chkconfig
34 34 '''
35 35 # Import Python libs
@@ -100,9 +100,7 @@ def _service_is_sysv(name):
100 100 executable, like README or skeleton.
101 101 '''
102 102 script = '/etc/init.d/{0}'.format(name)
103   - if not _is_symlink(script):
104   - return os.access(script, os.X_OK)
105   - return False
  103 + return not _service_is_upstart(name) and os.access(script, os.X_OK)
106 104
107 105
108 106 def _sysv_is_disabled(name):
@@ -122,6 +120,23 @@ def _sysv_is_enabled(name):
122 120 return not _sysv_is_disabled(name)
123 121
124 122
  123 +def _iter_service_names():
  124 + '''
  125 + Detect all of the service names available to upstart via init configuration
  126 + files and via classic sysv init scripts
  127 + '''
  128 + found = set()
  129 + for line in glob.glob('/etc/init.d/*'):
  130 + name = os.path.basename(line)
  131 + found.add(name)
  132 + yield name
  133 + for line in glob.glob('/etc/init/*.conf'):
  134 + name = os.path.basename(line)[:-5]
  135 + if name in found:
  136 + continue
  137 + yield name
  138 +
  139 +
125 140 def get_enabled():
126 141 '''
127 142 Return the enabled services
@@ -131,8 +146,7 @@ def get_enabled():
131 146 salt '*' service.get_enabled
132 147 '''
133 148 ret = set()
134   - for line in glob.glob('/etc/init.d/*'):
135   - name = os.path.basename(line)
  149 + for name in _iter_service_names():
136 150 if _service_is_upstart(name):
137 151 if _upstart_is_enabled(name):
138 152 ret.add(name)
@@ -152,8 +166,7 @@ def get_disabled():
152 166 salt '*' service.get_disabled
153 167 '''
154 168 ret = set()
155   - for line in glob.glob('/etc/init.d/*'):
156   - name = os.path.basename(line)
  169 + for name in _iter_service_names():
157 170 if _service_is_upstart(name):
158 171 if _upstart_is_disabled(name):
159 172 ret.add(name)

0 comments on commit 396d404

Please sign in to comment.
Something went wrong with that request. Please try again.