diff --git a/install/check-minimum-requirements.sh b/install/check-minimum-requirements.sh index 42689bf..b05952a 100644 --- a/install/check-minimum-requirements.sh +++ b/install/check-minimum-requirements.sh @@ -1,54 +1,50 @@ echo "${_group}Checking minimum requirements ..." source "$(dirname $0)/_min-requirements.sh" # Compare dot-separated strings - function below is inspired by https://stackoverflow.com/a/37939589/808368 function ver () { echo "$@" | awk -F. '{ printf("%d%03d%03d", $1,$2,$3); }'; } DOCKER_VERSION=$(docker version --format '{{.Server.Version}}') if [[ "$(ver $DOCKER_VERSION)" -lt "$(ver $MIN_DOCKER_VERSION)" ]]; then - echo "FAIL: Expected minimum Docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION" + echo "FAIL: Expected minimum docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION" exit 1 fi +echo "Found Docker version $DOCKER_VERSION" -if docker compose version &>/dev/null; then - # If `docker compose` exists then it's guaranteed to be Docker Compose v2, which is good enough for us. - true -else - # If we have `docker-compose` instead then it could be either v1 or v2 (also, use portable sed). - # See https://github.com/getsentry/self-hosted/issues/1132#issuecomment-982823712 ff. for regex testing. - COMPOSE_VERSION=$(docker-compose version | head -n1 | sed -E 's/^.* version:? v?([0-9.]+),?.*$/\1/') - if [[ "$(ver $COMPOSE_VERSION)" -lt "$(ver $MIN_COMPOSE_VERSION)" ]]; then - echo "FAIL: Expected minimum docker-compose version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION" - exit 1 - fi +# See https://github.com/getsentry/self-hosted/issues/1132#issuecomment-982823712 ff. for regex testing. +COMPOSE_VERSION=$($dc_base version | head -n1 | sed -E 's/^.* version:? v?([0-9.]+),?.*$/\1/') +if [[ "$(ver $COMPOSE_VERSION)" -lt "$(ver $MIN_COMPOSE_VERSION)" ]]; then + echo "FAIL: Expected minimum $dc_base version to be $MIN_COMPOSE_VERSION but found $COMPOSE_VERSION" + exit 1 fi +echo "Found Docker Compose version $COMPOSE_VERSION" CPU_AVAILABLE_IN_DOCKER=$(docker run --rm busybox nproc --all); if [[ "$CPU_AVAILABLE_IN_DOCKER" -lt "$MIN_CPU_HARD" ]]; then echo "FAIL: Required minimum CPU cores available to Docker is $MIN_CPU_HARD, found $CPU_AVAILABLE_IN_DOCKER" exit 1 elif [[ "$CPU_AVAILABLE_IN_DOCKER" -lt "$MIN_CPU_SOFT" ]]; then echo "WARN: Recommended minimum CPU cores available to Docker is $MIN_CPU_SOFT, found $CPU_AVAILABLE_IN_DOCKER" fi RAM_AVAILABLE_IN_DOCKER=$(docker run --rm busybox free -m 2>/dev/null | awk '/Mem/ {print $2}'); if [[ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM_HARD" ]]; then echo "FAIL: Required minimum RAM available to Docker is $MIN_RAM_HARD MB, found $RAM_AVAILABLE_IN_DOCKER MB" exit 1 elif [[ "$RAM_AVAILABLE_IN_DOCKER" -lt "$MIN_RAM_SOFT" ]]; then echo "WARN: Recommended minimum RAM available to Docker is $MIN_RAM_SOFT MB, found $RAM_AVAILABLE_IN_DOCKER MB" fi #SSE4.2 required by Clickhouse (https://clickhouse.yandex/docs/en/operations/requirements/) # On KVM, cpuinfo could falsely not report SSE 4.2 support, so skip the check. https://github.com/ClickHouse/ClickHouse/issues/20#issuecomment-226849297 IS_KVM=$(docker run --rm busybox grep -c 'Common KVM processor' /proc/cpuinfo || :) if [[ "$IS_KVM" -eq 0 ]]; then SUPPORTS_SSE42=$(docker run --rm busybox grep -c sse4_2 /proc/cpuinfo || :) if [[ "$SUPPORTS_SSE42" -eq 0 ]]; then echo "FAIL: The CPU your machine is running on does not support the SSE 4.2 instruction set, which is required for one of the services Sentry uses (Clickhouse). See https://git.io/JvLDt for more info." exit 1 fi fi echo "${_endgroup}" diff --git a/install/ensure-relay-credentials.sh b/install/ensure-relay-credentials.sh index 62388eb..df5686f 100644 --- a/install/ensure-relay-credentials.sh +++ b/install/ensure-relay-credentials.sh @@ -1,34 +1,37 @@ echo "${_group}Ensuring Relay credentials ..." RELAY_CONFIG_YML="../relay/config.yml" RELAY_CREDENTIALS_JSON="../relay/credentials.json" ensure_file_from_example $RELAY_CONFIG_YML if [[ -f "$RELAY_CREDENTIALS_JSON" ]]; then echo "$RELAY_CREDENTIALS_JSON already exists, skipped creation." else # There are a couple gotchas here: # # 1. We need to use a tmp file because if we redirect output directly to # credentials.json, then the shell will create an empty file that relay # will then try to read from (regardless of options such as --stdout or # --overwrite) and fail because it is empty. # # 2. We need to use -T to avoid additional garbage output cluttering # credentials.json under Docker Compose 1.x and 2.2.3+. Note that the # long opt --no-tty doesn't exist in Docker Compose 1. creds="$dcr --no-deps -T relay credentials" $creds generate --stdout > "$RELAY_CREDENTIALS_JSON".tmp mv "$RELAY_CREDENTIALS_JSON".tmp "$RELAY_CREDENTIALS_JSON" if ! grep -q Credentials <($creds show); then # Let's fail early if creds failed, to make debugging easier. echo "Failed to create relay credentials in $RELAY_CREDENTIALS_JSON." + echo "--- credentials.json v ---------------------------------------" + cat -v "$RELAY_CREDENTIALS_JSON" || true + echo "--- credentials.json ^ ---------------------------------------" exit 1 fi echo "Relay credentials written to $RELAY_CREDENTIALS_JSON." fi echo "${_endgroup}"