Skip to content

Commit a022877

Browse files
committed
improved domain check function
1 parent 779b9cf commit a022877

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

func/domain.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,21 @@ is_dns_template_valid() {
4646

4747
# Checking domain existance
4848
is_domain_new() {
49-
config_type="$1"
49+
type="$1"
5050
dom=${2-$domain}
51-
check_all=$(grep -w $dom $VESTA/data/users/*/*.conf)
52-
if [ ! -z "$check_all" ]; then
53-
check_ownership=$(grep -w $dom $USER_DATA/*.conf)
54-
if [ ! -z "$check_ownership" ]; then
55-
check_type1=$(grep -w "'$dom" $USER_DATA/$config_type.conf)
56-
check_type2=$(grep -w ",$dom" $USER_DATA/$config_type.conf)
57-
if [ ! -z "$check_type1" ] || [ ! -z "$check_type2" ]; then
51+
web="$(grep -w $dom $VESTA/data/users/*/web.conf)"
52+
dns="$(grep DOMAIN='$dom' $VESTA/data/users/*/dns.conf)"
53+
mail="$(grep DOMAIN='$dom' $VESTA/data/users/*/mail.conf)"
54+
55+
if [ -n "$web" ] || [ -n "$dns" ] || [ -n "$mail" ]; then
56+
if [ ! -z "$(grep -w $dom $USER_DATA/*.conf)" ]; then
57+
c1=$(grep "'$dom'" $USER_DATA/$type.conf)
58+
c2=$(grep "'$dom," $USER_DATA/$type.conf)
59+
c3=$(grep ",$dom," $USER_DATA/$type.conf)
60+
c4=$(grep ",$dom'" $USER_DATA/$type.conf)
61+
62+
if [ -n "$c1" ] || [ -n "$c2" ] || [ -n "$c3" ] || [ -n "$c4" ]
63+
then
5864
echo "Error: domain $dom exist"
5965
log_event "$E_EXISTS" "$EVENT"
6066
exit $E_EXISTS

0 commit comments

Comments
 (0)