diff --git a/lib/drop b/lib/drop deleted file mode 100644 index d70545e..0000000 --- a/lib/drop +++ /dev/null @@ -1,41 +0,0 @@ -| DROP TABLE IF EXISTS `wp_options`; | -| DROP TABLE IF EXISTS `wp_b2s_user`; | -| DROP TABLE IF EXISTS `wp_term_relationships`; | -| DROP TABLE IF EXISTS `wp_actionscheduler_groups`; | -| DROP TABLE IF EXISTS `wpjl_commentmeta`; | -| DROP TABLE IF EXISTS `wp_actionscheduler_actions`; | -| DROP TABLE IF EXISTS `wpjl_users`; | -| DROP TABLE IF EXISTS `wpjl_terms`; | -| DROP TABLE IF EXISTS `wp_commentmeta`; | -| DROP TABLE IF EXISTS `wp_b2s_posts_sched_details`; | -| DROP TABLE IF EXISTS `wpjl_usermeta`; | -| DROP TABLE IF EXISTS `wpjl_options`; | -| DROP TABLE IF EXISTS `wp_b2s_posts_favorites`; | -| DROP TABLE IF EXISTS `wpjl_links`; | -| DROP TABLE IF EXISTS `wpjl_termmeta`; | -| DROP TABLE IF EXISTS `wpjl_posts`; | -| DROP TABLE IF EXISTS `wp_b2s_posts_drafts`; | -| DROP TABLE IF EXISTS `wp_actionscheduler_claims`; | -| DROP TABLE IF EXISTS `wp_users`; | -| DROP TABLE IF EXISTS `wp_aioseo_posts`; | -| DROP TABLE IF EXISTS `wp_links`; | -| DROP TABLE IF EXISTS `wp_term_taxonomy`; | -| DROP TABLE IF EXISTS `wpjl_term_taxonomy`; | -| DROP TABLE IF EXISTS `wp_aioseo_notifications`; | -| DROP TABLE IF EXISTS `wp_usermeta`; | -| DROP TABLE IF EXISTS `wp_b2s_posts`; | -| DROP TABLE IF EXISTS `wpjl_postmeta`; | -| DROP TABLE IF EXISTS `wp_postmeta`; | -| DROP TABLE IF EXISTS `wp_actionscheduler_logs`; | -| DROP TABLE IF EXISTS `wp_termmeta`; | -| DROP TABLE IF EXISTS `wp_terms`; | -| DROP TABLE IF EXISTS `wp_posts`; | -| DROP TABLE IF EXISTS `wpjl_comments`; | -| DROP TABLE IF EXISTS `wp_b2s_user_contact`; | -| DROP TABLE IF EXISTS `wp_b2s_user_network_settings`; | -| DROP TABLE IF EXISTS `wp_blogmeta`; | -| DROP TABLE IF EXISTS `wpjl_term_relationships`; | -| DROP TABLE IF EXISTS `wp_comments`; | -| DROP TABLE IF EXISTS `wp_b2s_posts_network_details`; | -| DROP TABLE IF EXISTS `wpjl_elfsight_instagram_feed_widgets`; | -+--------------------------------------------------------------+ diff --git a/lib/functions.sh b/lib/functions.sh index c20b189..6dcd735 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -1361,7 +1361,10 @@ get_appvars() { ADMINPASS=`cat /federated/apps/panel/.env | grep SMTP_PASSWORD | awk -F= '{ print $2 }'` EXTERNALIP=$(get_externalip); MYSQL_ROOTPASSWORD=`cat /federated/apps/pdnsmysql/.env | grep MYSQL_ROOT_PASSWORD | awk -F= '{ print $2 }'` - MATRIX_SECRET=$(cat /federated/apps/postgresql/data/docker-entrypoint-initdb.d/init.sql | grep matrix | grep PASSWORD | awk -F\' '{ print $2 }') + + # If COTURN_MATRIX_SECRET exists in turnserver.conf then use it, otherwise create the password + [[ $(grep static-auth-secret /federated/apps/coturn/data/etc/turnserver.conf 2>/dev/null | awk -F= '{ print $2 }') ]] && COTURN_MATRIX_SECRET=$(grep static-auth-secret /federated/apps/coturn/data/etc/turnserver.conf 2>/dev/null | awk -F= '{ print $2 }') || COTURN_MATRIX_SECRET=$(create_password); + # Set SMTP user based on if fcore exists [[ $(docker exec ldap slapcat | grep fcore) ]] && SMTPUSER="fcore" || SMTPUSER="admin" } diff --git a/lib/matrix.sh b/lib/matrix.sh index c4e7fe3..c6b8c8a 100644 --- a/lib/matrix.sh +++ b/lib/matrix.sh @@ -3,6 +3,7 @@ # Matrix Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +get_appvars config_matrix() { echo -ne "\n* Configuring /federated/apps/matrix container.." @@ -16,6 +17,8 @@ config_matrix() { chown -R 991:991 /federated/apps/matrix/data/matrix fi + MATRIX_SECRET=$(create_password); + cat > /federated/apps/matrix/docker-compose.yml < /dev/null [ $? -ne 0 ] && fail "Couldn't run docker matrixdotorg/synapse:latest generate" @@ -82,7 +81,7 @@ database: email: smtp_host: "mail.$DOMAIN" smtp_port: 587 - smtp_user: "fcore" + smtp_user: "$SMTPUSER" smtp_pass: "$ADMINPASS" force_tls: true # require_transport_security: true @@ -112,6 +111,11 @@ EOF # 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 + kill -9 $SPINPID &> /dev/null echo -ne "done." } @@ -128,3 +132,99 @@ start_matrix() { kill -9 $SPINPID &> /dev/null echo -ne "done." } +email_matrix() { + echo -ne "* Sending email to customer.." + spin & + SPINPID=$! + +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

+ + ++++++++ + + + + + + + + + + + + + + + + + + + + +
ServiceLinkUser / PassAccessDocsDescription
Matrixelement.$DOMAINadmin@$DOMAIN
$ADMINPASS
All users in panel have access using user@$DOMAINClick hereMatrix (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 + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} +uninstall_matrix() { + echo -ne "* Uninstalling matrix container.." + spin & + SPINPID=$! + + # 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 + + kill -9 $SPINPID &> /dev/null + echo -ne "done.\n" +} diff --git a/lib/postgresql.sh b/lib/postgresql.sh index 07bdf0a..88ae533 100644 --- a/lib/postgresql.sh +++ b/lib/postgresql.sh @@ -72,7 +72,6 @@ chmod 600 /federated/apps/postgresql/.postgresql.secret NEXTCLOUD_SECRET=$(create_password); VAULTWARDEN_SECRET=$(create_password); LISTMONK_SECRET=$(create_password); -MATRIX_SECRET=$(create_password); BASEROW_SECRET=$(create_password); GITEA_SECRET=$(create_password); @@ -87,9 +86,6 @@ GRANT ALL PRIVILEGES ON DATABASE vaultwarden TO vaultwarden; CREATE USER listmonk WITH PASSWORD '$LISTMONK_SECRET'; CREATE DATABASE listmonk; GRANT ALL PRIVILEGES ON DATABASE listmonk TO listmonk; -CREATE USER matrix WITH PASSWORD '$MATRIX_SECRET'; -CREATE DATABASE matrix; -GRANT ALL PRIVILEGES ON DATABASE matrix TO matrix; CREATE USER baserow WITH PASSWORD '$BASEROW_SECRET'; CREATE DATABASE baserow; GRANT ALL PRIVILEGES ON DATABASE baserow TO baserow; diff --git a/lib/test b/lib/test new file mode 100755 index 0000000..019df2d --- /dev/null +++ b/lib/test @@ -0,0 +1,7 @@ +#!/bin/bash -x + +. /federated/lib/functions.sh + +[[ $(type get_appvars 2> /dev/null) ]] && get_appvars || echo "NO" + +echo "Admin pass: $ADMINPASS"