From ca23ae66d2f3645f57f62a5af334ed8356ae2888 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Fri, 4 Jan 2013 18:06:46 +0200 Subject: [PATCH] additional improvements for domain verification --- bin/v-add-dns-on-web-alias | 15 ++++++++--- func/domain.sh | 52 +++++++++++++++----------------------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias index 7b9e2f7d5..1c0077c7e 100755 --- a/bin/v-add-dns-on-web-alias +++ b/bin/v-add-dns-on-web-alias @@ -49,15 +49,21 @@ get_domain_values 'web' # Check if it a simple domain if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-add-dns-domain $user $dom_alias $IP '' '' '' '' '' $restart + $BIN/v-add-dns-domain \ + $user $dom_alias $IP '' '' '' '' '' $restart > /dev/null fi else # Check subdomain sub=$(echo "$dom_alias" | cut -f1 -d . -s) dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then - $BIN/v-add-dns-domain $user $dom $IP '' '' '' '' '' $restart - $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart + $BIN/v-add-dns-domain \ + $user $dom $IP '' '' '' '' '' $restart > /dev/null + + if [ $? -eq 0 ]; then + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart + fi else if [ "$sub" == '*' ]; then rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) @@ -65,7 +71,8 @@ else rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) fi if [ -z "$rec" ]; then - $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart > /dev/null fi fi fi diff --git a/func/domain.sh b/func/domain.sh index fe76eabbf..a62cc1b41 100644 --- a/func/domain.sh +++ b/func/domain.sh @@ -105,60 +105,48 @@ is_domain_new() { c2=$(grep "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) c3=$(grep ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /) c4=$(grep ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /) - if [ ! -z "$c1" ] && [ "$type" != "web" ]; then + if [ ! -z "$c1" ] && [ "$type" == "web" ]; then echo "Error: domain $dom exist" log_event "$E_EXISTS" "$EVENT" exit $E_EXISTS fi - if [ ! -z "$c1" ]; then - c1_user=$(echo "$c1" |cut -f 7 -d /) - if [ "$c1_user" != "$user" ]; then - echo "Error: domain $dom exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi + if [ ! -z "$c1" ] && [ "$c1" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS fi - if [ ! -z "$c2" ] && [ "$type" != "web" ]; then + if [ ! -z "$c2" ] && [ "$type" == "web" ]; then echo "Error: domain $dom exist" log_event "$E_EXISTS" "$EVENT" exit $E_EXISTS fi - if [ ! -z "$c2" ]; then - c2_user=$(echo "$c2" |cut -f 7 -d /) - if [ "$c2_user" != "$user" ]; then - echo "Error: domain $dom exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi + if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS fi - if [ ! -z "$c3" ] && [ "$type" != "web" ]; then + if [ ! -z "$c3" ] && [ "$type" == "web" ]; then echo "Error: domain $dom exist" log_event "$E_EXISTS" "$EVENT" exit $E_EXISTS fi - if [ ! -z "$c3" ]; then - c3_user=$(echo "$c3" |cut -f 7 -d /) - if [ "$c3_user" != "$user" ]; then - echo "Error: domain $dom exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi + if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS fi - if [ ! -z "$c4" ] && [ "$type" != "web" ]; then + if [ ! -z "$c4" ] && [ "$type" == "web" ]; then echo "Error: domain $dom exist" log_event "$E_EXISTS" "$EVENT" exit $E_EXISTS fi - if [ ! -z "$c4" ]; then - c1_user=$(echo "$c4" |cut -f 7 -d /) - if [ "$c4_user" != "$user" ]; then - echo "Error: domain $dom exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi + if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then + echo "Error: domain $dom exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS fi fi }