1 # ========================LICENSE_START=================================
4 # Copyright (C) 2024: OpenInfra Foundation Europe
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
22 if ! command -v java >/dev/null 2>&1; then
23 echo "Java is not installed. Please install Java."
24 echo "Suggested fix for ubuntu:"
25 echo "sudo apt install default-jdk"
28 echo "Java is installed."
33 if mvn -v >/dev/null 2>&1; then
34 echo "Maven is installed."
36 echo "Maven is not installed. Please install Maven."
37 echo "Suggested fix for ubuntu:"
38 echo "sudo apt install maven"
44 if ! docker -v > /dev/null 2>&1; then
45 echo "Docker is not installed. Please install Docker."
46 echo "Suggested fix for ubuntu:"
47 echo "sudo apt-get update"
48 echo "sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release"
49 echo "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg"
50 echo "echo \"deb [arch=\$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) stable\" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null"
51 echo "sudo apt-get update"
52 echo "sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
53 echo "sudo usermod -aG docker \$USER"
57 echo "Docker is installed."
61 checkDockerCompose() {
62 if ! docker-compose -v > /dev/null 2>&1; then
63 echo "docker-compose is not installed. Please install docker-compose"
64 echo "Suggested fix for ubuntu:"
65 echo "sudo apt-get install docker-compose-plugin"
68 echo "docker-compose is installed."
72 # Function to wait for a Docker container to be running and log a specific string with a maximum timeout of 20 minutes
73 wait_for_container() {
74 local container_name="$1"
76 local timeout=1200 # Timeout set to 20 minutes (20 minutes * 60 seconds)
78 local start_time=$(date +%s)
79 local end_time=$((start_time + timeout))
81 while ! docker inspect "$container_name" &>/dev/null; do
82 echo "Waiting for container '$container_name' to be created..."
84 if [ "$(date +%s)" -ge "$end_time" ]; then
85 echo "Timeout: Container creation exceeded 20 minutes."
90 while [ "$(docker inspect -f '{{.State.Status}}' "$container_name")" != "running" ]; do
91 echo "Waiting for container '$container_name' to be running..."
93 if [ "$(date +%s)" -ge "$end_time" ]; then
94 echo "Timeout: Container start exceeded 20 minutes."
99 # Check container logs for the specified string
100 while ! docker logs "$container_name" 2>&1 | grep "$log_string"; do
101 echo "Waiting for '$log_string' in container logs of '$container_name'..."
103 if [ "$(date +%s)" -ge "$end_time" ]; then
104 echo "Timeout: Log string not found within 20 minutes."
113 echo "++++++++++++++++++++++++++++++++++++++++++++++++++++"