#!/bin/bash # # Discourse Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin . /etc/federated get_appvars config_discourse() { echo -ne "* Configuring discourse container.." [[ ! -d "/federated/apps/redis" ]] && failcheck "Redis needs installed first. Run installapp redis" if [ ! -d "/federated/apps/discourse" ]; then mkdir -p /federated/apps/discourse/data/discourse/bitnami/discourse mkdir -p /federated/apps/discourse/data/sidekiq/bitnami/discourse mkdir -p /federated/apps/discourse/data/discourse/log touch /federated/apps/discourse/data/discourse/log/.gitkeep fi chown lxd /federated/apps/discourse/data/discourse/log chmod 775 /federated/apps/discourse/data/discourse/log chown lxd:root /federated/apps/discourse/data/discourse/log/.gitkeep chmod 664 /federated/apps/discourse/data/discourse/log/.gitkeep cat > /federated/apps/discourse/docker-compose.yml < /etc/logrotate.d/federated < /federated/apps/discourse/.env < /dev/null docker exec postgresql psql -U postgres -c "CREATE DATABASE discourse" &> /dev/null docker exec postgresql psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE discourse TO discourse" &> /dev/null echo -ne "done.\n" } start_discourse() { # Start service with command to make sure it's up before proceeding start_service "discourse" "nc -z 192.168.0.43 3000 &> /dev/null" "70" docker exec postgresql psql -U discourse -c "update users set username='admin@$DOMAIN' where username='admin';" &> /dev/null docker exec postgresql psql -U discourse -c "update users set username_lower='admin@$DOMAIN' where username_lower='admin';" &> /dev/null docker exec postgresql psql -U discourse -c "update site_settings set value='discourse@$DOMAIN' where name='notification_email';" &> /dev/null if [[ "${PLUS}" != "true" ]]; then docker exec pdns pdnsutil add-record $DOMAIN discourse A 86400 $EXTERNALIP &> /dev/null docker exec pdns pdnsutil add-record $DOMAIN forum A 86400 $EXTERNALIP &> /dev/null fi echo -ne "done.\n" } email_discourse() { echo -ne "* Sending email to customer.." cat > /federated/apps/mail/data/root/certs/mailfile <

Discourse is now installed on $DOMAIN

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

Applications

Service Link User / Pass Access Docs Description
Discourse discourse.$DOMAIN admin@$DOMAIN
$ADMINPASS
User access is separate from panel Click here Discourse is a simple, open-source, self-hosted, easy-to-use platform (Wiki) for organising and storing information

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_discourse() { echo -ne "* Uninstalling discourse container.." # First stop the service cd /federated/apps/discourse && docker compose -f docker-compose.yml -p discourse down &> /dev/null # Delete database and user in postgresql docker exec postgresql psql -U postgres -c "DROP DATABASE discourse" &> /dev/null docker exec postgresql psql -U postgres -c "DROP USER discourse" &> /dev/null # Delete the app directory rm -rf /federated/apps/discourse if [[ "${PLUS}" != "true" ]]; then docker exec pdns pdnsutil delete-rrset $DOMAIN discourse A &> /dev/null docker exec pdns pdnsutil delete-rrset $DOMAIN forum A &> /dev/null fi echo -ne "done.\n" } configsso_discourse() { if [[ "${PLUS}" != "true" ]]; then echo -ne "* Configuring discourse 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 "### Discourse" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]] && failcheck "Authelia already has a Discourse configuration." DISCOURSE_CLIENT_SECRET=$(create_password); DISCOURSE_CLIENT_SECRET_HASH=$(docker run --rm authelia/authelia:latest authelia crypto hash generate pbkdf2 --password $DISCOURSE_CLIENT_SECRET | awk '{ print $2 }') echo "$DISCOURSE_CLIENT_SECRET" > /federated/apps/discourse/.discourse.client.secret cat >> /federated/apps/authelia/data/config/idproviders.yml <