mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes _find_binaries not using globals
_find_binaries now sets the right globals Binaries are now properly populated (reverse path/binary for loops)
This commit is contained in:
parent
572868c9e1
commit
a7e4da92db
1 changed files with 8 additions and 8 deletions
|
@ -41,6 +41,8 @@ def fail_json(d):
|
|||
def _find_binaries():
|
||||
# list of possible paths for service/chkconfig binaries
|
||||
# with the most probable first
|
||||
global CHKCONFIG
|
||||
global SERVICE
|
||||
paths = ['/sbin', '/usr/sbin', '/bin', '/usr/bin']
|
||||
binaries = [ 'service', 'chkconfig', 'update-rc.d' ]
|
||||
location = dict()
|
||||
|
@ -48,26 +50,24 @@ def _find_binaries():
|
|||
for binary in binaries:
|
||||
location[binary] = None
|
||||
|
||||
for path in paths:
|
||||
for binary in binaries:
|
||||
for binary in binaries:
|
||||
for path in paths:
|
||||
if os.path.exists(path + '/' + binary):
|
||||
location[binary] = path + '/' + binary
|
||||
break
|
||||
|
||||
|
||||
|
||||
if location.get('chkconfig', None):
|
||||
CHKCONFIG = location['chkconfig']
|
||||
elif location.get('update-rc.d', None):
|
||||
CHKCONFIG = location['update-rc.d']
|
||||
else:
|
||||
fail_json(dict(failed=True, msg='unable to find chkconfig or update-rc.d binary'))
|
||||
|
||||
if location.get('service', None):
|
||||
SERVICE = location['service']
|
||||
else:
|
||||
fail_json(dict(failed=True, msg='unable to find service binary'))
|
||||
|
||||
|
||||
def _run(cmd):
|
||||
# returns (rc, stdout, stderr) from shell command
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
|
|
Loading…
Reference in a new issue