Skip to content

Commit 12c67c7

Browse files
committed
fix for dns cluster sync
1 parent e821bea commit 12c67c7

File tree

7 files changed

+31
-19
lines changed

7 files changed

+31
-19
lines changed

bin/v-add-dns-domain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ chown root:$dns_group $conf
146146

147147
# dns-cluster
148148
if [ ! -z "$DNS_CLUSTER" ]; then
149-
cmd="$BIN/v-add-remote-dns-domain $user $domain"
149+
cmd="$BIN/v-add-remote-dns-domain $user $domain no"
150150
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
151151
fi
152152

bin/v-add-remote-dns-domain

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add remote dns domain
3-
# options: USER DOMAIN
3+
# options: USER DOMAIN [FLUSH]
44
#
55
# The function synchronize dns domain with the remote server.
66

@@ -12,6 +12,7 @@
1212
# Argument defenition
1313
user=$1
1414
domain=$2
15+
flush=$3
1516

1617
# Includes
1718
source $VESTA/func/main.sh
@@ -23,7 +24,7 @@ source $VESTA/conf/vesta.conf
2324
# Verifications #
2425
#----------------------------------------------------------#
2526

26-
check_args '2' "$#" 'USER DOMAIN'
27+
check_args '2' "$#" 'USER DOMAIN [FLUSH]'
2728
validate_format 'user' 'domain'
2829
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
2930

@@ -89,10 +90,13 @@ for cluster_str in $search_str; do
8990
DNS_CLUSTER_IGNORE='dns-cluster'
9091
fi
9192

93+
# Check flush parameters
94+
9295
# Sync domain
9396
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
9497
eval $str
95-
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'flush' 'no'
98+
99+
$send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME "$flush" 'no'
96100
if [ $? -eq 0 ]; then
97101
# Sync records
98102
if [ "$TYPE" = 'ssh' ]; then
@@ -120,12 +124,11 @@ done
120124
# Update pipe
121125
rm -f $tmpfile
122126
pipe="$VESTA/data/queue/dns-cluster.pipe"
123-
str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
127+
str=$(grep -n "$SCRIPT $1 $2 " $pipe | cut -f1 -d: | head -n1)
124128
if [ ! -z "$str" ]; then
125129
sed -i "$str d" $pipe
126130
fi
127131

128-
129132
#----------------------------------------------------------#
130133
# Vesta #
131134
#----------------------------------------------------------#

bin/v-change-dns-domain-ip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
5757
# Check for first sync
5858
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
5959
if [ -z "$dlock" ]; then
60-
cmd="$BIN/v-add-remote-dns-domain $user $domain"
60+
cmd="$BIN/v-add-remote-dns-domain $user $domain domain"
6161
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
6262
fi
6363
fi

bin/v-change-dns-domain-tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
7575
# Check for first sync
7676
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
7777
if [ -z "$dlock" ]; then
78-
cmd="$BIN/v-add-remote-dns-domain $user $domain"
78+
cmd="$BIN/v-add-remote-dns-domain $user $domain domain"
7979
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
8080
fi
8181
fi

bin/v-change-dns-record

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
6868
# Check for first sync
6969
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
7070
if [ -z "$dlock" ]; then
71-
cmd="$BIN/v-add-remote-dns-domain $user $domain"
71+
cmd="$BIN/v-add-remote-dns-domain $user $domain records"
7272
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
7373
fi
7474
fi

bin/v-change-dns-record-id

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
5757
# Check for first sync
5858
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
5959
if [ -z "$dlock" ]; then
60-
cmd="$BIN/v-add-remote-dns-domain $user $domain"
60+
cmd="$BIN/v-add-remote-dns-domain $user $domain records"
6161
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
6262
fi
6363
fi

bin/v-insert-dns-domain

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,36 @@ is_object_valid 'user' 'USER' "$user"
3333
is_object_unsuspended 'user' 'USER' "$user"
3434
eval $data
3535
domain="$DOMAIN"
36-
is_domain_new 'dns'
36+
if [ "$flush" = 'no' ]; then
37+
is_domain_new 'dns'
38+
fi
3739

3840

3941
#----------------------------------------------------------#
4042
# Action #
4143
#----------------------------------------------------------#
4244

45+
# Flush records
46+
if [ "$flush" = 'records' ]; then
47+
rm -f $USER_DATA/dns/$DOMAIN.conf
48+
touch $USER_DATA/dns/$DOMAIN.conf
49+
chmod 660 $USER_DATA/dns/$DOMAIN.conf
50+
exit
51+
fi
52+
53+
# Flush domain
54+
if [ "$flush" = 'domain' ]; then
55+
sed -i "/DOMAIN='$DOMAIN'/d" $USER_DATA/dns.conf 2> /dev/null
56+
fi
57+
4358
# Prepare values for the insert
4459
dns_rec="DOMAIN='$DOMAIN' IP='$IP' TPL='$TPL' TTL='$TTL' EXP='$EXP'"
4560
dns_rec="$dns_rec SOA='$SOA' SRC='$src' RECORDS='$RECORDS'"
4661
dns_rec="$dns_rec SUSPENDED='$SUSPENDED' TIME='$TIME' DATE='$DATE'"
47-
sed -i "/DOMAIN='$DOMAIN'/d" $USER_DATA/dns.conf 2> /dev/null
4862
echo "$dns_rec" >> $USER_DATA/dns.conf
49-
chmod 660 $USER_DATA/dns.conf
5063

51-
# Flush dns records
52-
if [ "$flush" != 'no' ]; then
53-
rm -f $USER_DATA/dns/$DOMAIN.conf
54-
touch $USER_DATA/dns/$DOMAIN.conf
55-
chmod 660 $USER_DATA/dns/$DOMAIN.conf
56-
fi
64+
# Set permission
65+
chmod 660 $USER_DATA/dns.conf
5766

5867

5968
#----------------------------------------------------------#

0 commit comments

Comments
 (0)