| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/bash
- # info: change webmail alias url
- # options: WEBMAIL
- #
- # This function changes the webmail url in apache2 or nginx configuration.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Includes
- source $HESTIA/func/main.sh
- source $HESTIA/conf/hestia.conf
- # Get existing system webmail alias
- export $WEBMAIL_ALIAS
- # Define aliases
- OLD_ALIAS=$WEBMAIL_ALIAS
- NEW_ALIAS=$1
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Delete old webmail configuration
- for user in `ls /usr/local/hestia/data/users/`; do
- for domain in $($BIN/v-list-mail-domains $user plain |cut -f 1); do
- $BIN/v-delete-sys-webmail $user $domain
- done
- done
- # Set new webmail alias
- $BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' $NEW_ALIAS
- for user in `ls /usr/local/hestia/data/users/`; do
- for domain in $($BIN/v-list-mail-domains $user plain |cut -f 1); do
- $BIN/v-add-sys-webmail $user $domain
- done
- done
- # Update global directory alias configuration
- if [ "$WEB_SYSTEM" = 'apache2' ]; then
- sed -i "s|Alias \/$OLD_ALIAS|Alias \/$NEW_ALIAS|gI" /etc/apache2/conf.d/roundcube.conf
- fi
- if [ -e /etc/nginx/conf.d/webmail.inc ]; then
- sed -i "s|location \/$OLD_ALIAS|location \/$NEW_ALIAS|gI" /etc/nginx/conf.d/webmail.inc
- fi
- #----------------------------------------------------------#
- # Hestia #
- #----------------------------------------------------------#
- # Restart services
- $BIN/v-restart-web $restart
- $BIN/v-restart-proxy $restart
- # Logging
- log_history "changed global webmail alias to $NEW_ALIAS"
- log_event "$OK" "$ARGUMENTS"
- exit
|