Update 'installer.sh'

This commit is contained in:
b.waal
2019-09-18 21:53:27 +02:00
parent 211ce8b0b8
commit 6b93846d95

View File

@@ -93,7 +93,7 @@ chmod -R 755 /var/www
##----------------------##
TERM=ansi whiptail --title "Info" --infobox " Buzzy like a bee" 8 52
$PKGM update
$PKGI software-properties-common
$PKGI software-properties-common sudo
$PKGA universe -y > $OUTPUT 2>&1
$PKGA ppa:ondrej/php -y > $OUTPUT 2>&1
wget -q -O- https://repo.dovecot.org/DOVECOT-REPO-GPG | sudo apt-key add -
@@ -116,7 +116,7 @@ $PKGM autoremove -y
# HTML Folder Perms #
##-----------------------##
TERM=ansi whiptail --title "Info" --infobox " Configuring HTML permissions" 8 52
sleep 1
sleep 2
chown -R www-data:www-data /var/www/"$domain"/html
##-----------##
@@ -124,7 +124,7 @@ chown -R www-data:www-data /var/www/"$domain"/html
##-----------##
#$PKGI nginx
TERM=ansi whiptail --title "Info" --infobox " Configuring Nginx" 8 52
sleep 1
sleep 2
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Web/raw/branch/master/config/nginx/nginx-default.conf -O /etc/nginx/nginx.conf
cat <<EOF > /etc/nginx/sites-available/"$domain"
@@ -242,7 +242,7 @@ ln -s /etc/nginx/sites-available/"$domain" /etc/nginx/sites-enabled/
# NGINX Single core bug fix #
##-------------------------------##
TERM=ansi whiptail --title "Info" --infobox " Applying Nginx bug-fix" 8 52
sleep 1
sleep 2
mkdir /etc/systemd/system/nginx.service.d
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
systemctl daemon-reload
@@ -258,6 +258,7 @@ source /tmp/mysql-8.0.sh
# MySQL_Secure_Installation #
##------------------------------##
TERM=ansi whiptail --title "Info" --infobox " Securing MySQL" 8 52
sleep 2
mysql -u root -p"$password" -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')" > $OUTPUT 2>&1
mysql -u root -p"$password" -e "DELETE FROM mysql.user WHERE User=''" > $OUTPUT 2>&1
mysql -u root -p"$password" -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'" > $OUTPUT 2>&1
@@ -269,6 +270,7 @@ mysql -u root -p"$password" -e "FLUSH PRIVILEGES;" > $OUTPUT 2>&1
# MySQL Database Creation #
##-----------------------------##
TERM=ansi whiptail --title "Info" --infobox " Creating MySQL Databases" 8 52
sleep 2
mysql -u root -p"$password" -e "CREATE DATABASE postfixadmin;" > $OUTPUT 2>&1
mysql -u root -p"$password" -e "CREATE USER '"postfixadmin"'@'localhost' IDENTIFIED BY '"$password"';" > $OUTPUT 2>&1
mysql -u root -p"$password" -e "GRANT ALL ON "postfixadmin".* TO "postfixadmin"@'localhost';" > $OUTPUT 2>&1
@@ -281,6 +283,7 @@ mysql -u root -p"$password" -e "FLUSH PRIVILEGES;" > $OUTPUT 2>&1
#$PKGI php${phpver} php${phpver}-zip php${phpver}-fpm php${phpver}-cli php${phpver}-json php${phpver}-mysql php${phpver}-opcache php${phpver}-mbstring php${phpver}-readline
#$PKGI libc-client2007e mlock php${phpver}-common php${phpver}-imap
TERM=ansi whiptail --title "Info" --infobox " Configuring PostfixAdmin" 8 52
sleep 2
mkdir -p /var/www/"$domain"/html/postfixadmin/templates_c
wget -q -t7 https://git.ictmaatwerk.com/downloads/pfa/postfixadmin-3.1-dark.tar.gz -O /tmp/postfixadmin.tar.gz
tar -xf /tmp/postfixadmin.tar.gz -C /var/www/"$domain"/html/postfixadmin --strip-components=1
@@ -288,6 +291,7 @@ chmod 755 -R /var/www/"$domain"/html/postfixadmin/templates_c
chown -R www-data: /var/www/"$domain"/html/
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/postfixadmin/config.local.php -O /var/www/$domain/html/postfixadmin/config.local.php
sed -i -e 's/PASSword/'$password'/' -e 's/dOmaINnamE/'$domonly'/' /var/www/"$domain"/html/postfixadmin/config.local.php
sed -i 's/Welcome to your new account./Welkom bij je nieuwe mailbox!/g' /var/www/"$domain"/html/postfixadmin/config.inc.php
sudo -u www-data php /var/www/"$domain"/html/postfixadmin/upgrade.php > $OUTPUT 2>&1
bash /var/www/"$domain"/html/postfixadmin/scripts/postfixadmin-cli admin add superadmin@"$domonly" --superadmin 1 --active 1 --password "$password" --password2 "$password" > $OUTPUT 2>&1
groupadd -g 5000 vmail > $OUTPUT 2>&1
@@ -296,7 +300,8 @@ useradd -u 5000 -g vmail -s /usr/sbin/nologin -d /var/mail/vmail -m vmail > $OUT
##--------------------##
# Certbot (Auto) #
##--------------------##
TERM=ansi whiptail --title "Info" --infobox " Configuring Certbot" 8 52
#TERM=ansi whiptail --title "Info" --infobox " Configuring Certbot" 8 52
#sleep 2
#add-apt-repository ppa:certbot/certbot -y
#apt install -y python-certbot-nginx
#certbot --nginx -n -d "$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos
@@ -311,7 +316,7 @@ TERM=ansi whiptail --title "Info" --infobox " Configuring Certbot"
# Certbot (Manual) #
##----------------------##
TERM=ansi whiptail --title "Info" --infobox " Configuring Certbot (manual)" 8 52
sleep 1
sleep 2
mkdir -p /etc/letsencrypt/live/$domain/
sed -i 's/ssl ipv6only/ssl http2 ipv6only/g' /etc/nginx/sites-available/"$domain"
sed -i 's/listen 443 ssl/listen 443 ssl http2/g' /etc/nginx/sites-available/"$domain"
@@ -342,7 +347,7 @@ debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Si
# Postfix Configuration #
##---------------------------##
TERM=ansi whiptail --title "Info" --infobox " Configuring Postfix" 8 52
sleep 1
sleep 2
mkdir -p /etc/postfix/sql
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/postfix/mysql_virtual_alias_domain_catchall_maps.cf -O /etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/postfix/mysql_virtual_alias_domain_mailbox_maps.cf -O /etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
@@ -393,7 +398,7 @@ wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/$bran
# Dovecot Configuration #
##---------------------------##
TERM=ansi whiptail --title "Info" --infobox " Configuring Dovecot" 8 52
sleep 1
sleep 2
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/dovecot/15-mailboxes.conf -O /etc/dovecot/conf.d/15-mailboxes.conf
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/dovecot/10-mail.conf -O /etc/dovecot/conf.d/10-mail.conf
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/dovecot/10-auth.conf -O /etc/dovecot/conf.d/10-auth.conf
@@ -413,7 +418,7 @@ chmod +x /usr/local/bin/quota-warning.sh
# Dovecot move Spam to Spam Folder #
##--------------------------------------##
TERM=ansi whiptail --title "Info" --infobox " Configuring Spam Folder" 8 52
sleep 1
sleep 2
#$PKGI dovecot-sieve dovecot-managesieved
mkdir -p /etc/dovecot/sieve/
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/$branch/config/dovecot/15-lda.conf -O /etc/dovecot/conf.d/15-lda.conf
@@ -429,7 +434,7 @@ chgrp dovecot /etc/dovecot/sieve/default.svbin > $OUTPUT 2>&1
##------------------##
#$PKGI spamassassin spamc razor pyzor
TERM=ansi whiptail --title "Info" --infobox " Configuring Spamassassin" 8 52
sleep 1
sleep 2
sed -i -e 's/# report_safe 1/report_safe 0/' -e 's/# required_score 5.0/required_score 5.0/' -e 's/endif # Mail::SpamAssassin::Plugin::Shortcircuit//' /etc/spamassassin/local.cf
echo "" >> /etc/spamassassin/local.cf
echo "skip_rbl_checks 0" >> /etc/spamassassin/local.cf
@@ -455,7 +460,7 @@ echo "endif # Mail::SpamAssassin::Plugin::Shortcircuit" >> /etc/spamassassin/loc
##------------##
#$PKGI clamav clamav-daemon clamsmtp libclamunrar7 clamdscan
TERM=ansi whiptail --title "Info" --infobox " Configuring ClamAV" 8 52
sleep 1
sleep 2
mkdir -p /var/log/clamav
mkdir -p /var/lib/clamav
chown -R clamav:clamav /var/log/clamav
@@ -468,7 +473,7 @@ chmod 775 -R /var/lib/clamav/* /var/lib/clamav
#$PKGI amavisd-new
#$PKGI zip lrzip liblz4-tool lhasa arj unzip bzip2 nomarch cpio lzop cabextract arc apt-listchanges libauthen-sasl-perl libdbd-mysql-perl libdbi-perl libmail-dkim-perl ripole p7zip p7zip-full p7zip-rar rpm unrar unrar-free altermime libsnmp-perl libnet-ldap-perl libnet-ph-perl libnet-snpp-perl libnet-telnet-perl
TERM=ansi whiptail --title "Info" --infobox " Configuring Amavis" 8 52
sleep 1
sleep 2
sed -i -e 's/@bypass/'@bypass'/' -e 's/ / /' /etc/amavis/conf.d/15-content_filter_mode
adduser clamav amavis >/dev/null
sed -i 's/clamd.conf/'clamd.conf'/g' /etc/clamav/freshclam.conf
@@ -503,7 +508,7 @@ wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$bra
##--------------##
#$PKGI unzip
TERM=ansi whiptail --title "Info" --infobox " Configuring Rainloop" 8 52
sleep 1
sleep 2
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/rainloop.sh -O /tmp/rainloop.sh
source /tmp/rainloop.sh > $OUTPUT 2>&1
ln -s /opt/rainloop /var/www/"$domain"/html/
@@ -513,7 +518,7 @@ ln -s /opt/rainloop /var/www/"$domain"/html/
##--------------##
#$PKGI fail2ban
TERM=ansi whiptail --title "Info" --infobox " Configuring Fail2Ban" 8 52
sleep 1
sleep 2
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/fail2ban/dovecot-pop3imap.conf -O /etc/fail2ban/filter.d/dovecot-pop3imap.conf
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/fail2ban/postfix-sasl.conf -O /etc/fail2ban/filter.d/postfix-sasl.conf
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Ubuntu-Mail/raw/branch/"$branch"/config/fail2ban/rainloop.conf -O /etc/fail2ban/filter.d/rainloop.conf
@@ -525,45 +530,45 @@ systemctl restart fail2ban > $OUTPUT 2>&1
# Unattended Security Updates #
##---------------------------------##
TERM=ansi whiptail --title "Info" --infobox " Configuring Unattended Security Updates" 8 52
sleep 1
sleep 2
wget -q -t7 https://git.ictmaatwerk.com/VPS-scripts/Unattended-Security-Updates/raw/branch/master/installer.sh -O /tmp/unattended.sh
source /tmp/unattended.sh
##-----------------------##
# Enabling Services #
# Enabling services #
##-----------------------##
TERM=ansi whiptail --title "Info" --infobox " Enabling Services" 8 52
sleep 1
sleep 2
systemctl enable nginx mysql postfix postfix@- dovecot fail2ban clamav-daemon clamav-freshclam clamsmtp spamassassin > $OUTPUT 2>&1
##-------------------------------##
# Disabling Services on boot #
##-------------------------------##
##-----------------------------------------##
# Disabling services autostart on boot #
##-----------------------------------------##
systemctl disable amavisd-snmp-subagent amavis-mc
##----------------------##
# Stopping Services #
# Stopping services #
##----------------------##
systemctl stop amavisd-snmp-subagent amavis-mc postfix dovecot
##-----------------------##
# Starting Services #
# Starting services #
##-----------------------##
TERM=ansi whiptail --title "Info" --infobox " Restarting Services" 8 52
sleep 1
systemctl restart nginx mysql postfix@- fail2ban clamav-daemon clamav-freshclam clamsmtp spamassassin > $OUTPUT 2>&1
##---------------------------------##
# Updating ClamAV Definitions #
# Updating ClamAV definitions #
##---------------------------------##
{
for ((i = 0 ; i <= 100 ; i+=1)); do sleep 3.0
echo $i
done
} | whiptail --gauge " Please wait while ClamAV is updating definitions..." 6 50 0
} | whiptail --gauge " Please wait while ClamAV is updating definitions..." 6 52 0
##-------------------------------------------##
# Starting AntiVirus & AntiSpam Services #
# Starting AntiVirus & AntiSpam services #
##-------------------------------------------##
systemctl start amavisd-snmp-subagent amavis-mc postfix dovecot
@@ -576,7 +581,7 @@ echo "@reboot root systemctl stop amavisd-snmp-subagent amavis-mc postfix doveco
# Final Update #
##------------------##
TERM=ansi whiptail --title "Info" --infobox " Final Update" 8 52
sleep 1
sleep 2
$PKGM update
$PKGM upgrade -y
$PKGM autoremove -y
@@ -587,4 +592,5 @@ $PKGM autoremove -y
TERM=ansi whiptail --title "Info" --infobox " Done installing!" 8 52
sleep 3
whiptail --title "Credits" --msgbox " Made by: your local Wizard and God" 8 78
whiptail --title "Info" --msgbox "Point your browser to https://$domain/postfixadmin to get started" 8 108
clear