From 6f070062c579b8d2ac6adcbffe5287185f2bf0b5 Mon Sep 17 00:00:00 2001
From: Derek Crudgington <derek@federated.company>
Date: Wed, 15 Feb 2023 14:34:33 +0000
Subject: [PATCH] Added email fix for baserow, vaultwarden, and print_details
 at end of scrtip

---
 bin/install-federated.sh | 21 ++-----------
 lib/baserow.sh           |  2 +-
 lib/functions.sh         | 64 ++++++++++++++++++++++++++++++++++++++++
 lib/vaultwarden.sh       |  6 ++++
 4 files changed, 73 insertions(+), 20 deletions(-)

diff --git a/bin/install-federated.sh b/bin/install-federated.sh
index 2b8b3b7..28cb508 100755
--- a/bin/install-federated.sh
+++ b/bin/install-federated.sh
@@ -61,6 +61,7 @@ echo -ne "\n\nStarting Federated install for $DOMAIN\n"
 # Check that we have docker installed.  Check that
 # we have all ports available and not in use
 check_docker
+check_os
 check_ports
 
 # Configure docker private network
@@ -73,23 +74,5 @@ for i in dns postgresql ldap mail collabora proxy nextcloud matrix element listm
 done
 
 # Print out federated environment details
+print_details
 echo -ne "\n\n"
-cat << EOF
-* The services are at these hostnames..
-mail.$DOMAIN
-www.$DOMAIN
-panel.$DOMAIN
-nextcloud.$DOMAIN
-jitsi.$DOMAIN
-element.$DOMAIN
-listmonk.$DOMAIN
-vaultwarden.$DOMAIN
-vpn.$DOMAIN
-connector.$DOMAIN
-baserow.$DOMAIN
-calcom.$DOMAIN
-
-* Your VPN Wireguard configuration is..
-EOF
-
-cat /federated/apps/wireguard/data/config/peer1/peer1.conf
diff --git a/lib/baserow.sh b/lib/baserow.sh
index 7accf73..c5ebd67 100644
--- a/lib/baserow.sh
+++ b/lib/baserow.sh
@@ -53,7 +53,7 @@ BASEROW_AMOUNT_OF_GUNICORN_WORKERS=1
 BASEROW_RUN_MINIMAL=1
 BASEROW_TRIGGER_SYNC_TEMPLATES_AFTER_MIGRATION="false"
 EMAIL_SMTP=True
-FROM_EMAIL=admin@$DOMAIN
+FROM_EMAIL=baserow@$DOMAIN
 EMAIL_SMTP_HOST=mail.$DOMAIN
 EMAIL_SMTP_PORT=587
 EMAIL_SMTP_USER=admin
diff --git a/lib/functions.sh b/lib/functions.sh
index fdfebf5..cd0bd22 100644
--- a/lib/functions.sh
+++ b/lib/functions.sh
@@ -68,3 +68,67 @@ start_service() {
     done
   fi
 }
+print_details() {
+cat > /federated/apps/mail/data/root/certs/mailfile <<EOF
+Panel: User Management
+https://panel.$DOMAIN
+
+You must also log in as an admin user to https://vaultwarden.$DOMAIN
+to create an organization for your team. Open the URL
+(https://vaultwarden.$DOMAIN) and click the text below "Continue"
+that says "Create account".
+
+You will need this information for the VPN that can be set up by
+users of your system. Please keep it private.
+
+EOF
+
+cat /federated/apps/wireguard/data/config/peer1/peer1.conf >> /federated/apps/mail/data/root/certs/mailfile
+
+cat >> /federated/apps/mail/data/root/certs/mailfile <<EOF
+All documentation for administration of your Federated Core can
+be found at: https://documentation.federated.computer/administration.
+
+Users can then log into the following services to use Federated Core:
+
+Nextcloud: The Nextcloud suite provides web apps and services
+covering mail, calendar, contacts, notes, tasks, files, project
+management (deck), bookmarks, forms, team talk, pictures, and an
+activity monitor. It can be accessed at: https://nextcloud.$DOMAIN
+
+Jitsi: Video-conferencing. The current installation supports (4)
+users and can be extended by adding more RAM to the system. It can
+be found at: https://jitsi.$DOMAIN
+
+Element: Worldwide Federated Chat. This chat client uses Matrix and
+can be used chat with users outside your team and can even interact
+with other chat servers around the world including Signal, Whatsapp,
+and other services. It is found at: https://element.$DOMAIN
+
+Listmonk: Marketing Email Service. Use Listmonk the way you would use
+Mailchimp. Found here: https://listmonk.$DOMAIN
+
+Vaultwarden: Password Management. Open source equivalent of Bitwarden
+and is a widely used replacement for 1password, Lastpass, and other
+password managers. https://vaultwarden.$DOMAIN
+
+Baserow: Easy Database. Replacement for Airtable. Build amazing, easy
+to create on-line databases to be used by your team.
+https://baserom.$DOMAIN
+
+Cal.com: Easy scheduling. Create easy links so that others can easily
+schedule time on your calendar without the annoying back-and-forth.
+https://calcom.$DOMAIN
+
+Connector: a utility to automatically configure all your applications
+on macOS, iOS, Windows, Android for use with your Federated Core.
+https://connector.$DOMAIN
+
+All documentation for users can be found at
+https://documentation.federated.computer/users.
+EOF
+
+# Send out e-mail from mail container with details
+docker exec -it mail bash -c "mail -r admin@$DOMAIN -s \"Welcome to Feded\" admin@$DOMAIN < /root/certs/mailfile"
+cat /federated/apps/mail/data/root/certs/mailfile
+rm /federated/apps/mail/data/root/certs/mailfile
diff --git a/lib/vaultwarden.sh b/lib/vaultwarden.sh
index a808872..eea53f9 100644
--- a/lib/vaultwarden.sh
+++ b/lib/vaultwarden.sh
@@ -49,6 +49,12 @@ VIRTUAL_HOST=vaultwarden.$DOMAIN
 WEBSOCKET_ENABLED=true
 ADMIN_TOKEN=$VAULTWARDEN_SECRET
 #- SIGNUPS_ALLOWED=false
+SMTP_HOST=mail.$DOMAIN
+SMTP_FROM=vaultwarden@$DOMAIN
+SMTP_PORT=587
+SMTP_SECURITY=starttls
+SMTP_USERNAME=admin
+SMTP_PASSWORD=$ADMINPASS
 EOF
 chmod 600 /federated/apps/vaultwarden/.env