install.inc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. hestia_module_exim_install() {
  3. source $HESTIA/bin/module/func.inc
  4. if hestia_module_isinstalled 'mta' && [ ! "$param_force" ]; then
  5. echo "MTA module is already installed. See 'hestia module info mta'."
  6. return 0
  7. fi
  8. echo "Installing MTA (Exim) module..."
  9. osal_service_stop $OSAL_SERVICE_EXIM > /dev/null 2>&1
  10. hestia_config_backup 'exim-install' $OSAL_DIR_EXIM_CONF
  11. osal_package_preinstall
  12. osal_package_install $OSAL_PKG_EXIM
  13. gpasswd -a $OSAL_USER_EXIM mail > /dev/null 2>&1
  14. cp -f $HESTIA_INSTALL_DIR/exim/${OSAL_FILENAME_EXIM_CONF} "$OSAL_PATH_EXIM_CONF"
  15. chmod 640 "$OSAL_PATH_EXIM_CONF"
  16. cp -f $HESTIA_INSTALL_DIR/exim/dnsbl.conf $OSAL_DIR_EXIM_CONF/
  17. cp -f $HESTIA_INSTALL_DIR/exim/spam-blocks.conf $OSAL_DIR_EXIM_CONF/
  18. touch $OSAL_DIR_EXIM_CONF/white-blocks.conf
  19. touch $OSAL_DIR_EXIM_CONF/mailhelo.conf
  20. hestia_safe_rm $OSAL_DIR_EXIM_CONF/domains
  21. mkdir -p $OSAL_DIR_EXIM_CONF/domains
  22. hestia_safe_rm /etc/alternatives/mta
  23. ln -s /usr/sbin/$OSAL_SERVICE_EXIM /etc/alternatives/mta
  24. osal_service_stop sendmail > /dev/nul 2>&1
  25. osal_service_disable sendmail > /dev/nul 2>&1
  26. osal_service_stop postfix > /dev/nul 2>&1
  27. osal_service_disable postfix > /dev/nul 2>&1
  28. osal_service_enable $OSAL_SERVICE_EXIM
  29. osal_service_start $OSAL_SERVICE_EXIM
  30. check_result $? "Exim start failed"
  31. osal_kv_write $HESTIA/conf/hestia.conf 'MAIL_SYSTEM' 'exim'
  32. osal_kv_write $HESTIA_CONF_MODULES/mta.conf 'installed' '1'
  33. osal_kv_write $HESTIA_CONF_MODULES/mta.conf 'description' 'Hestia MTA (Exim) module'
  34. osal_kv_write $HESTIA_CONF_MODULES/mta.conf 'enabled' '1'
  35. osal_kv_write $HESTIA_CONF_MODULES/mta.conf 'variant' 'exim'
  36. osal_kv_write $HESTIA_CONF_MODULES/mta.conf 'version' '1'
  37. osal_kv_write $HESTIA_CONF_MODULES/mta.conf 'service_name' "$OSAL_SERVICE_EXIM"
  38. # Rebuild mail
  39. for user in $($HESTIA/bin/v-list-sys-users plain); do
  40. echo "Rebuilding mail domains for user $user"
  41. $BIN/v-rebuild-mail-domains $user 'no' >/dev/null 2>&1
  42. done
  43. # Setup ClamAv integration
  44. if [[ $(hestia_module_variant_installed 'antivirus') == 'clamav' ]]; then
  45. hestia module clamav exim-integration enable
  46. fi
  47. # Setup SpamAssassin integration
  48. if [[ $(hestia_module_variant_installed 'antispam') == 'spamassassin' ]]; then
  49. hestia module spamassassin exim-integration enable
  50. fi
  51. }