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

75
bin/v-change-dns-record-id Executable file
View file

@ -0,0 +1,75 @@
#!/bin/bash
# info: change dns domain record id
# options: USER DOMAIN ID NEWID [RESTART]
#
# The function for changing internal record id.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
id=$3
newid=$4
restart=$5
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '4' "$#" 'USER DOMAIN ID NEWID [RESTART]'
validate_format 'user' 'domain' 'id' 'newid'
is_system_enabled "$DNS_SYSTEM"
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"
is_object_new "dns/$domain" 'ID' "$newid"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Change id
sed -i "s/^ID='$id'/ID='$newid'/" $USER_DATA/dns/$domain.conf
# Sorting records
sort_dns_records
# Updating zone
update_domain_zone
# dns-cluster
if [ ! -z "$DNS_CLUSTER" ]; then
cmd="v-add-remote-dns-domain $user $domain"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Restart named
if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns
fi
# Logging
log_history "changed dns record id on $domain"
log_event "$OK" "$EVENT"
exit