remove-mail-stack.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. # Function Description
  3. # Soft remove the mail stack
  4. #----------------------------------------------------------#
  5. # Variable&Function #
  6. #----------------------------------------------------------#
  7. # Includes
  8. # shellcheck source=/etc/hestiacp/hestia.conf
  9. source /etc/hestiacp/hestia.conf
  10. # shellcheck source=/usr/local/hestia/func/main.sh
  11. source $HESTIA/func/main.sh
  12. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  13. source $HESTIA/conf/hestia.conf
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. echo "This will soft remove the mail stack from HestiaCP and disable related systemd service."
  18. echo "You won't be able to access mail related configurations from HestiaCP."
  19. echo "Your existing mail data and apt packages will be kept back."
  20. read -p 'Would you like to continue? [y/n]'
  21. #----------------------------------------------------------#
  22. # Action #
  23. #----------------------------------------------------------#
  24. if [ "$ANTISPAM_SYSTEM" == "spamassassin" ]; then
  25. echo Removing Spamassassin
  26. sed -i "/^ANTISPAM_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  27. systemctl disable --now spamassassin
  28. fi
  29. if [ "$ANTIVIRUS_SYSTEM" == "clamav-daemon" ]; then
  30. echo Removing ClamAV
  31. sed -i "/^ANTIVIRUS_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  32. systemctl disable --now clamav-daemon clamav-freshclam
  33. fi
  34. if [ "$IMAP_SYSTEM" == "dovecot" ]; then
  35. echo Removing Dovecot
  36. sed -i "/^IMAP_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  37. systemctl disable --now dovecot
  38. fi
  39. if [ "$MAIL_SYSTEM" == "exim4" ]; then
  40. echo Removing Exim4
  41. sed -i "/^MAIL_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  42. systemctl disable --now exim4
  43. fi