From 630e383ca9d962b7ce02eb752984560705c4d753 Mon Sep 17 00:00:00 2001
From: root <root@f11391a1.federatedcomputer.cloud>
Date: Fri, 5 Apr 2024 17:32:11 +0000
Subject: [PATCH] Added dns create entries for a few apps

---
 lib/listmonk.sh    | 3 +++
 lib/matrix.sh      | 4 ++++
 lib/pdns.sh        | 2 +-
 lib/vaultwarden.sh | 3 +++
 lib/wordpress.sh   | 4 ++--
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lib/listmonk.sh b/lib/listmonk.sh
index 58f1dc4..d027a29 100644
--- a/lib/listmonk.sh
+++ b/lib/listmonk.sh
@@ -88,6 +88,9 @@ start_listmonk() {
   # Start service with command to make sure it's up before proceeding
   start_service "listmonk" "nc -z 172.99.0.21 9000 &> /dev/null" "8"
 
+  docker exec pdns pdnsutil add-record $DOMAIN listmonk A 86400 $EXTERNALIP &> /dev/null
+  [ $? -ne 0 ] && fail "Couldn't add dns record"
+
   echo -ne "done."
 }
 email_listmonk() {
diff --git a/lib/matrix.sh b/lib/matrix.sh
index 39cb5bc..1f240f8 100644
--- a/lib/matrix.sh
+++ b/lib/matrix.sh
@@ -133,6 +133,10 @@ start_matrix() {
   # Set admin user as admin in Matrix
   docker exec postgresql psql -U matrix -c "update users set admin='1' where name='\"@admin:matrix.$DOMAIN\"'" &> /dev/null
 
+  docker exec pdns pdnsutil add-record $DOMAIN matrix A 86400 $EXTERNALIP &> /dev/null
+  [ $? -ne 0 ] && fail "Couldn't add dns record"
+
+
   echo -ne "done."
 }
 email_matrix() {
diff --git a/lib/pdns.sh b/lib/pdns.sh
index 53abf28..9812f0f 100644
--- a/lib/pdns.sh
+++ b/lib/pdns.sh
@@ -77,7 +77,7 @@ curl -X PATCH --data '{"rrsets": [ {"name": "$DOMAIN.", "type": "MX", "ttl": 864
 curl -X PATCH --data '{"rrsets": [ {"name": "$DOMAIN.", "type": "TXT", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "\"v=spf1 mx a:$DOMAIN ~all\"", "disabled": false } ] } ] }' -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/$DOMAIN.
 
 # Create the A records for domain
-for i in ns1 ns2 pdnsadmin powerdns traefik mail www computer panel nextcloud collabora jitsi matrix element listmonk vaultwarden vpn wireguard baserow gitea blog documentation castopod podcasts caddy; do
+for i in ns1 ns2 pdnsadmin powerdns traefik mail panel nextcloud collabora jitsi element vpn wireguard baserow gitea blog documentation castopod podcasts caddy; do
   curl -X PATCH --data "{\"rrsets\": [ {\"name\": \"\$i.$DOMAIN.\", \"type\": \"A\", \"ttl\": 86400, \"changetype\": \"REPLACE\", \"records\": [ {\"content\": \"$EXTERNALIP\", \"disabled\": false } ] } ] }" -H 'X-API-Key: $PDNS_APIKEY' http://127.0.0.1:8081/api/v1/servers/localhost/zones/$DOMAIN.
 done
 
diff --git a/lib/vaultwarden.sh b/lib/vaultwarden.sh
index 18cfd77..34f6ebf 100644
--- a/lib/vaultwarden.sh
+++ b/lib/vaultwarden.sh
@@ -71,5 +71,8 @@ start_vaultwarden() {
   # Start service with command to make sure it's up before proceeding
   start_service "vaultwarden" "nc -z 172.99.0.22 80 &> /dev/null" "8"
 
+  docker exec pdns pdnsutil add-record $DOMAIN vaultwarden A 86400 $EXTERNALIP &> /dev/null
+  [ $? -ne 0 ] && fail "Couldn't add dns record"
+
   echo -ne "done."
 }
diff --git a/lib/wordpress.sh b/lib/wordpress.sh
index 48187ed..240bcf8 100644
--- a/lib/wordpress.sh
+++ b/lib/wordpress.sh
@@ -86,9 +86,9 @@ start_wordpress() {
   chmod 740 /federated/apps/wordpress/data/bitnami/wordpress/wp-config.php
 
   docker exec pdns pdnsutil add-record $DOMAIN www A 86400 $EXTERNALIP &> /dev/null
-  [ $? -ne 0 ] && fail "Couldn't add dns record for freescout"
+  [ $? -ne 0 ] && fail "Couldn't add dns record"
   docker exec pdns pdnsutil add-record $DOMAIN wordpress A 86400 $EXTERNALIP &> /dev/null
-  [ $? -ne 0 ] && fail "Couldn't add dns record for freescout"
+  [ $? -ne 0 ] && fail "Couldn't add dns record"
 
   echo -ne "done.\n"
 }