|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
# Copyright (C) 2018-2019 Intel Corporation
|
|
|
|
|
# Copyright (C) 2018-2020 Intel Corporation
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
@ -50,10 +50,22 @@ def generate_ssh_keys():
|
|
|
|
|
ssh_dir = '{}/.ssh'.format(os.getenv('HOME'))
|
|
|
|
|
pidfile = os.path.join(ssh_dir, 'ssh.pid')
|
|
|
|
|
|
|
|
|
|
def add_ssh_keys():
|
|
|
|
|
IGNORE_FILES = ('README.md', 'ssh.pid')
|
|
|
|
|
keys_to_add = [entry.name for entry in os.scandir(ssh_dir) if entry.name not in IGNORE_FILES]
|
|
|
|
|
keys_to_add = ' '.join(os.path.join(ssh_dir, f) for f in keys_to_add)
|
|
|
|
|
subprocess.run(['ssh-add {}'.format(keys_to_add)],
|
|
|
|
|
shell = True,
|
|
|
|
|
stderr = subprocess.PIPE,
|
|
|
|
|
# lets set the timeout if ssh-add requires a input passphrase for key
|
|
|
|
|
# otherwise the process will be freezed
|
|
|
|
|
timeout=30,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
with open(pidfile, "w") as pid:
|
|
|
|
|
fcntl.flock(pid, fcntl.LOCK_EX)
|
|
|
|
|
try:
|
|
|
|
|
subprocess.run(['ssh-add {}/*'.format(ssh_dir)], shell = True, stderr = subprocess.PIPE)
|
|
|
|
|
add_ssh_keys()
|
|
|
|
|
keys = subprocess.run(['ssh-add -l'], shell = True,
|
|
|
|
|
stdout = subprocess.PIPE).stdout.decode('utf-8').split('\n')
|
|
|
|
|
if 'has no identities' in keys[0]:
|
|
|
|
|
@ -440,3 +452,4 @@ CACHES = {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USE_CACHE = True
|
|
|
|
|
|
|
|
|
|
|