diff --git a/bin/v-change-dns-domain-ip b/bin/v-change-dns-domain-ip index 810fe8a4..5e513c79 100755 --- a/bin/v-change-dns-domain-ip +++ b/bin/v-change-dns-domain-ip @@ -49,15 +49,18 @@ else ip='' fi + +# Get old ip +get_domain_values 'dns' +if [ -z "$ip" ] && [ -z "$IP6" ]; then + check_result $E_INVALID "IP or IPv6 is required" +fi + #----------------------------------------------------------# # Action # #----------------------------------------------------------# -# Get old ip -get_domain_values 'dns' old=$IP -new=$ip -ipv6=$IP6 if [ -z "$old" ]; then #Create new @@ -71,13 +74,21 @@ else # Changing records sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf else + ip="" + ipv6=$IP6 #Delete configs remove_dns_config_records fi fi # Changing ip -update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$new" +update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip" + +#update counters +records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" +update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +records=$(wc -l $USER_DATA/dns/*.conf | cut -f 1 -d ' ') +update_user_value "$user" '$U_DNS_RECORDS' "$records" # Updating zone if [[ "$DNS_SYSTEM" =~ named|bind ]]; then diff --git a/bin/v-change-dns-domain-ipv6 b/bin/v-change-dns-domain-ipv6 index 2f810b69..a0a0510c 100755 --- a/bin/v-change-dns-domain-ipv6 +++ b/bin/v-change-dns-domain-ipv6 @@ -47,15 +47,17 @@ else ipv6='' fi +# Get old ip +get_domain_values 'dns' +if [ -z @"$ipv6" ] && [ -z "$IP" ]; then + check_result $E_INVALID "IP or IPv6 is required" +fi + #----------------------------------------------------------# # Action # #----------------------------------------------------------# -# Get old ip -get_domain_values 'dns' old=$IP6 -new=$ipv6 -ip=$IP if [ -z "$old" ]; then #Create new @@ -66,18 +68,25 @@ if [ -z "$old" ]; then ip="" add_dns_config_records else - if [ ! -z "$ip" ]; then + if [ ! -z "$ipv6" ]; then # Changing records sed -i "s/$old/$ipv6/g" $USER_DATA/dns/$domain.conf else #Delete configs - ipv6=$old + ipv6="" + ip=$IP remove_dns_config_records fi fi # Changing ip -update_object_value 'dns' 'DOMAIN' "$domain" '$IP6' "$new" +update_object_value 'dns' 'DOMAIN' "$domain" '$IP6' "$ipv6" + +#update counters +records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" +update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +records=$(wc -l $USER_DATA/dns/*.conf | cut -f 1 -d ' ') +update_user_value "$user" '$U_DNS_RECORDS' "$records" # Updating zone if [[ "$DNS_SYSTEM" =~ named|bind ]]; then diff --git a/bin/v-change-web-domain-ip b/bin/v-change-web-domain-ip index 0a6965d2..0cb5a861 100755 --- a/bin/v-change-web-domain-ip +++ b/bin/v-change-web-domain-ip @@ -54,6 +54,10 @@ fi # Preparing variables for vhost replace get_domain_values 'web' +if [ -z "$ip" ] && [ -z "$IP6" ]; then + check_result $E_INVALID "IP or IPv6 is required" +fi + old=$(get_real_ip $IP) new=$ip diff --git a/bin/v-change-web-domain-ipv6 b/bin/v-change-web-domain-ipv6 index bc86ed8d..eb8c8e57 100755 --- a/bin/v-change-web-domain-ipv6 +++ b/bin/v-change-web-domain-ipv6 @@ -52,6 +52,10 @@ fi # Preparing variables for vhost replace get_domain_values 'web' +if [ -z "$ipv6" ] && [ -z "$IP" ]; then + check_result $E_INVALID "IP or IPv6 is required" +fi + old=$IP6 new=$ipv6 diff --git a/bin/v-suspend-web-domain b/bin/v-suspend-web-domain index 1b8a0241..6d6cdc4f 100755 --- a/bin/v-suspend-web-domain +++ b/bin/v-suspend-web-domain @@ -76,6 +76,8 @@ fi # Rebuilding vhost IPv6 if [ ! -z "$IP6" ]; then + local_ip="" + ipv6=$IP6 old=$IP6 del_web_config "$WEB_SYSTEM" "$TPL.tpl" add_web_config "$WEB_SYSTEM" "$TPL.tpl" diff --git a/bin/v-unsuspend-web-domain b/bin/v-unsuspend-web-domain index b3ad2b4b..588da249 100755 --- a/bin/v-unsuspend-web-domain +++ b/bin/v-unsuspend-web-domain @@ -75,6 +75,8 @@ fi # Rebuilding vhost IPv6 if [ ! -z "$IP6" ]; then old=$IP6 + local_ip="" + ipv6=$IP6 del_web_config "$WEB_SYSTEM" "$TPL.tpl" add_web_config "$WEB_SYSTEM" "$TPL.tpl" if [ "$SSL" = 'yes' ]; then diff --git a/func/domain.sh b/func/domain.sh index 4c058609..987f5998 100644 --- a/func/domain.sh +++ b/func/domain.sh @@ -535,8 +535,6 @@ add_dns_config() { if [ ! -z $ipv6 ]; then spfipv6="ip6:$ipv6"; fi - echo $spfipv4 - echo $spfipv6 # Adding dns zone to the user config echo "$template_data" | grep -v '%ip' |\ @@ -605,16 +603,14 @@ add_dns_config_records() { if [ ! -z "$ipv6" ]; then template_data=$(echo "$template_data" |grep "%ipv6%") fi - - new_lines=$(echo "$template_data" |\ + + echo "$template_data" |\ sed -e "s/%ip%/$ip/g" \ -e "s/%ipv6%/$ipv6/g" \ -e "s/%time%/$time/g" \ -e "s/%date%/$date/g" \ |awk -F 'ID=' '{print $2}' \ - |cut -d\' --complement -s -f1,2) - - echo "$new_lines"\ + |cut -d\' --complement -s -f1,2 \ | while read line; do id="" get_next_dnsrecord @@ -626,7 +622,7 @@ add_dns_config_records() { remove_dns_config_records() { template_data=$(cat $DNSTPL/$TPL.tpl) - # Adding dns zone to the user config + # Search template data template_data=$(echo "$template_data" |grep -v "v=spf1" |egrep "%ip(v6)?%") if [ -z "$ip" ]; then template_data=$(echo "$template_data" |grep "%ip%") @@ -635,16 +631,14 @@ remove_dns_config_records() { template_data=$(echo "$template_data" |grep "%ipv6%") fi - delete_lines=$(echo "$template_data" |\ + echo "$template_data" |\ sed -e "s/%ip%/$old/g" \ -e "s/%ipv6%/$old/g" \ |awk -F 'ID=' '{print $2}' \ |cut -d\' --complement -s -f1,2 \ - |awk -F 'TIME=' '{print $1}'); - - echo "$delete_lines"\ + |awk -F ' SUSPENDED=' '{print $1}' \ | while read line; do - sed -i '/$line/d' $USER_DATA/dns/$domain.conf + sed -i "/$line/d" $USER_DATA/dns/$domain.conf done }