Fixed Matrix to use installapp and uninstallapp

This commit is contained in:
root 2024-02-20 18:04:33 +00:00
parent 04052294bd
commit 2e112adc61
5 changed files with 116 additions and 51 deletions

View File

@ -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`; |
+--------------------------------------------------------------+

View File

@ -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"
}

View File

@ -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 <<EOF
version: '3.7'
@ -49,10 +52,6 @@ IMAGE_VERSION="v1.100.0"
EOF
chmod 600 /federated/apps/matrix/.env
LDAP_SECRET=`cat /federated/apps/ldap/.ldap.secret`
COTURN_MATRIX_SECRET=$(create_password);
MATRIX_SECRET=$(cat /federated/apps/postgresql/data/docker-entrypoint-initdb.d/init.sql | grep matrix | grep PASSWORD | awk -F\' '{ print $2 }')
# Generate the matrix homeserver.yaml file
docker run --rm -v "/federated/apps/matrix/data/matrix:/data" -e SYNAPSE_SERVER_NAME=matrix.$DOMAIN -e SYNAPSE_REPORT_STATS=yes matrixdotorg/synapse:latest generate &> /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 <<EOF
<html>
<img src="https://www.federated.computer/wp-content/uploads/2023/11/logo.png" alt="" /><br>
<p>
<h4>Wordpress is now installed on $DOMAIN</h4>
<p>
Here is your applications chart with on how to access this service:<br>
<p>
<h4>Applications</h4>
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-cul6{border-color:inherit;color:#340096;text-align:left;text-decoration:underline;vertical-align:top}
.tg .tg-acii{background-color:#FFF;border-color:inherit;color:#333;text-align:left;vertical-align:top}
.tg .tg-0hty{background-color:#000000;border-color:inherit;color:#ffffff;font-weight:bold;text-align:left;vertical-align:top}
.tg .tg-kwiq{border-color:inherit;color:#000000;text-align:left;vertical-align:top;word-wrap:break-word}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg" style="undefined;table-layout: fixed; width: 996px">
<colgroup>
<col style="width: 101.333333px">
<col style="width: 203.333333px">
<col style="width: 282.333333px">
<col style="width: 185.33333px">
<col style="width: 78.333333px">
<col style="width: 220.333333px">
</colgroup>
<thead>
<tr>
<th class="tg-0hty">Service</th>
<th class="tg-0hty">Link</th>
<th class="tg-0hty">User / Pass</th>
<th class="tg-0hty">Access</th>
<th class="tg-0hty">Docs</th>
<th class="tg-0hty">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-kwiq">Matrix</td>
<td class="tg-kwiq"><a href="https://element.$DOMAIN" target="_blank" rel="noopener noreferrer"><span style="color:#340096">element.$DOMAIN</span></a></td>
<td class="tg-kwiq">admin@$DOMAIN<br>$ADMINPASS</td>
<td class="tg-kwiq">All users in panel have access using user@$DOMAIN</td>
<td class="tg-kwiq"><a href="https://documentation.federated.computer/docs/getting_started/welcome/" target="_blank" rel="noopener noreferrer"><span style="color:#340096">Click here</span></a></td>
<td class="tg-kwiq">Matrix (a Slack replacement) provides you the ability to chat with those on your team and outside of your team</td>
</tr>
</tbody>
</table>
<h4>Thanks for your support!</h4>
<p>
Thank you for your support of Federated Computer. We really appreciate it and hope you have a very successful
time with Federated Core.
<p>
Again, if we can be of any assistance, please don't hesitate to get in touch.
<p>
Support: https://support.federated.computer<br>
Phone: (970) 722-8715<br>
Email: support@federated.computer<br>
<p>
It's <b>your</b> computer. Let's make it work for you!
</html>
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"
}

View File

@ -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;

7
lib/test Executable file
View File

@ -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"