From a022877f0057b4c2c73e1e30526cb557b7c927be Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Thu, 27 Sep 2012 12:13:55 +0300 Subject: [PATCH] improved domain check function --- func/domain.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/func/domain.sh b/func/domain.sh index 9364184d..d3affd50 100755 --- a/func/domain.sh +++ b/func/domain.sh @@ -46,15 +46,21 @@ is_dns_template_valid() { # Checking domain existance is_domain_new() { - config_type="$1" + type="$1" dom=${2-$domain} - check_all=$(grep -w $dom $VESTA/data/users/*/*.conf) - if [ ! -z "$check_all" ]; then - check_ownership=$(grep -w $dom $USER_DATA/*.conf) - if [ ! -z "$check_ownership" ]; then - check_type1=$(grep -w "'$dom" $USER_DATA/$config_type.conf) - check_type2=$(grep -w ",$dom" $USER_DATA/$config_type.conf) - if [ ! -z "$check_type1" ] || [ ! -z "$check_type2" ]; then + web="$(grep -w $dom $VESTA/data/users/*/web.conf)" + dns="$(grep DOMAIN='$dom' $VESTA/data/users/*/dns.conf)" + mail="$(grep DOMAIN='$dom' $VESTA/data/users/*/mail.conf)" + + if [ -n "$web" ] || [ -n "$dns" ] || [ -n "$mail" ]; then + if [ ! -z "$(grep -w $dom $USER_DATA/*.conf)" ]; then + c1=$(grep "'$dom'" $USER_DATA/$type.conf) + c2=$(grep "'$dom," $USER_DATA/$type.conf) + c3=$(grep ",$dom," $USER_DATA/$type.conf) + c4=$(grep ",$dom'" $USER_DATA/$type.conf) + + if [ -n "$c1" ] || [ -n "$c2" ] || [ -n "$c3" ] || [ -n "$c4" ] + then echo "Error: domain $dom exist" log_event "$E_EXISTS" "$EVENT" exit $E_EXISTS