mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
parent
af297bb0ae
commit
5a93b7e53c
1 changed files with 11 additions and 12 deletions
|
@ -153,23 +153,22 @@ def _sysv_is_enabled(name, runlevel=None):
|
|||
|
||||
def _chkconfig_is_enabled(name, runlevel=None):
|
||||
'''
|
||||
Return True if the service is enabled according to chkconfig; otherwise
|
||||
return False. If `runlevel` is None, then use the current runlevel.
|
||||
Return ``True`` if the service is enabled according to chkconfig; otherwise
|
||||
return ``False``. If ``runlevel`` is ``None``, then use the current
|
||||
runlevel.
|
||||
'''
|
||||
cmdline = '/sbin/chkconfig --list {0}'.format(name)
|
||||
result = __salt__['cmd.run_all'](cmdline, python_shell=False)
|
||||
|
||||
if runlevel is None:
|
||||
runlevel = _runlevel()
|
||||
if result['retcode'] == 0:
|
||||
cols = result['stdout'].splitlines()[0].split()
|
||||
try:
|
||||
if cols[0].strip(':') == name:
|
||||
if runlevel is None:
|
||||
runlevel = _runlevel()
|
||||
if len(cols) > 3 and '{0}:on'.format(runlevel) in cols:
|
||||
for row in result['stdout'].splitlines():
|
||||
if '{0}:on'.format(runlevel) in row:
|
||||
if row.split()[0] == name:
|
||||
return True
|
||||
elif len(cols) < 3 and cols[1] and cols[1] == 'on':
|
||||
return True
|
||||
except IndexError:
|
||||
pass
|
||||
elif row.split() == [name + ':', 'on']:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue