From 6bbe478ef1beb45f9606913d4b3ad4429dac78a7 Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Mon, 22 Aug 2022 16:19:14 +0200 Subject: [PATCH] support multiple sources --- rsync/entrypoint.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rsync/entrypoint.sh b/rsync/entrypoint.sh index a5f4186..f73bc09 100644 --- a/rsync/entrypoint.sh +++ b/rsync/entrypoint.sh @@ -20,9 +20,10 @@ fi KNOWN_HOSTS="${KNOWN_HOSTS:=${PLUGIN_KNOWN_HOSTS}}" -SOURCE="${SOURCE:-${PLUGIN_SOURCE}}" -if [ -z "$SOURCE" ]; then - echo "'source' must be specified" +SOURCES="${SOURCES:-${PLUGIN_SOURCES}}" +SOURCES=$(echo "$SOURCES" | tr ',' ' ') +if [ -z "$SOURCES" ]; then + echo "specify at least one source" exit 1 fi @@ -48,4 +49,7 @@ known_hosts_file="${HOME}/.ssh/known_hosts" # run rsync # shellcheck disable=SC2086 -exec rsync $ARGS "${SOURCE}" "${USER}"@"${HOST}":"${TARGET}" +for SOURCE in $SOURCES; do + echo "copying '$SOURCE' to '$TARGET'" + rsync $ARGS "${SOURCE}" "${USER}"@"${HOST}":"${TARGET}" +done