From 67d2e93c4ddbafd5c79bef22d1317e305aa40371 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Mon, 23 Nov 2020 22:46:21 +0100 Subject: [PATCH] Check setup when using integration endpoint Public upload urls cannot be checked like that currently. --- tools/consumedir.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/consumedir.sh b/tools/consumedir.sh index 47a8882c..e15faae6 100755 --- a/tools/consumedir.sh +++ b/tools/consumedir.sh @@ -324,6 +324,35 @@ findDir() { done } +checkSetup() { + for dir in "${watchdir[@]}"; do + find "$dir" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -d '' -r collective; do + for url in $urls; do + if [ "$integration" = "y" ]; then + url="$url/$(basename $collective)" + OPTS="$CURL_OPTS -i -s -o /dev/null -w %{http_code}" + if [ $iuser ]; then + OPTS="$OPTS --user $iuser" + fi + if [ $iheader ]; then + OPTS="$OPTS -H $iheader" + fi + trace "Checking integration endpoint: $CURL_CMD $OPTS "$url"" + status=$($CURL_CMD $OPTS "$url") + if [ "$status" != "200" ]; then + echo "[ERROR] $status response integration endpoint: $CURL_CMD $OPTS $url" + exit 1 + fi + fi + done + done + done +} + + +# quit here if something is not correctly configured +checkSetup + if [ "$once" = "y" ]; then info "Uploading all files in '$watchdir'." MD="-maxdepth 1"