Skip to content
Snippets Groups Projects
Select Git revision
  • e87b66db3f48cd5d9dfac2d9098cbb2682a65225
  • master default protected
  • replication_test
  • release-1.10 protected
  • dev protected
  • 556-usage-statistics
  • 553-semantic-recommendation-2
  • 553-semantic-recommendation
  • release-1.9 protected
  • 551-init-broker-service-permissions
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • v1.10.4 protected
  • v1.10.3 protected
  • v1.10.2 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
41 results

init.py

Blame
  • install.sh 4.20 KiB
    #!/bin/bash
    
    # preset
    VERSION="latest"
    MIN_CPU=8
    MIN_RAM=8
    MIN_MAP_COUNT=262144
    SKIP_CHECKS=${SKIP_CHECKS:-0}
    
    # checks
    if [[ $SKIP_CHECKS -eq 0 ]]; then
      echo "[✨] Startup check ..."
      docker info > /dev/null
      if [[ $? -ne 0 ]]; then
        echo "Docker is not installed (or accessible in bash) on your system:"
        echo ""
        echo "  - install docker from https://docs.docker.com/desktop/install/linux-install/"
        echo "  - make sure the docker executable is in \$PATH"
        exit 2
      else
        echo "$(docker --version) OK"
      fi
      CPU=$(cat /proc/cpuinfo | grep processor | wc -l)
      if [[ $CPU -lt $MIN_CPU ]]; then
        echo "You do not have enough vCPU resources available:"
        echo ""
        echo "  - we found ${CPU} vCPU cores instead of necessary ${MIN_CPU}"
        echo "  - if you believe this is a mistake, skip startup checks with the SKIP_CHECKS=1 flag"
        exit 3
      else
        echo "vCPU ${CPU} OK"
      fi
      RAM=$(free -g -t | awk 'NR==2 {print $7}')
      if [[ $RAM -lt $MIN_RAM ]]; then
        echo "You do not have enough RAM free resources:"
        echo ""
        echo "  - we found ${RAM}GB RAM (free) instead of necessary ${RAM}GB"
        echo "  - if you believe this is a mistake, skip startup checks with the SKIP_CHECKS=1 flag"
        exit 4
      else
        echo "RAM ${RAM}GB OK"
      fi
      MAX_MAP_COUNT=$(cat /etc/sysctl.conf | grep -oP "vm.max_map_count=.*" | grep -oP "[0-9]+")
      if [[ $MAX_MAP_COUNT -lt $MIN_MAP_COUNT ]]; then
        echo "You do not have enough max. map counts:"
        echo ""
        echo "  - we found max. ${MAX_MAP_COUNT} map count instead of necessary ${MIN_MAP_COUNT}"
        echo "  - update your /etc/sysctl.conf file and add the line 'vm.max_map_count=${MIN_MAP_COUNT}' at the end and apply it with 'sysctl -p'"
        echo "  - if you believe this is a mistake, skip startup checks with the SKIP_CHECKS=1 flag"
        exit 4
      else
        echo "MAP COUNT ${MAX_MAP_COUNT} OK"
      fi
    else
      echo "[✨] Skipping checks ..."
    fi
    
    # environment
    echo "[🚀] Gathering environment ..."
    mkdir -p ./dist
    curl -sSL -o ./docker-compose.yml "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/docker-compose.prod.yml"
    curl -sSL -o ./dist/2_setup-data.sql "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-metadata-db/2_setup-data.sql"
    curl -sSL -o ./dist/rabbitmq.conf "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-broker-service/rabbitmq.conf"
    curl -sSL -o ./dist/enabled_plugins "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-broker-service/enabled_plugins"
    curl -sSL -o ./dist/cert.pem "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-broker-service/cert.pem"
    curl -sSL -o ./dist/pubkey.pem "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-broker-service/pubkey.pem"
    curl -sSL -o ./dist/definitions.json "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-broker-service/definitions.json"
    curl -sSL -o ./dist/dbrepo.conf "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-gateway-service/dbrepo.conf"
    curl -sSL -o ./dist/opensearch_dashboards.yml "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-search-db/opensearch_dashboards.yml"
    curl -sSL -o ./dist/dbrepo.config.json "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-ui/dbrepo.config.json"
    curl -sSL -o ./dist/s3_config.json "https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/release-${VERSION}/dbrepo-storage-service/s3_config.json"
    
    echo "[📦] Pulling images for version ${VERSION} ..."
    docker compose pull
    
    echo "[✨] Starting DBRepo ..."
    docker compose up -d
    
    if [ $? -eq 0 ]; then
      echo "[🎉] Successfully started!"
      echo ""
      echo "You can now inspect the logs with:"
      echo ""
      echo "  docker compose logs -f"
      echo ""
      echo "Read about next steps online: https://www.ifs.tuwien.ac.at/infrastructures/dbrepo/${VERSION}/deployment-docker-compose/#next-steps"
    fi