diff options
author | Timo Weingärtner <timo@tiwe.de> | 2021-07-19 13:35:16 +0200 |
---|---|---|
committer | Timo Weingärtner <timo@tiwe.de> | 2021-07-19 13:35:16 +0200 |
commit | 53614d19826293d753aad599f2b2900d8d6303ed (patch) | |
tree | 8404704b4a7b42dd1cef8e2ced899c5174ac178b | |
parent | 265011411069c0c26dd693f714a43a6c7e6ad9ea (diff) | |
download | openssh-known-hosts-53614d19826293d753aad599f2b2900d8d6303ed.tar.gz |
factor out download_source()
-rwxr-xr-x | update-openssh-known-hosts | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/update-openssh-known-hosts b/update-openssh-known-hosts index c8f7e39..325a997 100755 --- a/update-openssh-known-hosts +++ b/update-openssh-known-hosts @@ -52,6 +52,36 @@ cleanup () { lockfile-remove "${LOCK}" } +download_source () ( + local sourcename=$1 + local sourcefile=$2 + + cd "${CACHEDIR}/${sourcename}" + set -a + . "${sourcefile}" + set +a + # shellcheck disable=SC2091 + $(path_search "$PLUGIN" "$PLUGIN_PATH") >| log 2>&1 || { + exitcode=$? + rm -f new + ignore='' + for e in ${EXIT_IGNORE:-0}; do + if [[ $e = "$exitcode" ]]; then + ignore=1 + break + fi + done + if [ -z "$ignore" ] || [ "$fail" ]; then + echo "${source} exited with code ${exitcode}, log follows:" + cat log + echo + fi + if [ "$fail" ]; then + exit 1 + fi + } >&2 +) + if [ $# -eq 1 ] && [ "$1" = "-f" ]; then fail=1 else @@ -72,30 +102,7 @@ find -mindepth 2 -maxdepth 2 -type f -name new -delete run-parts --list "${CONFDIR}/sources/" | while read sourcefile; do source=${sourcefile##*/} mkdir -p "${source}" - ( - set -a - cd "${source}" - . "${sourcefile}" - $(path_search "$PLUGIN" "$PLUGIN_PATH") >| log 2>&1 || { - exitcode=$? - rm -f new - ignore='' - for e in ${EXIT_IGNORE:-0}; do - if [[ $e = "$exitcode" ]]; then - ignore=1 - break - fi - done - if [ -z "$ignore" -o "$fail" ]; then - echo "${source} exited with code ${exitcode}, log follows:" - cat log - echo - fi - if [ "$fail" ]; then - exit 1 - fi - } >&2 - ) || exit 1 + download_source "${source}" "${sourcefile}" if [ -e "${source}/new" ]; then mv "${source}/new" "${source}/current" fi |