diff --git a/deploy/apptainer/qc.sh b/deploy/apptainer/qc.sh index 21d28a0..40fb1c8 100755 --- a/deploy/apptainer/qc.sh +++ b/deploy/apptainer/qc.sh @@ -248,10 +248,11 @@ restore_hint() { # list earlier data sets next to $QC_DATA (from --rebuild-data for d in $(ls -1dt "$QC_DATA".* 2>/dev/null); do [[ -f "$d/universe/universe.csv" ]] || continue if [[ $n == 0 ]]; then say " earlier data sets found (newest first):"; fi - when="$(grep -o '"setup_at": *"[^"]*"' "$d/manifest.json" 2>/dev/null | head -n 1 | sed 's/.*"\([^"]*\)"$/\1/')" + when="$(grep -o '"setup_at": *"[^"]*"' "$d/manifest.json" 2>/dev/null | head -n 1 | sed 's/.*"\([^"]*\)"$/\1/' || true)" stocks=$(( $(wc -l < "$d/universe/universe.csv") - 1 )) say " $d ($stocks stocks, built ${when:-?})" - n=$((n + 1)); [[ $n -ge 4 ]] && break + n=$((n + 1)) + if [[ $n -ge 4 ]]; then break; fi done if [[ $n -gt 0 ]]; then say " restore one with: $0 data-import "; fi } @@ -534,8 +535,9 @@ cmd_status() { step "API $QC_API_URL" if h="$(http_get "$QC_API_URL/health")"; then local api_setup host_setup - api_setup="$(printf '%s' "$h" | grep -o '"setup_at":"[^"]*"' | head -n 1)" - host_setup="$(grep -o '"setup_at": *"[^"]*"' "$QC_DATA/manifest.json" 2>/dev/null | head -n 1 | tr -d ' ')" + # `|| true`: under pipefail a grep without a match would end the script silently + api_setup="$(printf '%s' "$h" | grep -o '"setup_at":"[^"]*"' | head -n 1 || true)" + host_setup="$(grep -o '"setup_at": *"[^"]*"' "$QC_DATA/manifest.json" 2>/dev/null | head -n 1 | tr -d ' ' || true)" if [[ "$api_setup" != "$host_setup" ]]; then warn "the running API serves a different data set than $QC_DATA (API ${api_setup:-none}, folder ${host_setup:-none}). Run: $0 restart"