From 6c2deb92f55e982ad9c0cb74d378ee10a52c8d31 Mon Sep 17 00:00:00 2001 From: snickerjp Date: Wed, 31 Dec 2025 16:42:43 +0000 Subject: [PATCH 1/8] Add clean progress indication with --debug option Replace cluttered Docker Compose progress output with clean dot-based progress indication by default. Add --debug (-g) option to show detailed Docker progress when needed. Default behavior: - Shows user-friendly messages with dot progress - Clean terminal output Debug mode (--debug): - Shows full Docker Compose progress output - Useful for troubleshooting installation issues --- setup.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 9aa22a26..f5aa8ccd 100755 --- a/setup.sh +++ b/setup.sh @@ -9,6 +9,7 @@ OVERWRITE=no PREVIEW=no REDASH_VERSION="" COMPOSE_WRAPPER_DEFINED=no +DEBUG=no # Ensure the script is being run as root ID=$(id -u) @@ -52,7 +53,7 @@ elif [ ! -f /etc/os-release ]; then fi # Parse any user provided parameters -opts="$(getopt -o doph -l dont-start,overwrite,preview,help,version: --name "$0" -- "$@")" +opts="$(getopt -o dophg -l dont-start,overwrite,preview,help,debug,version: --name "$0" -- "$@")" eval set -- "$opts" while true; do @@ -69,13 +70,18 @@ while true; do PREVIEW=yes shift ;; + -g | --debug) + DEBUG=yes + shift + ;; --version) REDASH_VERSION="$2" shift 2 ;; -h | --help) - echo "Redash setup script usage: $0 [-d|--dont-start] [-p|--preview] [-o|--overwrite] [--version ]" + echo "Redash setup script usage: $0 [-d|--dont-start] [-p|--preview] [-g|--debug] [-o|--overwrite] [--version ]" echo " The --preview (also -p) option uses the Redash 'preview' Docker image instead of the last stable release" + echo " The --debug (also -g) option shows detailed Docker progress output instead of clean progress dots" echo " The --version option installs the specified version tag of Redash (e.g., 10.1.0)" echo " The --overwrite (also -o) option replaces any existing configuration with a fresh new install" echo " The --dont-start (also -d) option installs Redash, but doesn't automatically start it afterwards" @@ -335,10 +341,28 @@ startup() { echo "** Starting Redash **" echo "*********************" echo "** Initialising Redash database **" - docker_compose run --rm server create_db + if [ "$DEBUG" = "yes" ]; then + docker_compose run --rm server create_db + else + printf "Downloading images" + docker_compose pull > /dev/null 2>&1 & + PID=$! + while kill -0 $PID 2>/dev/null; do + printf "." + sleep 2 + done + echo " Done!" + echo "Creating database..." + docker_compose run --rm server create_db + fi echo "** Starting the rest of Redash **" - docker_compose up -d + if [ "$DEBUG" = "yes" ]; then + docker_compose up -d + else + echo "Starting containers..." + docker_compose up -d + fi echo echo "Redash has been installed and is ready for configuring at http://$(hostname -f):5000" From f6bd94240702690075fb51274502daf3ca7cfd83 Mon Sep 17 00:00:00 2001 From: snickerjp Date: Wed, 31 Dec 2025 16:43:08 +0000 Subject: [PATCH 2/8] Add error handling with debug mode suggestion When installation fails in default (clean) mode, show a helpful error message suggesting users run with --debug flag for detailed output. Features: - Clear error indication with emoji - Actionable troubleshooting advice - Maintains clean UX while providing debugging path - Applied to critical Docker Compose operations This helps users quickly identify and resolve installation issues. --- setup.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index f5aa8ccd..0a58f453 100755 --- a/setup.sh +++ b/setup.sh @@ -11,6 +11,17 @@ REDASH_VERSION="" COMPOSE_WRAPPER_DEFINED=no DEBUG=no +# Error handling function +handle_error() { + if [ "$DEBUG" != "yes" ]; then + echo + echo "❌ An error occurred during installation." + echo "💡 For detailed output, please run: $0 --debug" + echo + fi + exit 1 +} + # Ensure the script is being run as root ID=$(id -u) if [ "0$ID" -ne 0 ]; then @@ -342,7 +353,7 @@ startup() { echo "*********************" echo "** Initialising Redash database **" if [ "$DEBUG" = "yes" ]; then - docker_compose run --rm server create_db + docker_compose run --rm server create_db || handle_error else printf "Downloading images" docker_compose pull > /dev/null 2>&1 & @@ -351,17 +362,21 @@ startup() { printf "." sleep 2 done + wait $PID || { + echo " Failed!" + handle_error + } echo " Done!" echo "Creating database..." - docker_compose run --rm server create_db + docker_compose run --rm server create_db || handle_error fi echo "** Starting the rest of Redash **" if [ "$DEBUG" = "yes" ]; then - docker_compose up -d + docker_compose up -d || handle_error else echo "Starting containers..." - docker_compose up -d + docker_compose up -d || handle_error fi echo From 2486d9d65571749515ee6d363c90fa58c99362b3 Mon Sep 17 00:00:00 2001 From: snickerjp Date: Wed, 31 Dec 2025 17:05:44 +0000 Subject: [PATCH 3/8] Fix Copilot review issues: process leaks and error handling Address all 6 issues identified in Copilot review: 1. Add signal traps to prevent process leaks on interruption 2. Fix race condition in exit status handling with explicit STATUS check 3. Apply consistent progress suppression to database creation step 4. Suppress docker compose up output in non-debug mode for consistency 5. Use consistent comparison operators (x = xyes pattern) 6. Preserve error messages using temporary files while suppressing progress Key improvements: - Robust background process management with proper cleanup - Complete progress output suppression in clean mode - Error details automatically shown on failure (--debug less critical) - Maintains clean UX while providing excellent troubleshooting info --- setup.sh | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/setup.sh b/setup.sh index 0a58f453..4b5f41aa 100755 --- a/setup.sh +++ b/setup.sh @@ -13,7 +13,7 @@ DEBUG=no # Error handling function handle_error() { - if [ "$DEBUG" != "yes" ]; then + if [ "x$DEBUG" != "xyes" ]; then echo echo "❌ An error occurred during installation." echo "💡 For detailed output, please run: $0 --debug" @@ -352,31 +352,63 @@ startup() { echo "** Starting Redash **" echo "*********************" echo "** Initialising Redash database **" - if [ "$DEBUG" = "yes" ]; then + if [ "x$DEBUG" = "xyes" ]; then docker_compose run --rm server create_db || handle_error else printf "Downloading images" - docker_compose pull > /dev/null 2>&1 & + ERROR_LOG=$(mktemp) + docker_compose pull >/dev/null 2>"$ERROR_LOG" & PID=$! - while kill -0 $PID 2>/dev/null; do + trap 'kill "$PID" 2>/dev/null || true; rm -f "$ERROR_LOG"' EXIT INT TERM + while kill -0 "$PID" 2>/dev/null; do printf "." sleep 2 done - wait $PID || { + wait "$PID" + STATUS=$? + trap - EXIT INT TERM + if [ "$STATUS" -ne 0 ]; then echo " Failed!" + if [ -s "$ERROR_LOG" ]; then + echo "Error details:" + cat "$ERROR_LOG" + fi + rm -f "$ERROR_LOG" handle_error - } + fi + rm -f "$ERROR_LOG" + echo " Done!" + printf "Creating database" + ERROR_LOG=$(mktemp) + docker_compose run --rm server create_db >/dev/null 2>"$ERROR_LOG" & + PID=$! + trap 'kill "$PID" 2>/dev/null || true; rm -f "$ERROR_LOG"' EXIT INT TERM + while kill -0 "$PID" 2>/dev/null; do + printf "." + sleep 2 + done + wait "$PID" + STATUS=$? + trap - EXIT INT TERM + if [ "$STATUS" -ne 0 ]; then + echo " Failed!" + if [ -s "$ERROR_LOG" ]; then + echo "Error details:" + cat "$ERROR_LOG" + fi + rm -f "$ERROR_LOG" + handle_error + fi + rm -f "$ERROR_LOG" echo " Done!" - echo "Creating database..." - docker_compose run --rm server create_db || handle_error fi echo "** Starting the rest of Redash **" - if [ "$DEBUG" = "yes" ]; then + if [ "x$DEBUG" = "xyes" ]; then docker_compose up -d || handle_error else echo "Starting containers..." - docker_compose up -d || handle_error + docker_compose up -d >/dev/null 2>&1 || handle_error fi echo From fb3ed28d18b4728a2fb66249c53c9c18c5792636 Mon Sep 17 00:00:00 2001 From: snickerjp Date: Wed, 31 Dec 2025 17:11:55 +0000 Subject: [PATCH 4/8] Fix inconsistent error handling for docker compose up Address cubic-dev-ai feedback: docker compose up -d now captures and displays error details consistently with other docker operations. Previously: - docker compose pull/run: captured errors to temp file, displayed details - docker compose up -d: discarded all error output (>/dev/null 2>&1) Now all docker operations consistently capture and display error details while maintaining clean progress output in non-debug mode. --- setup.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 4b5f41aa..fa1f834b 100755 --- a/setup.sh +++ b/setup.sh @@ -408,7 +408,16 @@ startup() { docker_compose up -d || handle_error else echo "Starting containers..." - docker_compose up -d >/dev/null 2>&1 || handle_error + ERROR_LOG=$(mktemp) + if ! docker_compose up -d >/dev/null 2>"$ERROR_LOG"; then + if [ -s "$ERROR_LOG" ]; then + echo "Error details:" + cat "$ERROR_LOG" + fi + rm -f "$ERROR_LOG" + handle_error + fi + rm -f "$ERROR_LOG" fi echo From 10ec6b80bf1180e6d91d6ed73dc55b8b72cd7f7d Mon Sep 17 00:00:00 2001 From: snickerjp Date: Wed, 31 Dec 2025 17:16:10 +0000 Subject: [PATCH 5/8] Refactor: extract common progress pattern into reusable function Address Copilot feedback on code duplication: - Extract repeated progress display pattern into run_with_progress() function - Eliminates 40+ lines of duplicated code between pull and create_db operations - Fixes ERROR_LOG variable reuse issue with proper scoping - Improves maintainability and reduces bug risk - Each operation now uses independent ERROR_LOG variables This refactoring maintains identical functionality while significantly improving code quality and maintainability. --- setup.sh | 78 +++++++++++++++++++++++--------------------------------- 1 file changed, 32 insertions(+), 46 deletions(-) diff --git a/setup.sh b/setup.sh index fa1f834b..c0eb95a4 100755 --- a/setup.sh +++ b/setup.sh @@ -22,6 +22,36 @@ handle_error() { exit 1 } +# Background process with progress dots +run_with_progress() { + local message="$1" + local command="$2" + + printf "%s" "$message" + ERROR_LOG=$(mktemp) + eval "$command" >/dev/null 2>"$ERROR_LOG" & + PID=$! + trap 'kill "$PID" 2>/dev/null || true; rm -f "$ERROR_LOG"' EXIT INT TERM + while kill -0 "$PID" 2>/dev/null; do + printf "." + sleep 2 + done + wait "$PID" + STATUS=$? + trap - EXIT INT TERM + if [ "$STATUS" -ne 0 ]; then + echo " Failed!" + if [ -s "$ERROR_LOG" ]; then + echo "Error details:" + cat "$ERROR_LOG" + fi + rm -f "$ERROR_LOG" + handle_error + fi + rm -f "$ERROR_LOG" + echo " Done!" +} + # Ensure the script is being run as root ID=$(id -u) if [ "0$ID" -ne 0 ]; then @@ -355,52 +385,8 @@ startup() { if [ "x$DEBUG" = "xyes" ]; then docker_compose run --rm server create_db || handle_error else - printf "Downloading images" - ERROR_LOG=$(mktemp) - docker_compose pull >/dev/null 2>"$ERROR_LOG" & - PID=$! - trap 'kill "$PID" 2>/dev/null || true; rm -f "$ERROR_LOG"' EXIT INT TERM - while kill -0 "$PID" 2>/dev/null; do - printf "." - sleep 2 - done - wait "$PID" - STATUS=$? - trap - EXIT INT TERM - if [ "$STATUS" -ne 0 ]; then - echo " Failed!" - if [ -s "$ERROR_LOG" ]; then - echo "Error details:" - cat "$ERROR_LOG" - fi - rm -f "$ERROR_LOG" - handle_error - fi - rm -f "$ERROR_LOG" - echo " Done!" - printf "Creating database" - ERROR_LOG=$(mktemp) - docker_compose run --rm server create_db >/dev/null 2>"$ERROR_LOG" & - PID=$! - trap 'kill "$PID" 2>/dev/null || true; rm -f "$ERROR_LOG"' EXIT INT TERM - while kill -0 "$PID" 2>/dev/null; do - printf "." - sleep 2 - done - wait "$PID" - STATUS=$? - trap - EXIT INT TERM - if [ "$STATUS" -ne 0 ]; then - echo " Failed!" - if [ -s "$ERROR_LOG" ]; then - echo "Error details:" - cat "$ERROR_LOG" - fi - rm -f "$ERROR_LOG" - handle_error - fi - rm -f "$ERROR_LOG" - echo " Done!" + run_with_progress "Downloading images" "docker_compose pull" + run_with_progress "Creating database" "docker_compose run --rm server create_db" fi echo "** Starting the rest of Redash **" From 4f2d4fe2aa84a42582ec60496235eeb8faa9d508 Mon Sep 17 00:00:00 2001 From: snickerjp Date: Wed, 31 Dec 2025 17:17:01 +0000 Subject: [PATCH 6/8] Fix help text order and script name reference issues Address remaining Copilot feedback: - Reorder help text to match usage line order for better readability - Capture script name at startup to handle symlinks and different invocations - Use SCRIPT_NAME variable in error messages and help text for consistency These improvements enhance user experience and ensure correct script references regardless of how the script is invoked. --- setup.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index c0eb95a4..3995b16d 100755 --- a/setup.sh +++ b/setup.sh @@ -10,13 +10,14 @@ PREVIEW=no REDASH_VERSION="" COMPOSE_WRAPPER_DEFINED=no DEBUG=no +SCRIPT_NAME="$0" # Error handling function handle_error() { if [ "x$DEBUG" != "xyes" ]; then echo echo "❌ An error occurred during installation." - echo "💡 For detailed output, please run: $0 --debug" + echo "💡 For detailed output, please run: $SCRIPT_NAME --debug" echo fi exit 1 @@ -120,12 +121,12 @@ while true; do shift 2 ;; -h | --help) - echo "Redash setup script usage: $0 [-d|--dont-start] [-p|--preview] [-g|--debug] [-o|--overwrite] [--version ]" + echo "Redash setup script usage: $SCRIPT_NAME [-d|--dont-start] [-p|--preview] [-g|--debug] [-o|--overwrite] [--version ]" + echo " The --dont-start (also -d) option installs Redash, but doesn't automatically start it afterwards" echo " The --preview (also -p) option uses the Redash 'preview' Docker image instead of the last stable release" echo " The --debug (also -g) option shows detailed Docker progress output instead of clean progress dots" - echo " The --version option installs the specified version tag of Redash (e.g., 10.1.0)" echo " The --overwrite (also -o) option replaces any existing configuration with a fresh new install" - echo " The --dont-start (also -d) option installs Redash, but doesn't automatically start it afterwards" + echo " The --version option installs the specified version tag of Redash (e.g., 10.1.0)" exit 1 ;; --) From 0443dacc245e091728600d806deb23ff2d3cb274 Mon Sep 17 00:00:00 2001 From: snickerjp Date: Wed, 31 Dec 2025 17:24:52 +0000 Subject: [PATCH 7/8] Fix POSIX compliance: remove local keyword Address cubic-dev-ai feedback on POSIX compliance: - Remove 'local' keyword which is a bashism, not POSIX-compliant - Use unique variable names (RWP_MESSAGE, RWP_COMMAND) instead - Maintains compatibility with strict POSIX shells - Script continues to use #!/usr/bin/env sh as intended This ensures the script works on all POSIX-compliant shells, not just bash and dash. --- setup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 3995b16d..692ab0af 100755 --- a/setup.sh +++ b/setup.sh @@ -25,12 +25,12 @@ handle_error() { # Background process with progress dots run_with_progress() { - local message="$1" - local command="$2" + RWP_MESSAGE="$1" + RWP_COMMAND="$2" - printf "%s" "$message" + printf "%s" "$RWP_MESSAGE" ERROR_LOG=$(mktemp) - eval "$command" >/dev/null 2>"$ERROR_LOG" & + eval "$RWP_COMMAND" >/dev/null 2>"$ERROR_LOG" & PID=$! trap 'kill "$PID" 2>/dev/null || true; rm -f "$ERROR_LOG"' EXIT INT TERM while kill -0 "$PID" 2>/dev/null; do From 178fa9fa83a62ce0fc51d05d800e762bbb167234 Mon Sep 17 00:00:00 2001 From: snickerjp Date: Sun, 8 Mar 2026 01:39:50 +0900 Subject: [PATCH 8/8] Address Copilot review: capture stdout+stderr and remove unconditional pull High priority fixes: - Remove unconditional 'docker_compose pull' for offline environment support Docker Compose automatically pulls missing images during 'run' and 'up' Medium priority fixes: - Capture both stdout and stderr to ERROR_LOG for complete error diagnostics Changed from '>/dev/null 2>"$ERROR_LOG"' to '>"$ERROR_LOG" 2>&1' These changes improve offline installation support and error reporting. --- setup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.sh b/setup.sh index 692ab0af..d2185a52 100755 --- a/setup.sh +++ b/setup.sh @@ -30,7 +30,7 @@ run_with_progress() { printf "%s" "$RWP_MESSAGE" ERROR_LOG=$(mktemp) - eval "$RWP_COMMAND" >/dev/null 2>"$ERROR_LOG" & + eval "$RWP_COMMAND" >"$ERROR_LOG" 2>&1 & PID=$! trap 'kill "$PID" 2>/dev/null || true; rm -f "$ERROR_LOG"' EXIT INT TERM while kill -0 "$PID" 2>/dev/null; do @@ -386,7 +386,6 @@ startup() { if [ "x$DEBUG" = "xyes" ]; then docker_compose run --rm server create_db || handle_error else - run_with_progress "Downloading images" "docker_compose pull" run_with_progress "Creating database" "docker_compose run --rm server create_db" fi