11#! /bin/bash
22
33# These might need to be adjusted based on the setup
4-
5- # Domain name under which subdomains can be reachable
6- domain=aam-digital.com
7- # Prefix that will be added to created folders
8- prefix=ndb-
4+ source " ./setup.env"
95# Location where Keycloak is running
106source " ./keycloak/.env"
117
@@ -34,7 +30,7 @@ getKeycloakKey() {
3430
3531echo " What is the name of the organisation?"
3632read -r org
37- path=" ../$prefix $org "
33+ path=" ../$PREFIX $org "
3834app=$( docker ps | grep -c " \-$org -app" )
3935if [ " $app " == 0 ]; then
4036 echo " Setting up new instance '$org '"
@@ -53,7 +49,7 @@ if [ "$app" == 0 ]; then
5349 echo " COUCHDB_PASSWORD=$password " >> " $path /.env"
5450 echo " Admin password: $password "
5551
56- url=$org .$domain
52+ url=$org .$DOMAIN
5753 echo " APP_URL=$url " >> " $path /.env"
5854 echo " App URL: $url "
5955 (cd " $path " && docker compose up -d)
@@ -147,4 +143,18 @@ if [ ! -f "$path/keycloak.json" ]; then
147143 fi
148144fi
149145
146+ if [ " $app " == 0 ] && [ " $UPTIMEROBOT_API_KEY " != " " ] && [ " $UPTIMEROBOT_ALERT_ID " != " " ]; then
147+ echo " Do you want create UptimeRobot monitoring?[y/n]"
148+ read -r createsMonitors
149+ if [ " $createsMonitors " == " y" ] || [ " $createsMonitors " == " Y" ]; then
150+ curl -X POST -d " api_key=$UPTIMEROBOT_API_KEY &url=https://$url &friendly_name=Aam - $org App&alert_contacts=$UPTIMEROBOT_ALERT_ID &type=1" -H " Cache-Control: no-cache" -H " Content-Type: application/x-www-form-urlencoded" " https://api.uptimerobot.com/v2/newMonitor" -w " \n"
151+ if [ " $backend " == 1 ]; then
152+ curl -X POST -d " api_key=$UPTIMEROBOT_API_KEY &url=https://$url /db/api&friendly_name=Aam - $org Backend&alert_contacts=$UPTIMEROBOT_ALERT_ID &type=1" -H " Cache-Control: no-cache" -H " Content-Type: application/x-www-form-urlencoded" " https://api.uptimerobot.com/v2/newMonitor" -w " \n"
153+ curl -X POST -d " api_key=$UPTIMEROBOT_API_KEY &url=https://$url /db/couchdb/_utils/&friendly_name=Aam - $org DB&alert_contacts=$UPTIMEROBOT_ALERT_ID &type=1" -H " Cache-Control: no-cache" -H " Content-Type: application/x-www-form-urlencoded" " https://api.uptimerobot.com/v2/newMonitor" -w " \n"
154+ else
155+ curl -X POST -d " api_key=$UPTIMEROBOT_API_KEY &url=https://$url /db/_utils/&friendly_name=Aam - $org DB&alert_contacts=$UPTIMEROBOT_ALERT_ID &type=1" -H " Cache-Control: no-cache" -H " Content-Type: application/x-www-form-urlencoded" " https://api.uptimerobot.com/v2/newMonitor" -w " \n"
156+ fi
157+ fi
158+ fi
159+
150160echo " app is now available under https://$APP_URL "
0 commit comments