|
|
@@ -1,298 +1,205 @@
|
|
|
+#----------------------------------------------------------#
|
|
|
+# WEB #
|
|
|
+#----------------------------------------------------------#
|
|
|
+
|
|
|
# Web template check
|
|
|
is_web_template_valid() {
|
|
|
- t="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
|
|
- s="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.stpl"
|
|
|
- if [ ! -e $t ] || [ ! -e $s ]; then
|
|
|
- echo "Error: web template $template not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
- exit $E_NOTEXIST
|
|
|
+ if [ ! -z "$WEB_SYSTEM" ]; then
|
|
|
+ template=$1
|
|
|
+ if [ -z "$template" ]; then
|
|
|
+ template=$(grep WEB_TEMPLATE $USER_DATA/user.conf |cut -f2 -d \')
|
|
|
+ if [ -z "$template" ]; then
|
|
|
+ template="default"
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+ tpl="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
|
|
+ stpl="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.stpl"
|
|
|
+ if [ ! -e "$tpl" ] || [ ! -e "$stpl" ]; then
|
|
|
+ check_result $E_NOTEXIST "$template web template doesn't exist"
|
|
|
+ fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# Proxy template check
|
|
|
is_proxy_template_valid() {
|
|
|
- proxy=$1
|
|
|
- t="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
|
|
|
- s="$WEBTPL/$PROXY_SYSTEM/$proxy.stpl"
|
|
|
- if [ ! -e $t ] || [ ! -e $s ]; then
|
|
|
- echo "Error: proxy template $proxy not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
- exit $E_NOTEXIST
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-# Backend template check
|
|
|
-is_web_backend_template_valid() {
|
|
|
- if [ ! -z "$1" ]; then
|
|
|
- template=$1
|
|
|
- else
|
|
|
- template=$(grep BACKEND_TEMPLATE $USER_DATA/user.conf)
|
|
|
- fi
|
|
|
- if [ -z "$template" ]; then
|
|
|
- if [ -e "$WEBTPL/$WEB_BACKEND/default.tpl" ]; then
|
|
|
- sed -i "s/^WEB_DOMAINS/BACKEND_TEMPLATE='default'\nWEB_DOMAINS/g" \
|
|
|
- $USER_DATA/user.conf
|
|
|
- template='default'
|
|
|
- else
|
|
|
- echo "Error: backend template default not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
- exit $E_NOTEXIST
|
|
|
+ if [ ! -z "$PROXY_SYSTEM" ]; then
|
|
|
+ proxy=$1
|
|
|
+ if [ -z "$proxy" ]; then
|
|
|
+ proxy=$(grep PROXY_TEMPLATE $USER_DATA/user.conf |cut -f2 -d \')
|
|
|
+ if [ -z "$proxy" ]; then
|
|
|
+ proxy="default"
|
|
|
+ fi
|
|
|
fi
|
|
|
- else
|
|
|
- template=$(echo "$template"|cut -f 2 -d \'|head -n1)
|
|
|
- if [ ! -e "$WEBTPL/$WEB_BACKEND/$template.tpl" ]; then
|
|
|
- echo "Error: backend template $template not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
- exit $E_NOTEXIST
|
|
|
+ tpl="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
|
|
|
+ stpl="$WEBTPL/$PROXY_SYSTEM/$proxy.stpl"
|
|
|
+ if [ ! -e "$tpl" ] || [ ! -e "$stpl" ]; then
|
|
|
+ check_result $E_NOTEXIST "$proxy proxy template doesn't exist"
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
-# Backend pool check
|
|
|
-is_web_backend_pool_valid(){
|
|
|
- if [ -d "/etc/php-fpm.d" ]; then
|
|
|
- pool="/etc/php-fpm.d"
|
|
|
- fi
|
|
|
- if [ -d "/etc/php5/fpm/pool.d" ]; then
|
|
|
- pool="/etc/php5/fpm/pool.d"
|
|
|
- fi
|
|
|
- if [ -d "/etc/php-fpm-5.5.d" ]; then
|
|
|
- pool="/etc/php-fpm-5.5.d"
|
|
|
- fi
|
|
|
- if [ ! -e "$pool" ]; then
|
|
|
- echo "Error: backend pool directory not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
- exit $E_NOTEXIST
|
|
|
- fi
|
|
|
-
|
|
|
- backend="$domain"
|
|
|
- if [ "$WEB_BACKEND_POOL" = 'user' ]; then
|
|
|
- backend="$user"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-# DNS template check
|
|
|
-is_dns_template_valid() {
|
|
|
- t="$DNSTPL/$template.tpl"
|
|
|
- if [ ! -e $t ]; then
|
|
|
- echo "Error: dns template $template not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
- exit $E_NOTEXIST
|
|
|
+# Backend template check
|
|
|
+is_backend_template_valid() {
|
|
|
+ if [ ! -e "$WEBTPL/$WEB_BACKEND/$1.tpl" ]; then
|
|
|
+ check_result $E_NOTEXIST "$backend backend template doesn't exist"
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
-# Checking domain existance
|
|
|
-is_domain_new() {
|
|
|
- type="$1"
|
|
|
- dom=${2-$domain}
|
|
|
- object=${3-domain}
|
|
|
-
|
|
|
- # Check web domain
|
|
|
- if [ ! -z "$WEB_SYSTEM" ]; then
|
|
|
- web=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/web.conf)
|
|
|
- fi
|
|
|
- if [ ! -z "$web" ] && [ "$type" == 'web' ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
- fi
|
|
|
+# Web domain existence check
|
|
|
+is_web_domain_new() {
|
|
|
+ web=$(grep -F -H "DOMAIN='$1'" $VESTA/data/users/*/web.conf)
|
|
|
if [ ! -z "$web" ]; then
|
|
|
+ if [ "$type" == 'web' ]; then
|
|
|
+ check_result $E_EXISTS "Web domain $1 exist"
|
|
|
+ fi
|
|
|
web_user=$(echo "$web" |cut -f 7 -d /)
|
|
|
if [ "$web_user" != "$user" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
- # Check dns domain
|
|
|
- if [ ! -z "$DNS_SYSTEM" ]; then
|
|
|
- dns=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf)
|
|
|
- fi
|
|
|
- if [ ! -z "$dns" ] && [ "$type" == 'dns' ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
- fi
|
|
|
- if [ ! -z "$dns" ]; then
|
|
|
- dns_user=$(echo "$dns" |cut -f 7 -d /)
|
|
|
- if [ "$dns_user" != "$user" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
- # Check mail domain
|
|
|
- if [ ! -z "$MAIL_SYSTEM" ]; then
|
|
|
- mail=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf)
|
|
|
- fi
|
|
|
- if [ ! -z "$mail" ] && [ "$type" == 'mail' ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
- fi
|
|
|
- if [ ! -z "$mail" ]; then
|
|
|
- mail_user=$(echo "$mail" |cut -f 7 -d /)
|
|
|
- if [ "$mail_user" != "$user" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ check_result $E_EXISTS "Web domain $1 exist"
|
|
|
fi
|
|
|
fi
|
|
|
+}
|
|
|
|
|
|
- # Check web aliases
|
|
|
- if [ ! -z "$WEB_SYSTEM" ]; then
|
|
|
- web_alias=$(grep -w $dom $VESTA/data/users/*/web.conf)
|
|
|
- fi
|
|
|
+# Web alias existence check
|
|
|
+is_web_alias_new() {
|
|
|
+ web_alias=$(grep -wH "$1" $VESTA/data/users/*/web.conf)
|
|
|
if [ ! -z "$web_alias" ]; then
|
|
|
- c1=$(grep -HF "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
|
|
- c2=$(grep -HF "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
|
|
- c3=$(grep -HF ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
|
|
- c4=$(grep -HF ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
|
|
- if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ a1=$(echo "$web_alias" |grep -F "'$1'" |cut -f 7 -d /)
|
|
|
+ if [ ! -z "$a1" ] && [ "$2" == "web" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
- if [ ! -z "$c1" ] && [ "$c1" != "$user" ]; then
|
|
|
- echo "Error: domain $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ if [ ! -z "$a1" ] && [ "$a1" != "$user" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
-
|
|
|
- if [ ! -z "$c2" ] && [ "$type" == "web" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ a2=$(echo "$web_alias" |grep -F "'$1," |cut -f 7 -d /)
|
|
|
+ if [ ! -z "$a2" ] && [ "$2" == "web" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
- if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ if [ ! -z "$a2" ] && [ "$a2" != "$user" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
-
|
|
|
- if [ ! -z "$c3" ] && [ "$type" == "web" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ a3=$(echo "$web_alias" |grep -F ",$1," |cut -f 7 -d /)
|
|
|
+ if [ ! -z "$a3" ] && [ "$2" == "web" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
- if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ if [ ! -z "$a3" ] && [ "$a3" != "$user" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
-
|
|
|
- if [ ! -z "$c4" ] && [ "$type" == "web" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ a4=$(echo "$web_alias" |grep -F ",$1'" |cut -f 7 -d /)
|
|
|
+ if [ ! -z "$a4" ] && [ "$2" == "web" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
- if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then
|
|
|
- echo "Error: $object $dom exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+ if [ ! -z "$a4" ] && [ "$a4" != "$user" ]; then
|
|
|
+ check_result $E_EXISTS "Web alias $1 exists"
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
-# Checking mail account existance
|
|
|
-is_mail_new() {
|
|
|
- check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf)
|
|
|
- if [ ! -z "$check_acc" ]; then
|
|
|
- echo "Error: mail account $1 exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
- fi
|
|
|
- check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf )
|
|
|
- check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1)
|
|
|
- if [ ! -z "$check_als" ]; then
|
|
|
- echo "Error: mail alias $1 exist"
|
|
|
- log_event "$E_EXISTS" "$EVENT"
|
|
|
- exit $E_EXISTS
|
|
|
+# Prepare web backend
|
|
|
+prepare_web_backend() {
|
|
|
+ if [ -d "/etc/php-fpm.d" ]; then
|
|
|
+ pool="/etc/php-fpm.d"
|
|
|
fi
|
|
|
-}
|
|
|
-
|
|
|
-# Update domain zone
|
|
|
-update_domain_zone() {
|
|
|
- domain_param=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
|
|
- eval $domain_param
|
|
|
- SOA=$(idn --quiet -a -t "$SOA")
|
|
|
- if [ -z "$SERIAL" ]; then
|
|
|
- SERIAL=$(date +'%Y%m%d01')
|
|
|
+ if [ -d "/etc/php5/fpm/pool.d" ]; then
|
|
|
+ pool="/etc/php5/fpm/pool.d"
|
|
|
fi
|
|
|
- zn_conf="$HOMEDIR/$user/conf/dns/$domain.db"
|
|
|
- echo "\$TTL $TTL
|
|
|
-@ IN SOA $SOA. root.$domain_idn. (
|
|
|
- $SERIAL
|
|
|
- 7200
|
|
|
- 3600
|
|
|
- 1209600
|
|
|
- 180 )
|
|
|
-" > $zn_conf
|
|
|
- fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
|
|
|
- while read line ; do
|
|
|
- IFS=$'\n'
|
|
|
- for key in $(echo $line|sed "s/' /'\n/g"); do
|
|
|
- eval ${key%%=*}="${key#*=}"
|
|
|
- done
|
|
|
-
|
|
|
- RECORD=$(idn --quiet -a -t "$RECORD")
|
|
|
- if [ "$TYPE" = 'CNAME' ] || [ "$TYPE" = 'MX' ]; then
|
|
|
- VALUE=$(idn --quiet -a -t "$VALUE")
|
|
|
+ if [ ! -e "$pool" ]; then
|
|
|
+ pool=$(find /etc/php* -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
|
|
+ if [ ! -e "$pool" ]; then
|
|
|
+ check_result $E_NOTEXIST "php-fpm pool doesn't exist"
|
|
|
fi
|
|
|
+ fi
|
|
|
|
|
|
- if [ "$SUSPENDED" != 'yes' ]; then
|
|
|
- eval echo -e "\"$fields\""|sed "s/%quote%/'/g" >> $zn_conf
|
|
|
+ backend_type="$domain"
|
|
|
+ if [ "$WEB_BACKEND_POOL" = 'user' ]; then
|
|
|
+ backend_type="$user"
|
|
|
+ fi
|
|
|
+ if [ -e "$pool/$backend_type.conf" ]; then
|
|
|
+ backend_lsnr=$(grep "listen =" $pool/$backend_type.conf)
|
|
|
+ backend_lsnr=$(echo "$backend_lsnr" |cut -f 2 -d = |sed "s/ //")
|
|
|
+ if [ ! -z "$(echo $backend_lsnr |grep /)" ]; then
|
|
|
+ backend_lsnr="unix:$backend_lsnr"
|
|
|
fi
|
|
|
- done < $USER_DATA/dns/$domain.conf
|
|
|
+ fi
|
|
|
}
|
|
|
|
|
|
-# Update zone serial
|
|
|
-update_domain_serial() {
|
|
|
- zn_conf="$HOMEDIR/$user/conf/dns/$domain.db"
|
|
|
- if [ -e $zn_conf ]; then
|
|
|
- zn_serial=$(head $zn_conf |grep 'SOA' -A1 |tail -n 1 |sed "s/ //g")
|
|
|
- s_date=$(echo ${zn_serial:0:8})
|
|
|
- c_date=$(date +'%Y%m%d')
|
|
|
- if [ "$s_date" == "$c_date" ]; then
|
|
|
- cur_value=$(echo ${zn_serial:8} )
|
|
|
- new_value=$(expr $cur_value + 1 )
|
|
|
- len_value=$(expr length $new_value)
|
|
|
- if [ 1 -eq "$len_value" ]; then
|
|
|
- new_value='0'$new_value
|
|
|
- fi
|
|
|
- serial="$c_date""$new_value"
|
|
|
+# Prepare web aliases
|
|
|
+prepare_web_aliases() {
|
|
|
+ i=1
|
|
|
+ for tmp_alias in ${1//,/ }; do
|
|
|
+ tmp_alias_idn="$tmp_alias"
|
|
|
+ if [[ "$tmp_alias" = *[![:ascii:]]* ]]; then
|
|
|
+ tmp_alias_idn=$(idn -t --quiet -a $tmp_alias)
|
|
|
+ fi
|
|
|
+ if [[ $i -eq 1 ]]; then
|
|
|
+ aliases="$tmp_alias"
|
|
|
+ aliases_idn="$tmp_alias_idn"
|
|
|
+ alias_string="ServerAlias $tmp_alias_idn"
|
|
|
else
|
|
|
- serial="$(date +'%Y%m%d01')"
|
|
|
+ aliases="$aliases,$tmp_alias"
|
|
|
+ aliases_idn="$aliases_idn,$tmp_alias_idn"
|
|
|
+ if (( $i % 100 == 0 )); then
|
|
|
+ alias_string="$alias_string\n ServerAlias $tmp_alias_idn"
|
|
|
+ else
|
|
|
+ alias_string="$alias_string $tmp_alias_idn"
|
|
|
+ fi
|
|
|
fi
|
|
|
+ alias_number=$i
|
|
|
+ ((i++))
|
|
|
+ done
|
|
|
+}
|
|
|
+
|
|
|
+# Update web domain values
|
|
|
+prepare_web_domain_values() {
|
|
|
+ if [[ "$domain" = *[![:ascii:]]* ]]; then
|
|
|
+ domain_idn=$(idn -t --quiet -a $domain)
|
|
|
else
|
|
|
- serial="$(date +'%Y%m%d01')"
|
|
|
+ domain_idn=$domain
|
|
|
+ fi
|
|
|
+ group="$user"
|
|
|
+ email="info@$domain"
|
|
|
+ docroot="$HOMEDIR/$user/web/$domain/public_html"
|
|
|
+ sdocroot="$docroot"
|
|
|
+ if [ "$SSL_HOME" = 'single' ]; then
|
|
|
+ sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ;
|
|
|
fi
|
|
|
- add_object_key "dns" 'DOMAIN' "$domain" 'SERIAL' 'RECORDS'
|
|
|
- update_object_value 'dns' 'DOMAIN' "$domain" '$SERIAL' "$serial"
|
|
|
-}
|
|
|
|
|
|
-# Get next DNS record ID
|
|
|
-get_next_dnsrecord(){
|
|
|
- if [ -z "$id" ]; then
|
|
|
- curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
|
|
|
- sort -n|tail -n1)
|
|
|
- id="$((curr_str +1))"
|
|
|
+ if [ ! -z "$WEB_BACKEND" ]; then
|
|
|
+ prepare_web_backend
|
|
|
fi
|
|
|
-}
|
|
|
|
|
|
-# Sort DNS records
|
|
|
-sort_dns_records() {
|
|
|
- conf="$USER_DATA/dns/$domain.conf"
|
|
|
- cat $conf |sort -n -k 2 -t \' >$conf.tmp
|
|
|
- mv -f $conf.tmp $conf
|
|
|
+ server_alias=''
|
|
|
+ alias_string=''
|
|
|
+ aliases_idn=''
|
|
|
+ prepare_web_aliases $ALIAS
|
|
|
+
|
|
|
+ ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
|
|
|
+ ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
|
|
|
+ ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
|
|
|
+ ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
|
|
|
+ if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then
|
|
|
+ ssl_ca_str='#'
|
|
|
+ fi
|
|
|
+ if [ "$SUSPENDED" = 'yes' ]; then
|
|
|
+ docroot="$VESTA/data/templates/web/suspend"
|
|
|
+ sdocroot="$VESTA/data/templates/web/suspend"
|
|
|
+ fi
|
|
|
}
|
|
|
|
|
|
# Add web config
|
|
|
add_web_config() {
|
|
|
- cat $tpl_file | \
|
|
|
- sed -e "s|%ip%|$ip|g" \
|
|
|
+ conf="$HOMEDIR/$user/conf/web/$1.conf"
|
|
|
+ if [[ "$2" =~ stpl$ ]]; then
|
|
|
+ conf="$HOMEDIR/$user/conf/web/s$1.conf"
|
|
|
+ fi
|
|
|
+
|
|
|
+ cat $WEBTPL/$1/$WEB_BACKEND/$2 | \
|
|
|
+ sed -e "s|%ip%|$local_ip|g" \
|
|
|
+ -e "s|%domain%|$domain|g" \
|
|
|
+ -e "s|%domain_idn%|$domain_idn|g" \
|
|
|
+ -e "s|%alias%|${aliases//,/ }|g" \
|
|
|
+ -e "s|%alias_idn%|${aliases_idn//,/ }|g" \
|
|
|
+ -e "s|%alias_string%|$alias_string|g" \
|
|
|
+ -e "s|%email%|info@$domain|g" \
|
|
|
-e "s|%web_system%|$WEB_SYSTEM|g" \
|
|
|
-e "s|%web_port%|$WEB_PORT|g" \
|
|
|
-e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \
|
|
|
@@ -302,43 +209,55 @@ add_web_config() {
|
|
|
-e "s|%proxy_port%|$PROXY_PORT|g" \
|
|
|
-e "s|%proxy_ssl_port%|$PROXY_SSL_PORT|g" \
|
|
|
-e "s/%proxy_extentions%/${PROXY_EXT//,/|}/g" \
|
|
|
- -e "s|%domain_idn%|$domain_idn|g" \
|
|
|
- -e "s|%domain%|$domain|g" \
|
|
|
-e "s|%user%|$user|g" \
|
|
|
-e "s|%group%|$group|g" \
|
|
|
-e "s|%home%|$HOMEDIR|g" \
|
|
|
- -e "s|%docroot%|$docroot|g" \
|
|
|
- -e "s|%sdocroot%|$sdocroot|g" \
|
|
|
- -e "s|%email%|$email|g" \
|
|
|
- -e "s|%alias_string%|$alias_string|g" \
|
|
|
- -e "s|%alias_idn%|${aliases_idn//,/ }|g" \
|
|
|
- -e "s|%alias%|${aliases//,/ }|g" \
|
|
|
+ -e "s|%docroot%|$HOMEDIR/$user/web/$domain/public_html|g" \
|
|
|
+ -e "s|%sdocroot%|$HOMEDIR/$user/web/$domain/public_html|g" \
|
|
|
-e "s|%ssl_crt%|$ssl_crt|g" \
|
|
|
-e "s|%ssl_key%|$ssl_key|g" \
|
|
|
-e "s|%ssl_pem%|$ssl_pem|g" \
|
|
|
-e "s|%ssl_ca_str%|$ssl_ca_str|g" \
|
|
|
-e "s|%ssl_ca%|$ssl_ca|g" \
|
|
|
>> $conf
|
|
|
-}
|
|
|
|
|
|
-# Get config top and bottom line numbers
|
|
|
-get_web_config_brds() {
|
|
|
+ chown root:$user $conf
|
|
|
+ chmod 640 $conf
|
|
|
|
|
|
- serv_line=$(egrep -ni "Name %domain_idn%($| )" $tpl_file |cut -f 1 -d :)
|
|
|
- if [ -z "$serv_line" ]; then
|
|
|
- log_event "$E_PARSING" "$EVENT"
|
|
|
- return $E_PARSING
|
|
|
+ if [ -z "$(grep "$conf" /etc/$1/conf.d/vesta.conf)" ]; then
|
|
|
+ if [ "$WEB_SYSTEM" != 'nginx' ]; then
|
|
|
+ echo "Include $conf" >> /etc/$1/conf.d/vesta.conf
|
|
|
+ else
|
|
|
+ echo "include $conf;" >> /etc/$1/conf.d/vesta.conf
|
|
|
+ fi
|
|
|
fi
|
|
|
|
|
|
- last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
|
|
|
- bfr_line=$((serv_line - 1))
|
|
|
- aftr_line=$((last_line - serv_line - 1))
|
|
|
+ trigger="${2/.*pl/.sh}"
|
|
|
+ if [ -x "$WEBTPL/$1/$WEB_BACKEND/$trigger" ]; then
|
|
|
+ $WEBTPL/$1/$WEB_BACKEND/$trigger \
|
|
|
+ $user $domain $ip $HOMEDIR $HOMEDIR/$user/web/$domain/public_html
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+# Get config top and bottom line number
|
|
|
+get_web_config_lines() {
|
|
|
+ tpl_lines=$(egrep -ni "name %domain_idn%" $1 |grep -w %domain_idn%)
|
|
|
+ tpl_lines=$(echo "$tpl_lines" |cut -f 1 -d :)
|
|
|
+ tpl_last_line=$(wc -l $1 |cut -f 1 -d ' ')
|
|
|
+ if [ -z "$tpl_lines" ]; then
|
|
|
+ check_result $E_PARSING "can't parse template $1"
|
|
|
+ fi
|
|
|
+
|
|
|
+ vhost_lines=$(grep -niF "name $domain_idn" $2)
|
|
|
+ vhost_lines=$(echo "$vhost_lines" |egrep "$domain_idn$|$domain_idn ")
|
|
|
+ vhost_lines=$(echo "$vhost_lines" |cut -f 1 -d :)
|
|
|
+ if [ -z "$vhost_lines" ]; then
|
|
|
+ check_result $E_PARSING "can't parse config $2"
|
|
|
+ fi
|
|
|
|
|
|
- str=$(grep -niF "Name $domain_idn" $conf |egrep "$domain_idn$|$domain_idn ")
|
|
|
- str=$(echo "$str" |cut -f 1 -d :)
|
|
|
- top_line=$((str - serv_line + 1))
|
|
|
- bottom_line=$((top_line + last_line -1))
|
|
|
- multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
|
|
|
+ top_line=$((vhost_lines + 1 - tpl_lines))
|
|
|
+ bottom_line=$((top_line - 1 + tpl_last_line))
|
|
|
+ multi=$(sed -n "$top_line,$bottom_line p" $2 |grep ServerAlias |wc -l)
|
|
|
if [ "$multi" -ge 2 ]; then
|
|
|
bottom_line=$((bottom_line + multi -1))
|
|
|
fi
|
|
|
@@ -346,32 +265,25 @@ get_web_config_brds() {
|
|
|
|
|
|
# Replace web config
|
|
|
replace_web_config() {
|
|
|
- get_web_config_brds || exit $?
|
|
|
- clean_new=$(echo "$new" | sed \
|
|
|
- -e 's/\\/\\\\/g' \
|
|
|
- -e 's/&/\\&/g' \
|
|
|
- -e 's/\//\\\//g')
|
|
|
- clean_old=$(echo "$old" | sed \
|
|
|
- -e 's/\\/\\\\/g' \
|
|
|
- -e 's/&/\\&/g' \
|
|
|
- -e 's/\//\\\//g')
|
|
|
-
|
|
|
- sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
|
|
|
+ get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
|
|
|
+ sed -i "$top_line,$bottom_line s|$old|$new|g" $conf
|
|
|
}
|
|
|
|
|
|
-# Get domain variables
|
|
|
-get_domain_values() {
|
|
|
- for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do
|
|
|
- eval $line
|
|
|
- done
|
|
|
-}
|
|
|
+# Delete web configuartion
|
|
|
+del_web_config() {
|
|
|
+ conf="$HOMEDIR/$user/conf/web/$1.conf"
|
|
|
+ if [[ "$2" =~ stpl$ ]]; then
|
|
|
+ conf="$HOMEDIR/$user/conf/web/s$1.conf"
|
|
|
+ fi
|
|
|
+
|
|
|
+ get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
|
|
|
+ sed -i "$top_line,$bottom_line d" $conf
|
|
|
|
|
|
-# Get backend values
|
|
|
-get_domain_backend_values() {
|
|
|
- lsnr=$(grep "listen =" $pool/$backend.conf |cut -f 2 -d = |sed "s/ //")
|
|
|
- backend_lsnr="$lsnr"
|
|
|
- if [ ! -z "$(echo $lsnr |grep /)" ]; then
|
|
|
- backend_lsnr="unix:$backend_lsnr"
|
|
|
+ web_domains=$(grep DOMAIN $USER_DATA/web.conf |wc -l)
|
|
|
+ if [ "$web_domains" -eq '0' ]; then
|
|
|
+ sed -i "/.*\/$user\/.*$WEB_SYSTEM.conf/d" /etc/$1/conf.d/vesta.conf
|
|
|
+ rm -f $HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf
|
|
|
+ rm -f $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
@@ -379,27 +291,27 @@ get_domain_backend_values() {
|
|
|
is_web_domain_cert_valid() {
|
|
|
if [ ! -e "$ssl_dir/$domain.crt" ]; then
|
|
|
echo "Error: $ssl_dir/$domain.crt not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
+ log_event "$E_NOTEXIST" "$ARGUMENTS"
|
|
|
exit $E_NOTEXIST
|
|
|
fi
|
|
|
|
|
|
if [ ! -e "$ssl_dir/$domain.key" ]; then
|
|
|
echo "Error: $ssl_dir/$domain.key not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
+ log_event "$E_NOTEXIST" "$ARGUMENTS"
|
|
|
exit $E_NOTEXIST
|
|
|
fi
|
|
|
|
|
|
crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1)
|
|
|
if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then
|
|
|
echo "Error: SSL Certificate is not valid"
|
|
|
- log_event "$E_INVALID" "$EVENT"
|
|
|
+ log_event "$E_INVALID" "$ARGUMENTS"
|
|
|
exit $E_INVALID
|
|
|
fi
|
|
|
|
|
|
if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then
|
|
|
if [ ! -e "$ssl_dir/$domain.ca" ]; then
|
|
|
echo "Error: Certificate Authority not found"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
+ log_event "$E_NOTEXIST" "$ARGUMENTS"
|
|
|
exit $E_NOTEXIST
|
|
|
fi
|
|
|
fi
|
|
|
@@ -411,7 +323,7 @@ is_web_domain_cert_valid() {
|
|
|
s2=$(echo "$s2" |grep Subject |awk -F = '{print $6}' |head -n1)
|
|
|
if [ "$s1" != "$s2" ]; then
|
|
|
echo "Error: SSL intermediate chain is not valid"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
+ log_event "$E_NOTEXIST" "$ARGUMENTS"
|
|
|
exit $E_NOTEXIST
|
|
|
fi
|
|
|
fi
|
|
|
@@ -419,7 +331,7 @@ is_web_domain_cert_valid() {
|
|
|
key_vrf=$(grep 'PRIVATE KEY' $ssl_dir/$domain.key | wc -l)
|
|
|
if [ "$key_vrf" -ne 2 ]; then
|
|
|
echo "Error: SSL Key is not valid"
|
|
|
- log_event "$E_INVALID" "$EVENT"
|
|
|
+ log_event "$E_INVALID" "$ARGUMENTS"
|
|
|
exit $E_INVALID
|
|
|
fi
|
|
|
|
|
|
@@ -431,94 +343,112 @@ is_web_domain_cert_valid() {
|
|
|
kill $pid &> /dev/null
|
|
|
if [ "$?" -ne '0' ]; then
|
|
|
echo "Error: ssl certificate key pair is not valid"
|
|
|
- log_event "$E_INVALID" "$EVENT"
|
|
|
+ log_event "$E_INVALID" "$ARGUMENTS"
|
|
|
exit $E_INVALID
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
-# Delete web configuartion
|
|
|
-del_web_config() {
|
|
|
- get_web_config_brds || exit $?
|
|
|
- sed -i "$top_line,$bottom_line d" $conf
|
|
|
-}
|
|
|
|
|
|
-# Update web domain values
|
|
|
-upd_web_domain_values() {
|
|
|
- group="$user"
|
|
|
- email="info@$domain"
|
|
|
- docroot="$HOMEDIR/$user/web/$domain/public_html"
|
|
|
- sdocroot=$docroot
|
|
|
- if [ "$SSL_HOME" = 'single' ]; then
|
|
|
- sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ;
|
|
|
- fi
|
|
|
- if [ ! -z "$WEB_BACKEND" ]; then
|
|
|
- is_web_backend_pool_valid
|
|
|
- get_domain_backend_values
|
|
|
+#----------------------------------------------------------#
|
|
|
+# DNS #
|
|
|
+#----------------------------------------------------------#
|
|
|
+
|
|
|
+# DNS template check
|
|
|
+is_dns_template_valid() {
|
|
|
+ t="$DNSTPL/$template.tpl"
|
|
|
+ if [ ! -e $t ]; then
|
|
|
+ check_result $E_NOTEXIST "dns template $template doesn't exist"
|
|
|
fi
|
|
|
- i=1
|
|
|
- j=1
|
|
|
- OLD_IFS="$IFS"
|
|
|
- IFS=','
|
|
|
- server_alias=''
|
|
|
- alias_string=''
|
|
|
- aliases_idn=''
|
|
|
+}
|
|
|
|
|
|
- for dalias in $ALIAS; do
|
|
|
- dalias=$(idn -t --quiet -a $dalias)
|
|
|
- check_8k="$server_alias $dalias"
|
|
|
- if [ "${#check_8k}" -ge '8100' ]; then
|
|
|
- if [ "$j" -eq 1 ]; then
|
|
|
- alias_string="ServerAlias $server_alias"
|
|
|
- else
|
|
|
- alias_string="$alias_string\n ServerAlias $server_alias"
|
|
|
- fi
|
|
|
- j=2
|
|
|
- server_alias=''
|
|
|
+# DNS domain existence check
|
|
|
+is_dns_domain_new() {
|
|
|
+ dns=$(ls $VESTA/data/users/*/dns/$1.conf 2>/dev/null)
|
|
|
+ if [ ! -z "$dns" ]; then
|
|
|
+ if [ "$2" == 'dns' ]; then
|
|
|
+ check_result $E_EXISTS "DNS domain $1 exists"
|
|
|
fi
|
|
|
- if [ "$i" -eq 1 ]; then
|
|
|
- aliases_idn="$dalias"
|
|
|
- server_alias="$dalias"
|
|
|
- alias_string="ServerAlias $server_alias"
|
|
|
- else
|
|
|
- aliases_idn="$aliases_idn,$dalias"
|
|
|
- server_alias="$server_alias $dalias"
|
|
|
+ dns_user=$(echo "$dns" |cut -f 7 -d /)
|
|
|
+ if [ "$dns_user" != "$user" ]; then
|
|
|
+ check_result $E_EXISTS "DNS domain $1 exists"
|
|
|
fi
|
|
|
- i=2
|
|
|
- done
|
|
|
-
|
|
|
- if [ $j -gt 1 ]; then
|
|
|
- alias_string="$alias_string\n ServerAlias $server_alias"
|
|
|
- else
|
|
|
- alias_string="ServerAlias $server_alias"
|
|
|
fi
|
|
|
+}
|
|
|
|
|
|
- IFS=$OLD_IFS
|
|
|
- if [ "$ELOG" = 'no' ]; then
|
|
|
- elog='#'
|
|
|
- else
|
|
|
- elog=''
|
|
|
+# Update domain zone
|
|
|
+update_domain_zone() {
|
|
|
+ domain_param=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
|
|
+ eval $domain_param
|
|
|
+ SOA=$(idn --quiet -a -t "$SOA")
|
|
|
+ if [ -z "$SERIAL" ]; then
|
|
|
+ SERIAL=$(date +'%Y%m%d01')
|
|
|
fi
|
|
|
+ zn_conf="$HOMEDIR/$user/conf/dns/$domain.db"
|
|
|
+ echo "\$TTL $TTL
|
|
|
+@ IN SOA $SOA. root.$domain_idn. (
|
|
|
+ $SERIAL
|
|
|
+ 7200
|
|
|
+ 3600
|
|
|
+ 1209600
|
|
|
+ 180 )
|
|
|
+" > $zn_conf
|
|
|
+ fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
|
|
|
+ while read line ; do
|
|
|
+ IFS=$'\n'
|
|
|
+ for key in $(echo $line|sed "s/' /'\n/g"); do
|
|
|
+ eval ${key%%=*}="${key#*=}"
|
|
|
+ done
|
|
|
+
|
|
|
+ RECORD=$(idn --quiet -a -t "$RECORD")
|
|
|
+ if [ "$TYPE" = 'CNAME' ] || [ "$TYPE" = 'MX' ]; then
|
|
|
+ VALUE=$(idn --quiet -a -t "$VALUE")
|
|
|
+ fi
|
|
|
+
|
|
|
+ if [ "$SUSPENDED" != 'yes' ]; then
|
|
|
+ eval echo -e "\"$fields\""|sed "s/%quote%/'/g" >> $zn_conf
|
|
|
+ fi
|
|
|
+ done < $USER_DATA/dns/$domain.conf
|
|
|
+}
|
|
|
|
|
|
- if [ "$CGI" != 'yes' ]; then
|
|
|
- cgi='#'
|
|
|
- cgi_option='-ExecCGI'
|
|
|
+# Update zone serial
|
|
|
+update_domain_serial() {
|
|
|
+ zn_conf="$HOMEDIR/$user/conf/dns/$domain.db"
|
|
|
+ if [ -e $zn_conf ]; then
|
|
|
+ zn_serial=$(head $zn_conf |grep 'SOA' -A1 |tail -n 1 |sed "s/ //g")
|
|
|
+ s_date=$(echo ${zn_serial:0:8})
|
|
|
+ c_date=$(date +'%Y%m%d')
|
|
|
+ if [ "$s_date" == "$c_date" ]; then
|
|
|
+ cur_value=$(echo ${zn_serial:8} )
|
|
|
+ new_value=$(expr $cur_value + 1 )
|
|
|
+ len_value=$(expr length $new_value)
|
|
|
+ if [ 1 -eq "$len_value" ]; then
|
|
|
+ new_value='0'$new_value
|
|
|
+ fi
|
|
|
+ serial="$c_date""$new_value"
|
|
|
+ else
|
|
|
+ serial="$(date +'%Y%m%d01')"
|
|
|
+ fi
|
|
|
else
|
|
|
- cgi=''
|
|
|
- cgi_option='+ExecCGI'
|
|
|
+ serial="$(date +'%Y%m%d01')"
|
|
|
fi
|
|
|
+ add_object_key "dns" 'DOMAIN' "$domain" 'SERIAL' 'RECORDS'
|
|
|
+ update_object_value 'dns' 'DOMAIN' "$domain" '$SERIAL' "$serial"
|
|
|
+}
|
|
|
|
|
|
- ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
|
|
|
- ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
|
|
|
- ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
|
|
|
- ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
|
|
|
- if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then
|
|
|
- ssl_ca_str='#'
|
|
|
+# Get next DNS record ID
|
|
|
+get_next_dnsrecord(){
|
|
|
+ if [ -z "$id" ]; then
|
|
|
+ curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
|
|
|
+ sort -n|tail -n1)
|
|
|
+ id="$((curr_str +1))"
|
|
|
fi
|
|
|
+}
|
|
|
|
|
|
- if [ "$SUSPENDED" = 'yes' ]; then
|
|
|
- docroot="$VESTA/data/templates/web/suspend"
|
|
|
- sdocroot="$VESTA/data/templates/web/suspend"
|
|
|
- fi
|
|
|
+# Sort DNS records
|
|
|
+sort_dns_records() {
|
|
|
+ conf="$USER_DATA/dns/$domain.conf"
|
|
|
+ cat $conf |sort -n -k 2 -t \' >$conf.tmp
|
|
|
+ mv -f $conf.tmp $conf
|
|
|
}
|
|
|
|
|
|
# Check if this is a last record
|
|
|
@@ -529,7 +459,7 @@ is_dns_record_critical() {
|
|
|
records=$(grep "TYPE='$TYPE'" $USER_DATA/dns/$domain.conf| wc -l)
|
|
|
if [ $records -le 1 ]; then
|
|
|
echo "Error: at least one $TYPE record should remain active"
|
|
|
- log_event "$E_INVALID" "$EVENT"
|
|
|
+ log_event "$E_INVALID" "$ARGUMENTS"
|
|
|
exit $E_INVALID
|
|
|
fi
|
|
|
fi
|
|
|
@@ -551,7 +481,7 @@ is_dns_fqnd() {
|
|
|
r=$(echo $r|sed -e "s/\.$//")
|
|
|
msg="$t record $r should be a fully qualified domain name (FQDN)"
|
|
|
echo "Error: $msg"
|
|
|
- log_event "$E_INVALID" "$EVENT"
|
|
|
+ log_event "$E_INVALID" "$ARGUMENTS"
|
|
|
exit $E_INVALID
|
|
|
fi
|
|
|
fi
|
|
|
@@ -569,10 +499,68 @@ is_dns_nameserver_valid() {
|
|
|
a_record=$(echo $r |cut -f 1 -d '.')
|
|
|
n_record=$(grep "RECORD='$a_record'" $zone| grep "TYPE='A'")
|
|
|
if [ -z "$n_record" ]; then
|
|
|
- echo "Error: corresponding A record $a_record.$d does not exist"
|
|
|
- log_event "$E_NOTEXIST" "$EVENT"
|
|
|
- exit $E_NOTEXIST
|
|
|
+ check_result $E_NOTEXIST "IN A $a_record.$d does not exist"
|
|
|
fi
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#----------------------------------------------------------#
|
|
|
+# MAIL #
|
|
|
+#----------------------------------------------------------#
|
|
|
+
|
|
|
+# Mail domain existence check
|
|
|
+is_mail_domain_new() {
|
|
|
+ mail=$(ls $VESTA/data/users/*/mail/$1.conf 2>/dev/null)
|
|
|
+ if [ ! -z "$mail" ]; then
|
|
|
+ if [ "$2" == 'mail' ]; then
|
|
|
+ check_result $E_EXISTS "Mail domain $1 exists"
|
|
|
+ fi
|
|
|
+ mail_user=$(echo "$mail" |cut -f 7 -d /)
|
|
|
+ if [ "$mail_user" != "$user" ]; then
|
|
|
+ check_result $E_EXISTS "Mail domain $1 exists"
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+# Checking mail account existance
|
|
|
+is_mail_new() {
|
|
|
+ check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf)
|
|
|
+ if [ ! -z "$check_acc" ]; then
|
|
|
+ check_result $E_EXIST "mail account $1 is already exists"
|
|
|
+ fi
|
|
|
+ check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf )
|
|
|
+ check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1)
|
|
|
+ if [ ! -z "$check_als" ]; then
|
|
|
+ check_result $E_EXIST "mail alias $1 is already exists"
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#----------------------------------------------------------#
|
|
|
+# CMN #
|
|
|
+#----------------------------------------------------------#
|
|
|
+
|
|
|
+# Checking domain existance
|
|
|
+is_domain_new() {
|
|
|
+ type=$1
|
|
|
+ for object in ${2//,/ }; do
|
|
|
+ if [ ! -z "$WEB_SYSTEM" ]; then
|
|
|
+ is_web_domain_new $object $type
|
|
|
+ is_web_alias_new $object $type
|
|
|
+ fi
|
|
|
+ if [ ! -z "$DNS_SYSTEM" ]; then
|
|
|
+ is_dns_domain_new $object $type
|
|
|
+ fi
|
|
|
+ if [ ! -z "$MAIL_SYSTEM" ]; then
|
|
|
+ is_mail_domain_new $object $type
|
|
|
+ fi
|
|
|
+ done
|
|
|
+}
|
|
|
+
|
|
|
+# Get domain variables
|
|
|
+get_domain_values() {
|
|
|
+ eval $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf)
|
|
|
+}
|