use ssh key file

This commit is contained in:
trnq1ll0 committed 2026-03-08 19:26:53 +01:00
1 parent 5707598046
commit 6b0776003d
3 files changed
+30 -2

No files matched your search

+20 -1
View File
@@ -37,6 +37,18 @@ for var in "${required_vars[@]}"; do
fi
done
if [[ -z "${RSYNC_RSH:-}" && -z "${SSH_KEY_FILE:-}" ]]; then
echo "Missing SSH config: set SSH_KEY_FILE or RSYNC_RSH" >&2
exit 1
fi
if [[ -n "${SSH_KEY_FILE:-}" && ! -r "$SSH_KEY_FILE" ]]; then
echo "SSH key file not readable: $SSH_KEY_FILE" >&2
exit 1
fi
mkdir -p "$RSYNC_TARGET_DIR"
repo_abs="$(cd "$RSYNC_TARGET_DIR" && pwd)"
rel_target="."
@@ -50,7 +62,14 @@ git_target() {
}
if [[ -n "${RSYNC_RSH:-}" ]]; then
rsync -az --delete -e "$RSYNC_RSH" "$RSYNC_SOURCE" "$repo_abs/"
rsync_rsh="$RSYNC_RSH"
else
ssh_options="${SSH_OPTIONS:--o IdentitiesOnly=yes -o StrictHostKeyChecking=yes}"
rsync_rsh="ssh -i $SSH_KEY_FILE $ssh_options"
fi
if [[ -n "${rsync_rsh:-}" ]]; then
rsync -az --delete -e "$rsync_rsh" "$RSYNC_SOURCE" "$repo_abs/"
else
rsync -az --delete "$RSYNC_SOURCE" "$repo_abs/"
fi