-
Notifications
You must be signed in to change notification settings - Fork 0
Mods for macOS installer. #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a6b9434
Mods for macOS installer.
danichcr72 da85305
Add help for use-timeout.
danichcr72 70cf27d
Address reviewer's comment.
danichcr72 3471e66
Fix one more help error.
danichcr72 0c796b6
Check return code for direct pull.
danichcr72 b3bb21e
Address another reviewer comment.
danichcr72 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,31 @@ 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 " --use-timeout (0 or 1) Run docker asynchronously with a timeout (default: $DEFAULT_USE_TIMEOUT)" | ||
| echo " -h, --help Show this help message" | ||
| exit 0 | ||
| ;; | ||
|
|
@@ -124,27 +148,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 +326,23 @@ 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't work when running inside the macOS installer... |
||
| log_error "Failed to pull container images. Error: $output" | ||
| exit 1 | ||
| elif [ $use_timeout -eq 0 ]; then | ||
| $DOCKER_CMD compose pull | ||
landwehrj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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." | ||
| 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 +407,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!" | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should a line in the help be added for use-timeout?