starting to build vmail-installer

This commit is contained in:
Matthew Saunders Brown 2021-02-19 14:18:16 -08:00
parent 6b72c5fe07
commit 3b005959b9
2 changed files with 72 additions and 34 deletions

View File

@ -1,3 +1,75 @@
#!/bin/bash #!/bin/bash
echo 'installing vmail-stack now!' echo 'installing vmail-stack now!'
apt -y install mariadb-client mariadb-server
## config mariadb
apt -y install apache2 libapache2-mod-authnz-pam libwww-perl php-fpm php-cli php-ssh2 php-curl php-dev php-enchant php-mysql php-pear php-gd php-http php-imap php-intl php-mysql php-yaml php-propro php-pspell php-raphf php-ssh2 php-sqlite3 php-tidy php-xml php-xmlrpc php-zip php-mbstring php-imagick php-redis redis pwauth libapache2-mod-authnz-external
## adjust above package list
a2enmod rewrite headers expires ssl http2 macro
# configure mod_macro
# configure php
# configure apache security
## below needs to be cleaned up (remove 'stack' stuff)
# mail stack
apt -y --install-suggests install spamassassin libclass-dbi-mysql-perl
apt -y install exim4-daemon-heavy spf-tools-perl dovecot-core dovecot-imapd dovecot-mysql dovecot-pop3d dovecot-lmtpd
usermod -a -G ssl-cert Debian-exim
groupadd --gid 500 vmail
useradd --create-home --home-dir /var/vmail --shell /bin/false --uid 500 --gid 500 vmail
chmod 750 /var/vmail/
mkdir /etc/ssl/dkim
chown Debian-exim:ssl-cert /etc/ssl/dkim
chmod 750 /etc/ssl/dkim
sed -i 's/size 10M/daily/g' /etc/logrotate.d/exim4-paniclog
# # chown Debian-exim:Debian-exim /etc/exim4/autowhitelist.filter
# # chmod 640 /etc/exim4/autowhitelist.filter
mysqladmin create vmail
## fix this path
mysql < .../vmail.sql
VMAILPASS=`pwgen -1 12`
mysql -e "CREATE USER 'vmail'@'localhost' IDENTIFIED BY '$VMAILPASS';"
mysql -e "GRANT ALL PRIVILEGES ON vmail.* TO 'vmail'@'localhost';"
# spamassassin config
sed -i "s|userpref|sa_userpref|g" /usr/share/doc/spamassassin/sql/userpref_mysql.sql
sed -i "s|username varchar(100)|username varchar(255)|g" /usr/share/doc/spamassassin/sql/userpref_mysql.sql
sed -i "s|TYPE=MyISAM||g" /usr/share/doc/spamassassin/sql/userpref_mysql.sql
mysql vmail < /usr/share/doc/spamassassin/sql/userpref_mysql.sql
sed -i 's|OPTIONS="--create-prefs --max-children 5 --helper-home-dir"|OPTIONS="-x -q -v -u Debian-exim -m 5"|g' /etc/default/spamassassin
sed -i 's|CRON=0|CRON=1|g' /etc/default/spamassassin
systemctl enable spamassassin.service
cp /opt/stack/server_configs/etc/spamassassin/* /etc/spamassassin/
sed -i "s|user_scores_sql_password password|user_scores_sql_password $VMAILPASS|g" /etc/spamassassin/sql.cf
chown root:root /etc/spamassassin/local.cf
chmod 644 /etc/spamassassin/local.cf
chown debian-spamd:mail /etc/spamassassin/sql.cf
chmod 640 /etc/spamassassin/sql.cf
service spamassassin restart
# exim config
install --owner=Debian-exim --group=Debian-exim --mode=640 /dev/null /etc/exim4/relay_domains
cp /opt/stack/server_configs/etc/exim4/* /etc/exim4/
chown Debian-exim:Debian-exim /etc/exim4/autowhitelist.filter
chown Debian-exim:Debian-exim /etc/exim4/return-resender.sh
chown Debian-exim:Debian-exim /etc/exim4/skip_greylisting_hosts
sed -i "s|password|$VMAILPASS|g" /etc/exim4/exim_local.conf
service exim4 restart
# dovecot config
mkdir /etc/dovecot/sites.d
cp -a /opt/stack/server_configs/etc/dovecot/* /etc/dovecot/
chgrp dovecot /etc/dovecot/dovecot-sql.conf.ext
sed -i "s|password=password|password=$VMAILPASS|g" /etc/dovecot/dovecot-sql.conf.ext
cp -a /opt/stack/server_configs/usr/local/sbin/vmail-quota-warning.sh /usr/local/sbin/
chmod 750 /usr/local/sbin/vmail-quota-warning.sh
chown dovecot:mail /usr/local/sbin/vmail-quota-warning.sh
service dovecot restart
# set webmail password
sed -i "s|vmail:password@localhost|vmail:$VMAILPASS@localhost|g" /var/www/html/webmail/config/config.inc.php
sed -i "s|vmail:password@localhost|vmail:$VMAILPASS@localhost|g" /var/www/html/webmail/plugins/sauserprefs/config.inc.php
# Let's Encrypt

View File

@ -1,34 +0,0 @@
#!/bin/bash
#
# vmail-stack
# https://git.stack-source.com/msb/vmail-stack
# MIT License Copyright (c) 2021 Matthew Saunders Brown
# load config
source /opt/stack/include/config.inc
# check for and set virtualhost
if [ -n "$1" ]; then
virtualhost=$1
else
echo "virtualhost not set"
exit 1
fi
check that IP points here
install le cert
create dovecot conf
vhost-enable
dkim
_dmarc.example.com 3600 TXT "v=DMARC1; p=reject;"
letsencrypt-certonly.sh
vmail.sh create domain
vhost VHostMAIL
dovecot/sites.d/
# enable webmail vhost & restart apache
webmail-enable.sh $virtualhost