#!/bin/bash # # Roundcube Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin get_appvars config_roundcube() { echo -ne "\n* Configuring roundcube container.." if [ ! -d "/federated/apps/roundcube" ]; then mkdir -p /federated/apps/roundcube/data/var/www/html fi cat > /federated/apps/roundcube/docker-compose.yml < /federated/apps/roundcube/.env < /dev/null docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -e \"CREATE USER 'roundcube'@'%' IDENTIFIED BY '$ROUNDCUBE_SECRET';\"" &> /dev/null docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -e \"grant all privileges on roundcube.* to 'roundcube'@'%';\"" &> /dev/null docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -e 'flush privileges;'" &> /dev/null echo -ne "done.\n" } start_roundcube() { # Start service with command to make sure it's up before proceeding start_service "roundcube" "nc -z 172.99.0.47 80 &> /dev/null" "7" docker exec pdns pdnsutil add-record $DOMAIN roundcube A 86400 $EXTERNALIP &> /dev/null [ $? -ne 0 ] && fail "Couldn't add dns record for roundcube" docker exec pdns pdnsutil add-record $DOMAIN webmail A 86400 $EXTERNALIP &> /dev/null [ $? -ne 0 ] && fail "Couldn't add dns record for roundcube" kill -9 $SPINPID &> /dev/null echo -ne "done.\n" } email_roundcube() { echo -ne "* Sending email to customer.." spin & SPINPID=$! cat > /federated/apps/mail/data/root/certs/mailfile <

Roundcube is now installed on $DOMAIN

Dear Customer,

We'd like to introduce you to "Roundcube", a free and open source webmail solution with a desktop-like user interface. You can find "Roundcube" at https://roundcube.$DOMAIN and also on your Dashboard https://dashboard.$DOMAIN as a new application.

This is only one of a number of big changes you'll be seeing from Federated Computer in the coming months to improve and enhance your Federated Core. Thank you for being a customer!

Best,
Federated Computer

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_roundcube() { echo -ne "* Uninstalling roundcube container.." spin & SPINPID=$! # First stop the service cd /federated/apps/roundcube && docker-compose -f docker-compose.yml -p roundcube down &> /dev/null # Delete database and user docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -e 'drop database roundcube;'" &> /dev/null docker exec pdnsmysql bash -c "mysql -uroot -p$MYSQL_ROOTPASSWORD -e 'drop user roundcube;'" &> /dev/null # Delete the app directory rm -rf /federated/apps/roundcube # Delete the image docker image rm roundcube/roundcubemail:$IMAGE_VERSION &> /dev/null # Delete the DNS record docker exec pdns pdnsutil delete-rrset $DOMAIN roundcube A # Uninstall the SSO configuration if it exists in authelia (authelia must exist too) if [[ $(grep "### Roundcube" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]]; then sed -i '/### Roundcube/,/### /{/### PowerDNS/!{/### /!d}}' /federated/apps/authelia/data/config/idproviders.yml sed -i '/### Roundcube/d' /federated/apps/authelia/data/config/idproviders.yml /federated/bin/stop authelia /federated/bin/start authelia fi kill -9 $SPINPID &> /dev/null echo -ne "done.\n" } configsso_roundcube() { [ ! -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 "### Roundcube" /federated/apps/authelia/data/config/idproviders.yml 2>/dev/null) ]] && failcheck "Authelia already has a Roundcube configuration." ROUNDCUBE_CLIENT_SECRET=$(create_password); ROUNDCUBE_CLIENT_SECRET_HASH=$(docker run -it --rm authelia/authelia:latest authelia crypto hash generate pbkdf2 --password $ROUNDCUBE_CLIENT_SECRET | awk '{ print $2 }') cat >> /federated/apps/authelia/data/config/idproviders.yml <