make the show-status script fail on errors

This commit is contained in:
Sebastian
2025-03-18 06:02:34 +01:00
parent 57f5091dcd
commit 228d527af3

View File

@@ -1,3 +1,4 @@
#!/bin/bash #!/bin/bash
BASEPATH="$(dirname "$0")" BASEPATH="$(dirname "$0")"
@@ -7,39 +8,41 @@ IFS=':' read -ra parts <<< $COMPOSE_FILE
blacklist=("drpc.yml" "drpc-free.yml" "base.yml" "rpc.yml" "monitoring.yml" "ftp.yml" "backup-http.yml") blacklist=("drpc.yml" "drpc-free.yml" "base.yml" "rpc.yml" "monitoring.yml" "ftp.yml" "backup-http.yml")
# Flag to track if any invocation failed
any_failure=false
for part in "${parts[@]}"; do for part in "${parts[@]}"; do
include=true include=true
for word in "${blacklist[@]}"; do for word in "${blacklist[@]}"; do
if echo "$part" | grep -qE "$word"; then if echo "$part" | grep -qE "$word"; then
#echo "The path $path contains a blacklisted word: $word" include=false
include=false fi
fi
done done
# Check if any parameters were passed # Check if any parameters were passed
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
# Put parameters into an array (list) # Put parameters into an array (list)
params=("$@") params=("$@")
# Check if a string is part of the list # Check if a string is part of the list
if [[ " ${params[@]} " =~ " ${part%.yml} " ]]; then if [[ " ${params[@]} " =~ " $1 " ]]; then
include=$include # don't change anything include=$include # don't change anything
else else
include=false include=false
fi fi
fi fi
if $include; then if $include; then
result=$($BASEPATH/sync-status.sh "${part%.yml}") result=$($BASEPATH/sync-status.sh "${part%.yml}")
#if [ "$1" = "${part%.yml}" ]; then if [ $? -ne 0 ]; then
# echo "${result}" any_failure=true
# exit 0 fi
#else
echo "${part%.yml}: $result" echo "${part%.yml}: $result"
#fi
fi fi
done done
# If any invocation failed, return a failure exit code
if $any_failure; then
exit 1
fi