Bitnami Roundcube

From Coolscript
Jump to navigation Jump to search

Protoype of Bitnami Cloud Image (AWS/Azure)

Configure

  • Configure Mail Target: /opt/bitnami/roundcube/config/config.inc.php
$config['imap_host'] = 'ssl://mail.domain.com:993';
$config['smtp_host'] = 'tls://mail.domain.com:587';
#Consider to do this!
$config['smtp_auth_type'] = 'PLAIN';
  • Letsencryp install (2023)
apt install snapd
snap install core
snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
  • Automatic Cert Renewal
systemctl stop bitnami
certonly --domain mail.coolscript.org --renew-by-default  --standalone
cp /etc/letsencrypt/live/mail.domain.org/cert.pem  /opt/bitnami/apache2/conf/bitnami/certs/server.crt
cp /etc/letsencrypt/live/mail.domain.org/privkey.pem  /opt/bitnami/apache2/conf/bitnami/certs/server.key
systemctl start bitnami


Optional Renew the DNS A Record at startup

  • /etc/systemd/system/renew-dns.service
[Unit]
Description=Renew DNS Name of mail.domain.org

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/usr/local/bin/cfddns.pl -c /usr/local/bin/cfddns.xml -v | logger
Type=simple
WorkingDirectory=/usr/local/bin
Restart=on-failure
  • Enable
systemctl enable renew-dns.service

Optional Auto Shutdown

  • /etc/systemd/system/autoshut.service
[Unit]
Description=Init Auto Shutdown after 8 hours

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=shutdown -P +480
ExecStop=shutdown -c
RemainAfterExit=yes
Type=simple

Restart=on-failure
systemctl enable autoshut
  • start
systemctl start autoshut
  • stop
systemctl stop autoshut
  • Check to see when autoshutdown applies
systemctl status autoshut
or
if [ -f /run/systemd/shutdown/scheduled ]; then   perl -wne 'm/^USEC=(\d+)\d{6}$/ and printf("Shutting down at: %s\n", scalar localtime $1)' < /run/systemd/shutdown/scheduled; fi

Cert Renewal

#!/bin/bash
#Check the age of the certificate and renew if the condition is matching
file=/etc/letsencrypt/live/mail.coolscript.org/cert.pem

#30 Days
#maxAge=2592000
#1 Day
#maxAge=86400
#7 Day
maxAge=604800
#Test
#maxAge=30
if [ `stat --format=%Y $file` -le $(( `date +%s` - $maxAge )) ]; then
   echo "Renew Certificates as they are older than $maxAge secs - Checked file: $file"
   #Renew mail cert
   echo Certificate Renewal | logger
   systemctl stop bitnami
   certbot certonly --domain mail.coolscript.org --renew-by-default  --standalone | logger
   cp /etc/letsencrypt/live/mail.coolscript.org/cert.pem  /opt/bitnami/apache2/conf/bitnami/certs/server.crt
   cp /etc/letsencrypt/live/mail.coolscript.org/privkey.pem  /opt/bitnami/apache2/conf/bitnami/certs/server.key
   systemctl start bitnami
else
 echo Certificate Renewal | logger
 echo Certificate Renewal
 echo Nothing to do, Certificate age is less then $maxAge | logger
 echo Nothing to do, Certificate age is less then $maxAge
fi

Shutdown Message

[Unit]
Description=Send a Shutdown message
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/shutdown-message.sh
TimeoutStartSec=0

[Install]
WantedBy=shutdown.target

Other Services

Reboot Message: https://coolscript.org/index.php/Reboot_message
SSH Logon Message: https://coolscript.org/index.php/Sshrc