summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xupdate-openssh-known-hosts55
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