From a6b9434983460cade605b61c8b460550d4032ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Chavarr=C3=ADa?= Date: Thu, 22 May 2025 12:41:55 -0700 Subject: [PATCH 1/6] Mods for macOS installer. --danich --- install.sh | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index eb773f9..4378a00 100644 --- a/install.sh +++ b/install.sh @@ -10,10 +10,14 @@ NC='\033[0m' # No Color. # Default ports. DEFAULT_HTTP_PORT=80 DEFAULT_HTTPS_PORT=443 +DEFAULT_DOCKER_CMD=docker +DEFAULT_USE_TIMEOUT=1 # Initialize variables with default values HTTP_PORT=$DEFAULT_HTTP_PORT HTTPS_PORT=$DEFAULT_HTTPS_PORT +DOCKER_CMD=$DEFAULT_DOCKER_CMD +USE_TIMEOUT=$DEFAULT_USE_TIMEOUT # Parse command line options while [ $# -gt 0 ]; do @@ -36,11 +40,30 @@ while [ $# -gt 0 ]; do exit 1 fi ;; + --docker-command) + if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + DOCKER_CMD=$2 + shift 2 + else + log_error "Error: Argument for $1 is missing" + exit 1 + fi + ;; + --use-timeout) + if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then + USE_TIMEOUT=$2 + shift 2 + else + log_error "Error: Argument for $1 is missing" + exit 1 + fi + ;; -h|--help) echo "Usage: $0 [OPTIONS]" echo "Available options:" echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" + echo " --docker-command DOCKER_COMMAND Specify explicit location of the docker command (default: $DEFAULT_DOCKER_CMD)" echo " -h, --help Show this help message" exit 0 ;; @@ -124,27 +147,27 @@ check_requirements_docker() { log_info "Checking system requirements." # Check if Docker is installed. - if ! command_exists docker; then + if ! command_exists $DOCKER_CMD; then log_error "Docker is not installed. Please install Docker first." log_info "Visit https://docs.docker.com/get-docker/ for installation instructions." exit 1 fi # Check that Docker is running and the user has permissions to use it. - if ! run_with_timeout 10 "docker ps"; then + if ! run_with_timeout 10 "$DOCKER_CMD ps"; then log_error "Docker is either not running or this user doesn't have permission to use Docker. Make sure Docker is started. If Docker is running, it is likely the user doesn't have permission to use Docker. Either run the script as root or contact your system administrator." exit 1 fi # Check if Docker Compose is installed. - if ! run_with_timeout 10 "docker compose version"; then + if ! run_with_timeout 10 "$DOCKER_CMD compose version"; then log_error "Docker is installed but Compose is not. Please install Docker Compose first." log_info "Visit https://docs.docker.com/compose/install/ for installation instructions." exit 1 fi # Check Docker Compose version. - compose_version=$(docker compose version --short 2>/dev/null || docker-compose --version | awk '{print $3}') + compose_version=$($DOCKER_CMD compose version --short 2>/dev/null || docker-compose --version | awk '{print $3}') compose_version=$(echo "$compose_version" | sed 's/[^0-9.]*//g') if ! version_ge "$MIN_COMPOSE_VERSION" "$compose_version"; then log_error "Docker Compose version $compose_version is too old. Please install Docker Compose version $MIN_COMPOSE_VERSION or higher." @@ -302,14 +325,18 @@ check_ports() { # Pull and start containers. deploy_containers_docker() { + local use_timeout=$1 + log_info "Pulling latest container images." - if ! output=$(run_with_timeout 300 docker compose pull 2>&1); then + if [ $use_timeout -eq 1 ] && ! output=$(run_with_timeout 300 $DOCKER_CMD compose pull 2>&1); then log_error "Failed to pull container images. Error: $output" exit 1 + else + $DOCKER_CMD compose pull fi log_info "Starting containers." - if ! output=$(docker compose up -d 2>&1); then + if ! output=$($DOCKER_CMD compose up -d 2>&1); then log_error "Failed to start containers. Error: $output" exit 1 fi @@ -374,7 +401,7 @@ main() { if [ $(uname -m) = "ppc64le" ]; then deploy_containers_podman else - deploy_containers_docker + deploy_containers_docker $USE_TIMEOUT fi log_info "Installation completed successfully!" From da85305b6a7d8d95d6b5d9841631ec8b858e9e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Chavarr=C3=ADa?= Date: Thu, 22 May 2025 12:56:31 -0700 Subject: [PATCH 2/6] Add help for use-timeout. --danich --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 4378a00..5602f7e 100644 --- a/install.sh +++ b/install.sh @@ -64,6 +64,7 @@ while [ $# -gt 0 ]; do echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" echo " --docker-command DOCKER_COMMAND Specify explicit location of the docker command (default: $DEFAULT_DOCKER_CMD)" + echo " --use-time (0 or 1) Run docker asynchronously with a timeout (default: $DEFAULT_DOCKER_CMD)" echo " -h, --help Show this help message" exit 0 ;; From 70cf27da0ca5c7ac7bd53afd7308d78a723e03ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Chavarr=C3=ADa?= Date: Thu, 22 May 2025 15:01:31 -0700 Subject: [PATCH 3/6] Address reviewer's comment. --danich --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 5602f7e..577243b 100644 --- a/install.sh +++ b/install.sh @@ -64,7 +64,7 @@ while [ $# -gt 0 ]; do echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" echo " --docker-command DOCKER_COMMAND Specify explicit location of the docker command (default: $DEFAULT_DOCKER_CMD)" - echo " --use-time (0 or 1) Run docker asynchronously with a timeout (default: $DEFAULT_DOCKER_CMD)" + echo " --use-timeout (0 or 1) Run docker asynchronously with a timeout (default: $DEFAULT_DOCKER_CMD)" echo " -h, --help Show this help message" exit 0 ;; From 3471e662d5fb130187284041b8d6a6b6330f6c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Chavarr=C3=ADa?= Date: Thu, 22 May 2025 15:28:23 -0700 Subject: [PATCH 4/6] Fix one more help error. --danich --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 577243b..003f109 100644 --- a/install.sh +++ b/install.sh @@ -64,7 +64,7 @@ while [ $# -gt 0 ]; do echo " --http-port PORT Specify custom HTTP port (default: $DEFAULT_HTTP_PORT)" echo " --https-port PORT Specify custom HTTPS port (default: $DEFAULT_HTTPS_PORT)" echo " --docker-command DOCKER_COMMAND Specify explicit location of the docker command (default: $DEFAULT_DOCKER_CMD)" - echo " --use-timeout (0 or 1) Run docker asynchronously with a timeout (default: $DEFAULT_DOCKER_CMD)" + echo " --use-timeout (0 or 1) Run docker asynchronously with a timeout (default: $DEFAULT_USE_TIMEOUT)" echo " -h, --help Show this help message" exit 0 ;; From 0c796b661795ea1c6bbae76419f01ae925499f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Chavarr=C3=ADa?= Date: Thu, 22 May 2025 15:31:18 -0700 Subject: [PATCH 5/6] Check return code for direct pull. --danich --- install.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install.sh b/install.sh index 003f109..093c083 100644 --- a/install.sh +++ b/install.sh @@ -334,6 +334,11 @@ deploy_containers_docker() { exit 1 else $DOCKER_CMD compose pull + local return_code=$? + if [ $return_code -ne 0 ]; then + log_error "Failed to pull container images directly." + exit 1 + fi fi log_info "Starting containers." From b3bb21e9b82dbf76f8e17e35261169f02b612558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Chavarr=C3=ADa?= Date: Thu, 22 May 2025 15:34:06 -0700 Subject: [PATCH 6/6] Address another reviewer comment. --danich --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 093c083..37e22af 100644 --- a/install.sh +++ b/install.sh @@ -332,7 +332,7 @@ deploy_containers_docker() { if [ $use_timeout -eq 1 ] && ! output=$(run_with_timeout 300 $DOCKER_CMD compose pull 2>&1); then log_error "Failed to pull container images. Error: $output" exit 1 - else + elif [ $use_timeout -eq 0 ]; then $DOCKER_CMD compose pull local return_code=$? if [ $return_code -ne 0 ]; then