| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #!/bin/bash
- # info: change webmail alias url
- # options: WEBMAIL
- #
- # This function changes the webmail url in apache2 or nginx configuration.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument definition
- WEBMAIL=$1
- # Includes
- source $HESTIA/func/main.sh
- source $HESTIA/conf/hestia.conf
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- check_args '1' "$#" 'WEBMAIL'
- # Check if string has leading /
- if [[ ! ${WEBMAIL:0:1} == "/" ]]; then
- WEBMAIL="/$WEBMAIL"
- fi
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Get existing apache2 webmail alias
- if [ -f /etc/apache2/conf.d/roundcube.conf ]; then
- apache_webmail=$(tail -n+3 /etc/apache2/conf.d/roundcube.conf | grep "Alias" | { IFS=' '; read -r -a array; echo "${array[1]}"; })
- fi
- # Get existing nginx webmail alias
- if [ -f /etc/nginx/conf.d/webmail.inc ]; then
- nginx_webmail=$(cat /etc/nginx/conf.d/webmail.inc | grep "location" | { IFS=' '; read -r -a array; echo "${array[1]}"; })
- fi
- # Check if alias is different for apache2
- if [ ! -z "$apache_webmail" ]; then
- if [ ! "$apache_webmail" = "$WEBMAIL" ]; then
- # Replace webmail alias in config files.
- sed -i "s|Alias $apache_webmail|Alias $WEBMAIL|" /etc/apache2/conf.d/roundcube.conf
- # Replace in Backend UI
- sed -i "s|$apache_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/admin/list_mail.html
- sed -i "s|$apache_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/user/list_mail.html
- # Restart services
- $HESTIA/bin/v-restart-service apache2
- fi
- fi
- # Check if alias is different for nginx
- if [ ! -z "$nginx_webmail" ]; then
- if [ ! "$nginx_webmail" = "$WEBMAIL" ]; then
- # Replace webmail alias in config files.
- sed -i "s|$nginx_webmail|$WEBMAIL|" /etc/nginx/conf.d/webmail.inc
- sed -i "s|/var/lib$WEBMAIL|/var/lib/roundcube|" /etc/nginx/conf.d/webmail.inc
- # Replace in Backend UI
- sed -i "s|$nginx_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/admin/list_mail.html
- sed -i "s|$nginx_webmail/|$WEBMAIL/|" /usr/local/hestia/web/templates/user/list_mail.html
- # Restart services
- $HESTIA/bin/v-restart-service nginx
- fi
- fi
- #----------------------------------------------------------#
- # Hestia #
- #----------------------------------------------------------#
- # Logging
- #log_event "$OK" "$ARGUMENTS"
- exit
|