Skip to content

Commit 9a24b25

Browse files
authored
feat: uptime monitor can automatically be created (#20)
1 parent 9d90842 commit 9a24b25

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

interactive_setup.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
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
106
source "./keycloak/.env"
117

@@ -34,7 +30,7 @@ getKeycloakKey() {
3430

3531
echo "What is the name of the organisation?"
3632
read -r org
37-
path="../$prefix$org"
33+
path="../$PREFIX$org"
3834
app=$(docker ps | grep -c "\-$org-app")
3935
if [ "$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
148144
fi
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+
150160
echo "app is now available under https://$APP_URL"

setup.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DOMAIN=aam-digital.com
2+
PREFIX=ndb-
3+
UPTIMEROBOT_API_KEY=
4+
UPTIMEROBOT_ALERT_ID=

0 commit comments

Comments
 (0)