mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Some distros do not seem to have a /lib/systemd, but do have a /usr/lib/systemd
This commit is contained in:
parent
8d0498eff4
commit
8f0e866f1b
1 changed files with 10 additions and 9 deletions
|
@ -26,7 +26,7 @@ __func_alias__ = {
|
|||
'reload_': 'reload'
|
||||
}
|
||||
|
||||
SYSTEM_CONFIG_PATH = '/lib/systemd/system'
|
||||
SYSTEM_CONFIG_PATHS = ('/lib/systemd/system', '/usr/lib/systemd/system')
|
||||
LOCAL_CONFIG_PATH = '/etc/systemd/system'
|
||||
INITSCRIPT_PATH = '/etc/init.d'
|
||||
VALID_UNIT_TYPES = ('service', 'socket', 'device', 'mount', 'automount',
|
||||
|
@ -147,14 +147,15 @@ def _get_systemd_services():
|
|||
if contextkey in __context__:
|
||||
return __context__[contextkey]
|
||||
ret = set()
|
||||
for path in (SYSTEM_CONFIG_PATH, LOCAL_CONFIG_PATH):
|
||||
for fullname in os.listdir(path):
|
||||
try:
|
||||
unit_name, unit_type = fullname.rsplit('.', 1)
|
||||
except ValueError:
|
||||
continue
|
||||
if unit_type in VALID_UNIT_TYPES:
|
||||
ret.add(unit_name if unit_type == 'service' else fullname)
|
||||
for path in SYSTEM_CONFIG_PATHS + LOCAL_CONFIG_PATH:
|
||||
if os.access(path, os.R_OK):
|
||||
for fullname in os.listdir(path):
|
||||
try:
|
||||
unit_name, unit_type = fullname.rsplit('.', 1)
|
||||
except ValueError:
|
||||
continue
|
||||
if unit_type in VALID_UNIT_TYPES:
|
||||
ret.add(unit_name if unit_type == 'service' else fullname)
|
||||
__context__[contextkey] = copy.deepcopy(ret)
|
||||
return ret
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue