v-change-sys-webmail 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. # info: change webmail alias url
  3. # options: WEBMAIL
  4. # labels: hestia panel
  5. #
  6. # example: v-change-sys-webmail YourtrickyURLhere
  7. #
  8. # This function changes the webmail url in apache2 or nginx configuration.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Includes
  13. # shellcheck source=/usr/local/hestia/func/main.sh
  14. source $HESTIA/func/main.sh
  15. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  16. source $HESTIA/conf/hestia.conf
  17. # Get existing system webmail alias
  18. export $WEBMAIL_ALIAS
  19. # Define aliases
  20. OLD_ALIAS=$WEBMAIL_ALIAS
  21. NEW_ALIAS=$1
  22. # Perform verification if read-only mode is enabled
  23. check_hestia_demo_mode
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. # Delete old webmail configuration
  28. for user in $($HESTIA/bin/v-list-sys-users plain); do
  29. for domain in $($BIN/v-list-mail-domains $user plain |cut -f 1); do
  30. $BIN/v-delete-sys-webmail $user $domain
  31. done
  32. done
  33. # Set new webmail alias
  34. $BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' $NEW_ALIAS
  35. # Add new webmail configuration
  36. for user in $($HESTIA/bin/v-list-sys-users plain); do
  37. for domain in $($BIN/v-list-mail-domains $user plain |cut -f 1); do
  38. $BIN/v-add-sys-webmail $user $domain
  39. done
  40. done
  41. #----------------------------------------------------------#
  42. # Hestia #
  43. #----------------------------------------------------------#
  44. # Restart services
  45. $BIN/v-restart-web $restart
  46. $BIN/v-restart-proxy $restart
  47. # Logging
  48. log_history "changed global webmail alias to $NEW_ALIAS" '' 'admin'
  49. log_event "$OK" "$ARGUMENTS"
  50. exit