robust dns cluster sync

This commit is contained in:
Serghey Rodin 2013-10-24 00:10:54 +03:00
commit b36b15921c
6 changed files with 37 additions and 29 deletions

View file

@ -53,7 +53,8 @@ IFS=$'\n'
# Check remote dns nodes # Check remote dns nodes
remote_dns_health_check remote_dns_health_check
for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do search_str=$(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf)
for cluster_str in $search_str; do
# Get host values # Get host values
eval $cluster_str eval $cluster_str
@ -83,25 +84,26 @@ for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
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
# Sync records
if [ "$TYPE" = 'ssh' ]; then
tmp=$(mktemp -u)
scp_cmd $USER_DATA/dns/$DOMAIN.conf $tmp
$send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp 'no'
else
for str in $(cat $USER_DATA/dns/$DOMAIN.conf); do
str=$(echo "$str" | sed 's/"/\\"/g')
$send_cmd v-insert-dns-record $DNS_USER $DOMAIN "$str"
done
fi
# Sync records # Rebuild dns zone
if [ "$TYPE" = 'ssh' ]; then $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
tmp=$(mktemp -u) if [ $? -ne 0 ]; then
scp_cmd $USER_DATA/dns/$DOMAIN.conf $tmp echo "Error: $TYPE connection to $HOST failed"
$send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp 'no' log_event "$E_CONNECT $EVENT"
else exit $E_CONNECT
for str in $(cat $USER_DATA/dns/$DOMAIN.conf); do fi
str=$(echo "$str" | sed 's/"/\\"/g')
$send_cmd v-insert-dns-record $DNS_USER $DOMAIN "$str"
done
fi
# Rebuild dns zone
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
if [ $? -ne 0 ]; then
echo "Error: $TYPE connection to $HOST failed"
log_event "$E_CONNECT $EVENT"
exit $E_CONNECT
fi fi
done done

View file

@ -84,13 +84,14 @@ for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
str=$(echo "$str" | sed 's/"/\\"/g') str=$(echo "$str" | sed 's/"/\\"/g')
$send_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no' $send_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no'
if [ $? -eq 0 ]; then
# Rebuild dns zone # Rebuild dns zone
$send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled' $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error: $TYPE connection to $HOST failed (rebuild)" echo "Error: $TYPE connection to $HOST failed (rebuild)"
log_event "$E_CONNECT $EVENT" log_event "$E_CONNECT $EVENT"
exit $E_CONNECT exit $E_CONNECT
fi
fi fi
done done

View file

@ -116,6 +116,11 @@ if [ ! -z "$dns_data" ]; then
$BIN/v-unsuspend-dns-domain $user $domain no >> /dev/null 2>&1 $BIN/v-unsuspend-dns-domain $user $domain no >> /dev/null 2>&1
$BIN/v-rebuild-dns-domains $owner no $BIN/v-rebuild-dns-domains $owner no
$BIN/v-rebuild-dns-domains $user $BIN/v-rebuild-dns-domains $user
# Resync dns cluster
if [ ! -z "$DNS_CLUSTER" ]; then
v-sync-dns-cluster
fi
fi fi
# MAIL domain # MAIL domain

View file

@ -93,7 +93,7 @@ done
# Update pipe # Update pipe
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 $3$" $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

View file

@ -96,7 +96,7 @@ done
# Update pipe # Update pipe
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 $3$" $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

View file

@ -111,7 +111,7 @@ done
# Update pipe # Update pipe
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 $3$" $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