Skip to content

Commit ca23ae6

Browse files
committed
additional improvements for domain verification
1 parent 0ef19bf commit ca23ae6

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

bin/v-add-dns-on-web-alias

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,30 @@ get_domain_values 'web'
4949
# Check if it a simple domain
5050
if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
5151
if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then
52-
$BIN/v-add-dns-domain $user $dom_alias $IP '' '' '' '' '' $restart
52+
$BIN/v-add-dns-domain \
53+
$user $dom_alias $IP '' '' '' '' '' $restart > /dev/null
5354
fi
5455
else
5556
# Check subdomain
5657
sub=$(echo "$dom_alias" | cut -f1 -d . -s)
5758
dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
5859
if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
59-
$BIN/v-add-dns-domain $user $dom $IP '' '' '' '' '' $restart
60-
$BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart
60+
$BIN/v-add-dns-domain \
61+
$user $dom $IP '' '' '' '' '' $restart > /dev/null
62+
63+
if [ $? -eq 0 ]; then
64+
$BIN/v-add-dns-domain-record \
65+
$user $dom "$sub" A $IP '' '' $restart
66+
fi
6167
else
6268
if [ "$sub" == '*' ]; then
6369
rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
6470
else
6571
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
6672
fi
6773
if [ -z "$rec" ]; then
68-
$BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart
74+
$BIN/v-add-dns-domain-record \
75+
$user $dom "$sub" A $IP '' '' $restart > /dev/null
6976
fi
7077
fi
7178
fi

func/domain.sh

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -105,60 +105,48 @@ is_domain_new() {
105105
c2=$(grep "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
106106
c3=$(grep ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
107107
c4=$(grep ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
108-
if [ ! -z "$c1" ] && [ "$type" != "web" ]; then
108+
if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
109109
echo "Error: domain $dom exist"
110110
log_event "$E_EXISTS" "$EVENT"
111111
exit $E_EXISTS
112112
fi
113-
if [ ! -z "$c1" ]; then
114-
c1_user=$(echo "$c1" |cut -f 7 -d /)
115-
if [ "$c1_user" != "$user" ]; then
116-
echo "Error: domain $dom exist"
117-
log_event "$E_EXISTS" "$EVENT"
118-
exit $E_EXISTS
119-
fi
113+
if [ ! -z "$c1" ] && [ "$c1" != "$user" ]; then
114+
echo "Error: domain $dom exist"
115+
log_event "$E_EXISTS" "$EVENT"
116+
exit $E_EXISTS
120117
fi
121118

122-
if [ ! -z "$c2" ] && [ "$type" != "web" ]; then
119+
if [ ! -z "$c2" ] && [ "$type" == "web" ]; then
123120
echo "Error: domain $dom exist"
124121
log_event "$E_EXISTS" "$EVENT"
125122
exit $E_EXISTS
126123
fi
127-
if [ ! -z "$c2" ]; then
128-
c2_user=$(echo "$c2" |cut -f 7 -d /)
129-
if [ "$c2_user" != "$user" ]; then
130-
echo "Error: domain $dom exist"
131-
log_event "$E_EXISTS" "$EVENT"
132-
exit $E_EXISTS
133-
fi
124+
if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then
125+
echo "Error: domain $dom exist"
126+
log_event "$E_EXISTS" "$EVENT"
127+
exit $E_EXISTS
134128
fi
135129

136-
if [ ! -z "$c3" ] && [ "$type" != "web" ]; then
130+
if [ ! -z "$c3" ] && [ "$type" == "web" ]; then
137131
echo "Error: domain $dom exist"
138132
log_event "$E_EXISTS" "$EVENT"
139133
exit $E_EXISTS
140134
fi
141-
if [ ! -z "$c3" ]; then
142-
c3_user=$(echo "$c3" |cut -f 7 -d /)
143-
if [ "$c3_user" != "$user" ]; then
144-
echo "Error: domain $dom exist"
145-
log_event "$E_EXISTS" "$EVENT"
146-
exit $E_EXISTS
147-
fi
135+
if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then
136+
echo "Error: domain $dom exist"
137+
log_event "$E_EXISTS" "$EVENT"
138+
exit $E_EXISTS
148139
fi
149140

150-
if [ ! -z "$c4" ] && [ "$type" != "web" ]; then
141+
if [ ! -z "$c4" ] && [ "$type" == "web" ]; then
151142
echo "Error: domain $dom exist"
152143
log_event "$E_EXISTS" "$EVENT"
153144
exit $E_EXISTS
154145
fi
155-
if [ ! -z "$c4" ]; then
156-
c1_user=$(echo "$c4" |cut -f 7 -d /)
157-
if [ "$c4_user" != "$user" ]; then
158-
echo "Error: domain $dom exist"
159-
log_event "$E_EXISTS" "$EVENT"
160-
exit $E_EXISTS
161-
fi
146+
if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then
147+
echo "Error: domain $dom exist"
148+
log_event "$E_EXISTS" "$EVENT"
149+
exit $E_EXISTS
162150
fi
163151
fi
164152
}

0 commit comments

Comments
 (0)