#!/usr/bin/env bash # Install jq echo "Installing jq" sudo apt-get -y install jq # Load env variables source /tmp/env.sh ## Install pgadmin echo "Installing pgadmin" # Download certificate curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg # Download pgAdmin4 sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update' # Install for web mode only: sudo apt -y install pgadmin4-web # Configure the webserver echo "Configuring the pgadmin webserver" export PGADMIN_SETUP_EMAIL=$PGADMIN_USER export PGADMIN_SETUP_PASSWORD=$PGADMIN_PASSWORD sudo -E /usr/pgadmin4/bin/setup-web.sh --yes # Create ragdemos Database echo "Creating the ragdemos database" sql=$( cat < 'text-embedding-005', model_provider => 'google', model_qualified_name => 'text-embedding-005', model_type => 'text_embedding', model_auth_type => 'alloydb_service_agent_iam' ); EOF ) echo $sql | PGPASSWORD=${ALLOYDB_PASSWORD} psql -h "${ALLOYDB_IP}" -U postgres -d ragdemos # Register Gemini model GEMINI_ENDPOINT="https://${REGION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${REGION}/publishers/google/models/gemini-2.0-flash-001:generateContent" sql=$( cat < 'gemini', model_request_url => '${GEMINI_ENDPOINT}', model_provider => 'google', model_auth_type => 'alloydb_service_agent_iam' ); EOF ) echo $sql | PGPASSWORD=${ALLOYDB_PASSWORD} psql -h "${ALLOYDB_IP}" -U postgres -d ragdemos # Create investments table and indexes echo "Creating tables" sql=$( cat <