Просмотр исходного кода

additional improvements for domain verification

Serghey Rodin 13 лет назад
Родитель
Сommit
ca23ae66d2
2 измененных файлов с 31 добавлено и 36 удалено
  1. 11 4
      bin/v-add-dns-on-web-alias
  2. 20 32
      func/domain.sh

+ 11 - 4
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

+ 20 - 32
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
 }