Update mail-aio.sh

This commit is contained in:
myve 2024-03-25 07:15:45 -06:00
commit f933144e60

View file

@ -922,7 +922,7 @@ ln -s /etc/nginx/sites-available/mail.conf /etc/nginx/sites-enabled/
# Certbot # Certbot
systemctl -q disable --now apache2.service systemctl -q disable --now apache2.service
systemctl -q reload nginx.service systemctl -q reload nginx.service
/etc/init.d/php*-fpm reload /etc/init.d/php*-fpm reload >/dev/null
until certbot --nginx --agree-tos --redirect --hsts --no-eff-email --staple-ocsp -m ${eff_email} -d ${subdomain}.${domain} until certbot --nginx --agree-tos --redirect --hsts --no-eff-email --staple-ocsp -m ${eff_email} -d ${subdomain}.${domain}
do do
@ -954,44 +954,33 @@ ln -s /usr/share/webapps/roundcube/bin/cleandb.sh /etc/cron.daily/roundcube-clea
echo -e '\n\e[1;34mInstalling Postwhite\e[0m' echo -e '\n\e[1;34mInstalling Postwhite\e[0m'
/usr/local/bin/postwhite/postwhite /usr/local/bin/postwhite/postwhite
# echo -e '\n\e[1;34mRestarting system services...\e[0m'
# /etc/init.d/php*-fpm restart
# systemctl -q restart postfix.service dovecot.service opendkim.service opendmarc.service nginx.service mariadb.service fail2ban.service
# # Check DKIM key
# while :
# do
# if opendkim-testkey -d ${domain} -s default
# then
# echo -e '\n\e[1;32mDKIM key has been verified!\e[0m'
# break
# fi
# sleep 5
# done &
# disown
su ${username} <<"CHANGEUSER" su ${username} <<"CHANGEUSER"
# SSH # SSH
yes | ssh-keygen -t ed25519 -q -f ~/.ssh/id_ed25519 -P "" yes | ssh-keygen -t ed25519 -q -f ~/.ssh/id_ed25519 -P ""
echo "${sshkeys}" >~/.ssh/authorized_keys echo "${sshkeys}" >~/.ssh/authorized_keys
# Home directory mods
echo -e '\nif [ -f ~/.bash_history ]
then
rm -f ~/.bash_history
fi
# Home directory mods
cat >>~/.bashrc <<bashrc
# Apt upgrade
alias syu='sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y'
# Disable shell history
unset HISTFILE unset HISTFILE
if [ -f \${HISTFILE} ]
then
rm -f \${HISTFILE}
fi
history -c history -c
# Mail logs # Mail logs
function mail-watch function mail-watch
{ {
tail -f /var/log/mail.log sudo tail -f /var/log/mail.log
} }
function mail-log function mail-log
{ {
cat /var/log/mail.log sudo cat /var/log/mail.log
} }
function mail-troubleshoot function mail-troubleshoot
@ -1002,8 +991,8 @@ function mail-troubleshoot
function mail-reboot function mail-reboot
{ {
systemctl -q restart postfix.service dovecot.service opendkim.service opendmarc.service nginx.service mariadb.service sudo systemctl -q restart postfix.service dovecot.service opendkim.service opendmarc.service nginx.service mariadb.service
/etc/init.d/php*-fpm restart sudo /etc/init.d/php*-fpm restart >/dev/null
} }
function mail-check function mail-check
@ -1019,30 +1008,31 @@ function mail-check
function mail-test function mail-test
{ {
systemctl stop postfix dovecot sudo systemctl stop postfix dovecot
read -n 1 -s -p $'\nPress any key to continue...\n' read -n 1 -s -p $'\nPress any key to continue...\n'
systemctl start postfix dovecot && sudo systemctl start postfix dovecot &&
mail-watch mail-watch
} }
# SSH pubkey access # SSH pubkey access
function ssh-on function ssh-on
{ {
sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config.d/10-personal-sshd.conf sudo sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config.d/10-personal-sshd.conf
systemctl -q restart sshd sudo systemctl -q restart sshd
} }
function ssh-off function ssh-off
{ {
sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config.d/10-personal-sshd.conf sudo sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config.d/10-personal-sshd.conf
systemctl -q restart sshd sudo systemctl -q restart sshd
}' >> ~/.bashrc }
bashrc
install /dev/stdin ~/dhparam >/dev/null <<'dhparam' install /dev/stdin ~/dhparam >/dev/null <<'dhparam'
#!/usr/bin/env bash #!/usr/bin/env bash
echo echo
# Create certificates # Create certificates
echo -e '\e[1;34mGenerating DH parameters with openssl\e[0m' echo -e '\e[1;34mGenerating DH parameters with openssl\e[0m'
echo -e '\e[3m# a notification will pop up once completed\e[0m' echo -e '\e[3m# a notification will pop up once completed\e[0m'
@ -1052,15 +1042,17 @@ echo -e '\n\n\e[1;32mOpenssl certificates have successfully been generated!\e[0m
rm ${0} rm ${0}
dhparam dhparam
CHANGEUSER CHANGEUSER
clear
# In your DNS manager, create a TXT record, enter default._domainkey in the name field clear
echo -e '\e[1;34mUpdate DKIM TXT on DNS registrar and press any key to continue\e[5m...\e[0m'
echo -e '\e[3m# Use default._domainkey in the host field'
echo -e '# Visit https://www.dmarcanalyzer.com/dkim/dkim-checker/ to check manually\e[0m'
cat /etc/opendkim/keys/${domain}/default.txt | sed 's/.*( //' | sed 's/ ).*//' | sed 's/"//g' | sed 's/^[ \t]*//g' | sed ':a;N;$!ba;s/\n//g'
cat <<END # In your DNS manager, create a TXT record, enter default._domainkey in the name field
echo -e "\e[1;34mUpdate DKIM TXT on DNS registrar and press any key to continue\e[5m...\e[0m"
echo -e "\e[3m# Use default._domainkey in the host field"
echo -e "# Check with 'sudo opendkim-testkey -d ${domain} -s default'"
echo -e "# Or visit https://www.dmarcanalyzer.com/dkim/dkim-checker/\e[0m"
cat /etc/opendkim/keys/${domain}/default.txt | sed 's/.*( //' | sed 's/ ).*//' | sed 's/"//g' | sed 's/^[ \t]*//g' | sed ':a;N;$!ba;s/\n//g'
cat <<END
### ###
### SSH ### SSH