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 # dns-cluster
if [ ! -z "$DNS_CLUSTER" ]; then 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 echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
fi fi

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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