dns cluster support

This commit is contained in:
Serghey Rodin 2013-05-28 16:09:07 +03:00
commit 68a34e18b7
47 changed files with 1536 additions and 64 deletions

73
bin/v-delete-dns-record Executable file
View file

@ -0,0 +1,73 @@
#!/bin/bash
# info: delete dns record
# options: USER DOMAIN ID [RESTART]
#
# The function for deleting a certain record of DNS zone.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
id=$3
restart=$4
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN ID [RESTART]'
validate_format 'user' 'domain' 'id'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_object_valid "dns/$domain" 'ID' "$id"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Deleting record
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
# Updating zone
update_domain_zone
# dns-cluster
if [ ! -z "$DNS_CLUSTER" ]; then
cmd="v-delete-remote-dns-record $user $domain $id"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Upddate counters
records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
decrease_user_value "$user" '$U_DNS_RECORDS'
# Restart named
if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns
fi
# Logging
log_history "deleted dns record $id on $domain"
log_event "$OK" "$EVENT"
exit