#!/bin/bash # # Matrix Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin . /etc/federated get_appvars config_matrix() { echo -ne "* Configuring matrix container.." if [ ! -d "/federated/apps/matrix" ]; then mkdir -p /federated/apps/matrix/data/matrix &> /dev/null if [[ "${PLUS}" != "true" ]]; then cp /federated/certs/certs/$DOMAIN.crt /federated/certs/private/$DOMAIN.key /federated/apps/matrix/data/matrix/ chmod 644 /federated/apps/matrix/data/matrix/$DOMAIN.crt /federated/apps/matrix/data/matrix/$DOMAIN.key fi chown -R 991:991 /federated/apps/matrix/data/matrix fi MATRIX_SECRET=$(create_password); cat > /federated/apps/matrix/docker-compose.yml < /federated/apps/matrix/.env < /dev/null [ $? -ne 0 ] && fail "Couldn't run docker matrixdotorg/synapse:latest generate" # Take out default Sqlite database config sed -i 's!database: /data/homeserver.db!!g' /federated/apps/matrix/data/matrix/homeserver.yaml sed -i 's!database:!!g' /federated/apps/matrix/data/matrix/homeserver.yaml sed -i 's!name: sqlite3!!g' /federated/apps/matrix/data/matrix/homeserver.yaml sed -i 's!args:!!g' /federated/apps/matrix/data/matrix/homeserver.yaml # Insert our Postgres and LDAP config if [[ "${PLUS}" = "true" ]]; then cat >> /federated/apps/matrix/data/matrix/homeserver.yaml <" app_name: $COMPANY Matrix Server EOF else cat >> /federated/apps/matrix/data/matrix/homeserver.yaml <" app_name: $COMPANY Matrix Server modules: - module: "ldap_auth_provider.LdapAuthProviderModule" config: enabled: true uri: "ldaps://ldap.$DOMAIN:636" start_tls: true base: "dc=federatedcomputer,dc=cloud" attributes: mail: "mail" uid: "uid" name: "givenName" bind_dn: cn=admin,dc=federatedcomputer,dc=cloud bind_password: $LDAP_SECRET tls_options: validate: true local_certificate_file: /data/$DOMAIN.crt local_private_key_file: /data/$DOMAIN.key EOF # Set the ldap configuration correct to the domain if [ "${#LDAP_DOMAIN_ARRAY[@]}" -eq "3" ]; then sed -i "s#dc=federatedcomputer,dc=cloud#dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST#g" /federated/apps/matrix/data/matrix/homeserver.yaml else sed -i "s#dc=federatedcomputer,dc=cloud#dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST#g" /federated/apps/matrix/data/matrix/homeserver.yaml fi fi # Set permissions chown -R 991:991 /federated/apps/matrix/data/matrix # Create database and user in postgresql docker exec postgresql psql -U postgres -c "CREATE USER matrix WITH PASSWORD '$MATRIX_SECRET'" &> /dev/null docker exec postgresql psql -U postgres -c "CREATE DATABASE matrix" &> /dev/null docker exec postgresql psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE matrix TO matrix" &> /dev/null echo -ne "done.\n" } start_matrix() { # Start service with command to make sure it's up before proceeding start_service "matrix" "nc -z 192.168.0.19 8008 &> /dev/null" "8" # Set permissions chown -R 991:991 /federated/apps/matrix/data/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 [[ "${PLUS}" != "true" ]] && docker exec pdns pdnsutil add-record $DOMAIN matrix A 86400 $EXTERNALIP &> /dev/null echo -ne "done.\n" } email_matrix() { echo -ne "* Sending email to customer.." cat > /federated/apps/mail/data/root/certs/mailfile <

Wordpress is now installed on $DOMAIN

Here is your applications chart with on how to access this service:

Applications

Service Link User / Pass Access Docs Description
Matrix element.$DOMAIN admin@$DOMAIN
$ADMINPASS
All users in panel have access using user@$DOMAIN Click here Matrix (a Slack replacement) provides you the ability to chat with those on your team and outside of your team

Thanks for your support!

Thank you for your support of Federated Computer. We really appreciate it and hope you have a very successful time with Federated Core.

Again, if we can be of any assistance, please don't hesitate to get in touch.

Support: https://support.federated.computer
Phone: (970) 722-8715
Email: support@federated.computer

It's your computer. Let's make it work for you! EOF # Send out e-mail from mail container with details docker exec mail bash -c "mail -r admin@$DOMAIN -a \"Content-type: text/html\" -s \"Application installed on $DOMAIN\" $EMAIL < /root/certs/mailfile" rm /federated/apps/mail/data/root/certs/mailfile echo -ne "done.\n" } uninstall_matrix() { echo -ne "* Uninstalling matrix container.." # First stop the service cd /federated/apps/matrix && docker compose -f docker-compose.yml -p matrix down &> /dev/null # Delete database and user in postgresql docker exec postgresql psql -U postgres -c "DROP DATABASE matrix" &> /dev/null docker exec postgresql psql -U postgres -c "DROP USER matrix" &> /dev/null # Delete the app directory rm -rf /federated/apps/matrix # Delete the image docker image rm matrixdotorg/synapse:$IMAGE_VERSION &> /dev/null # Delete the DNS record [[ "${PLUS}" != "true" ]] && docker exec pdns pdnsutil delete-rrset $DOMAIN matrix A # Uninstall the SSO configuration if it exists in authelia (authelia must exist too) if [[ $(grep "### Matrix" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]]; then sed -i '/### Matrix/,/### /{/### PowerDNS/!{/### /!d}}' /federated/apps/authelia/data/config/idproviders.yml sed -i '/### Matrix/d' /federated/apps/authelia/data/config/idproviders.yml run_command "/federated/bin/stop authelia" run_command "/federated/bin/start authelia" fi echo -ne "done.\n" } configsso_matrix() { if [[ "${PLUS}" != "true" ]]; then echo -ne "* Configuring matrix container with SSO.." [ ! -d "/federated/apps/authelia" ] && failcheck "Authelia is not installed. You need this first before continuing." [ ! -f "/federated/apps/authelia/data/config/idproviders.yml" ] && failcheck "Authelia idproviders.yml is missing." [[ $(grep "### Matrix" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]] && failcheck "Authelia already has a Matrix configuration." MATRIX_CLIENT_SECRET=$(create_password); MATRIX_CLIENT_SECRET_HASH=$(docker run --rm authelia/authelia:latest authelia crypto hash generate pbkdf2 --password $MATRIX_CLIENT_SECRET | awk '{ print $2 }') echo "$MATRIX_CLIENT_SECRET" > /federated/apps/matrix/.matrix.client.secret cat >> /federated/apps/authelia/data/config/idproviders.yml <> /federated/apps/matrix/data/matrix/homeserver.yaml <> /federated/apps/matrix/data/matrix/homeserver.yaml <