mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Adds support for nested upstart scripts in the form of subfolder/service. This is implemented via an os.walk through the /etc/init folder, rather than the previous glob for *.conf method.
Fixes #26478 - nested upstart services are not supported
This commit is contained in:
parent
10b5728f84
commit
89d9cd5e38
@ -45,6 +45,7 @@ import glob
|
||||
import os
|
||||
import re
|
||||
import itertools
|
||||
import fnmatch
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
@ -226,11 +227,24 @@ def _iter_service_names():
|
||||
name = os.path.basename(line)
|
||||
found.add(name)
|
||||
yield name
|
||||
for line in glob.glob('/etc/init/*.conf'):
|
||||
name = os.path.basename(line)[:-5]
|
||||
if name in found:
|
||||
continue
|
||||
yield name
|
||||
|
||||
# This walk method supports nested services as per the init man page
|
||||
# definition 'For example a configuration file /etc/init/rc-sysinit.conf
|
||||
# is named rc-sysinit, while a configuration file /etc/init/net/apache.conf
|
||||
# is named net/apache'
|
||||
init_root = '/etc/init/'
|
||||
for root, dirnames, filenames in os.walk(init_root):
|
||||
relpath = os.path.relpath(root, init_root)
|
||||
for filename in fnmatch.filter(filenames, '*.conf'):
|
||||
if relpath == '.':
|
||||
# service is defined in the root, no need to append prefix.
|
||||
name = filename[:-5]
|
||||
else:
|
||||
# service is nested, append its relative path prefix.
|
||||
name = os.path.join(relpath, filename[:-5])
|
||||
if name in found:
|
||||
continue
|
||||
yield name
|
||||
|
||||
|
||||
def get_enabled():
|
||||
|
Loading…
Reference in New Issue
Block a user