diff --git a/metro-ai-suite/metro-vision-ai-app-recipe/install.sh b/metro-ai-suite/metro-vision-ai-app-recipe/install.sh index 555e52a9b..43c345170 100755 --- a/metro-ai-suite/metro-vision-ai-app-recipe/install.sh +++ b/metro-ai-suite/metro-vision-ai-app-recipe/install.sh @@ -56,22 +56,37 @@ else echo "HOST_IP=$HOST_IP" >> "$ENV_FILE" fi -# Extract SAMPLE_APP variable from .env file +# Extract SAMPLE_APP variable from .env file to ensure consistency SAMPLE_APP=$(grep -E "^SAMPLE_APP=" "$ENV_FILE" | cut -d '=' -f2 | tr -d '"' | tr -d "'") -# Bring down the application before updating docker compose file -if docker compose ps >/dev/null 2>&1; then - echo "Bringing down any running containers..." - docker compose down +# Validate that SAMPLE_APP was set correctly +if [ -z "$SAMPLE_APP" ]; then + echo "Error: SAMPLE_APP not found in .env file." + exit 1 fi -# Copy appropriate docker-compose file +# Determine appropriate docker-compose file based on SAMPLE_APP if [ "$SAMPLE_APP" = "smart-intersection" ]; then - cp compose-scenescape.yml docker-compose.yml + RI_COMPOSE_FILE_ARG="compose-scenescape.yml" else - cp compose-without-scenescape.yml docker-compose.yml + RI_COMPOSE_FILE_ARG="compose-without-scenescape.yml" +fi + +# Check if the compose file exists +if [ ! -f "$RI_COMPOSE_FILE_ARG" ]; then + echo "Error: Compose file $RI_COMPOSE_FILE_ARG not found." + exit 1 fi +# Bring down the application before updating docker compose file +if docker compose -f "$RI_COMPOSE_FILE_ARG" ps >/dev/null 2>&1; then + echo "Bringing down any running containers..." + docker compose -f "$RI_COMPOSE_FILE_ARG" down +fi + +# Copy appropriate docker-compose file +cp "$RI_COMPOSE_FILE_ARG" docker-compose.yml + # Check if the directory exists if [ ! -d "$SAMPLE_APP" ]; then echo "Error: Directory $SAMPLE_APP does not exist."