fix for dns cluster sync

This commit is contained in:
Serghey Rodin 2013-11-27 09:02:40 +02:00
commit 12c67c76b3
7 changed files with 31 additions and 19 deletions

View file

@ -146,7 +146,7 @@ chown root:$dns_group $conf
# dns-cluster
if [ ! -z "$DNS_CLUSTER" ]; then
cmd="$BIN/v-add-remote-dns-domain $user $domain"
cmd="$BIN/v-add-remote-dns-domain $user $domain no"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: add remote dns domain
# options: USER DOMAIN
# options: USER DOMAIN [FLUSH]
#
# The function synchronize dns domain with the remote server.
@ -12,6 +12,7 @@
# Argument defenition
user=$1
domain=$2
flush=$3
# Includes
source $VESTA/func/main.sh
@ -23,7 +24,7 @@ source $VESTA/conf/vesta.conf
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DOMAIN'
check_args '2' "$#" 'USER DOMAIN [FLUSH]'
validate_format 'user' 'domain'
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
@ -89,10 +90,13 @@ for cluster_str in $search_str; do
DNS_CLUSTER_IGNORE='dns-cluster'
fi
# Check flush parameters
# Sync domain
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
eval $str
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'flush' 'no'
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME "$flush" 'no'
if [ $? -eq 0 ]; then
# Sync records
if [ "$TYPE" = 'ssh' ]; then
@ -120,12 +124,11 @@ done
# Update pipe
rm -f $tmpfile
pipe="$VESTA/data/queue/dns-cluster.pipe"
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
str=$(grep -n "$SCRIPT $1 $2 " $pipe | cut -f1 -d: | head -n1)
if [ ! -z "$str" ]; then
sed -i "$str d" $pipe
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#

View file

@ -57,7 +57,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
if [ -z "$dlock" ]; then
cmd="$BIN/v-add-remote-dns-domain $user $domain"
cmd="$BIN/v-add-remote-dns-domain $user $domain domain"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi
fi

View file

@ -75,7 +75,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
if [ -z "$dlock" ]; then
cmd="$BIN/v-add-remote-dns-domain $user $domain"
cmd="$BIN/v-add-remote-dns-domain $user $domain domain"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi
fi

View file

@ -68,7 +68,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
if [ -z "$dlock" ]; then
cmd="$BIN/v-add-remote-dns-domain $user $domain"
cmd="$BIN/v-add-remote-dns-domain $user $domain records"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi
fi

View file

@ -57,7 +57,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
if [ -z "$dlock" ]; then
cmd="$BIN/v-add-remote-dns-domain $user $domain"
cmd="$BIN/v-add-remote-dns-domain $user $domain records"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi
fi

View file

@ -33,27 +33,36 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
eval $data
domain="$DOMAIN"
if [ "$flush" = 'no' ]; then
is_domain_new 'dns'
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Flush records
if [ "$flush" = 'records' ]; then
rm -f $USER_DATA/dns/$DOMAIN.conf
touch $USER_DATA/dns/$DOMAIN.conf
chmod 660 $USER_DATA/dns/$DOMAIN.conf
exit
fi
# Flush domain
if [ "$flush" = 'domain' ]; then
sed -i "/DOMAIN='$DOMAIN'/d" $USER_DATA/dns.conf 2> /dev/null
fi
# Prepare values for the insert
dns_rec="DOMAIN='$DOMAIN' IP='$IP' TPL='$TPL' TTL='$TTL' EXP='$EXP'"
dns_rec="$dns_rec SOA='$SOA' SRC='$src' RECORDS='$RECORDS'"
dns_rec="$dns_rec SUSPENDED='$SUSPENDED' TIME='$TIME' DATE='$DATE'"
sed -i "/DOMAIN='$DOMAIN'/d" $USER_DATA/dns.conf 2> /dev/null
echo "$dns_rec" >> $USER_DATA/dns.conf
chmod 660 $USER_DATA/dns.conf
# Flush dns records
if [ "$flush" != 'no' ]; then
rm -f $USER_DATA/dns/$DOMAIN.conf
touch $USER_DATA/dns/$DOMAIN.conf
chmod 660 $USER_DATA/dns/$DOMAIN.conf
fi
# Set permission
chmod 660 $USER_DATA/dns.conf
#----------------------------------------------------------#