2021-04-20 14:26:46 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# must be root
|
|
|
|
if [ "$USER" != "root" ]; then
|
|
|
|
echo "You must be root to run this installer."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for vmail-stack & vhost-stack installs & required configs
|
|
|
|
if [ -f "/usr/local/bin/vhost.sh" ] && [ -d "/srv/www/html" ] && [ -f "/usr/local/bin/vmail.sh" ] && [ -f "/var/vmail/.my.cnf" ]; then
|
|
|
|
# check for existing roundcube webmail install
|
|
|
|
if [ -d "/srv/www/html/roundcube" ]; then
|
|
|
|
echo "Roundcube webmail app is already installed."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Missing required installs/configurations."
|
|
|
|
echo "You must install vhost-stack & vmail-stack first."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# get current working dir, so we can come back here later
|
|
|
|
installer_dir=$(dirname $(readlink -f $0))
|
|
|
|
|
|
|
|
cd /usr/local/src/
|
|
|
|
wget https://github.com/roundcube/roundcubemail/releases/download/1.4.11/roundcubemail-1.4.11-complete.tar.gz
|
|
|
|
tar zxf roundcubemail-1.4.11-complete.tar.gz
|
|
|
|
mv roundcubemail-1.4.11 /srv/www/html/roundcube
|
|
|
|
|
|
|
|
cd /usr/local/src/
|
|
|
|
wget https://github.com/johndoh/roundcube-sauserprefs/archive/refs/tags/1.18.4.tar.gz -O roundcube-sauserprefs-1.18.4.tar.gz
|
|
|
|
tar zxf roundcube-sauserprefs-1.18.4.tar.gz
|
|
|
|
mv roundcube-sauserprefs-1.18.4 /srv/www/html/roundcube/plugins/sauserprefs
|
|
|
|
|
|
|
|
cd $installer_dir
|
|
|
|
|
|
|
|
cp config/config.inc.php /srv/www/html/roundcube/config/config.inc.php
|
|
|
|
# get vmail db settings and set db connection info
|
|
|
|
dbhost=`grep -m 1 host /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`
|
|
|
|
dbdatabase=`grep -m 1 database /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`
|
|
|
|
dbuser=`grep -m 1 user /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`
|
|
|
|
dbpass=`grep -m 1 password /var/vmail/.my.cnf |cut -d = -f 2|cut -d ' ' -f 2`
|
|
|
|
sed -i "s|.*db_dsnw.*|\$config['db_dsnw'] = 'mysql://$dbuser:$vmail_password@$dbhost/$dbdatabase';|g" /srv/www/html/roundcube/config/config.inc.php
|
|
|
|
|
2021-04-21 11:17:21 -07:00
|
|
|
apt-get update
|
|
|
|
|
2021-04-20 14:26:46 -07:00
|
|
|
# make sure pwgen is installed
|
|
|
|
apt-get -qq -y install pwgen
|
|
|
|
|
|
|
|
# create random key
|
|
|
|
des_key=`pwgen -1 24`
|
|
|
|
sed -i "s|.*des_key.*|\$config['des_key'] = '$des_key';|g" /srv/www/html/roundcube/config/config.inc.php
|
|
|
|
|
|
|
|
# install plugins / configs
|
|
|
|
cp -a plugins/* /srv/www/html/roundcube/plugins/
|
|
|
|
sed -i "s|.*sauserprefs_db_dsnw*|\$config['sauserprefs_db_dsnw'] = 'mysql://$dbuser:$vmail_password@$dbhost/$dbdatabase';|g" /srv/www/html/roundcube/plugins/sauserprefs/config.inc.php
|
|
|
|
|
|
|
|
# create tmp files storage dir
|
|
|
|
install --owner=www-data --group=www-data --mode=750 --directory /var/tmp/roundcube
|
|
|
|
|
|
|
|
# set permissions
|
|
|
|
# # USER=$(stat -c '%U' /srv/www/html)
|
|
|
|
# # GROUP=$(stat -c '%G' /srv/www/html)
|
|
|
|
# # chown -R $USER:$GROUP /srv/www/html/roundcube
|
|
|
|
find /srv/www/html/roundcube -type d -exec chmod 755 {} +
|
|
|
|
find /srv/www/html/roundcube -type f -exec chmod 644 {} +
|
|
|
|
chmod 755 /srv/www/html/roundcube/bin/*.sh
|
|
|
|
|
|
|
|
# load roundcube database tables
|
|
|
|
mysql vmail < rc.sql
|
|
|
|
|
2021-04-20 14:34:15 -07:00
|
|
|
# install & enable rc systemd cron
|
|
|
|
cp sbin/rc-cron.sh /usr/local/sbin/
|
|
|
|
chmod 755 /usr/local/sbin/rc-cron.sh
|
|
|
|
cp systemd/rc-cron.* /usr/lib/systemd/system/
|
|
|
|
chmod 644 /usr/lib/systemd/system/rc-cron.*
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl start rc-cron.timer
|
|
|
|
|
2021-04-20 14:26:46 -07:00
|
|
|
echo "Roundcube webmail installed."
|
|
|
|
echo "You can optionally set the vars 'product_name' & 'support_url' in /srv/www/html/roundcube/config/config.inc.php"
|