|
1 | 1 | # Checking domain existance |
2 | 2 | is_domain_new() { |
3 | | - output_mode="$1" |
4 | | - search_dom=${2-$domain} |
5 | | - |
6 | | - # Parsing domain values |
7 | | - check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/*/*.conf| \ |
8 | | - grep -v cron.conf) |
9 | | - |
10 | | - # Parsing alias values |
11 | | - check_alias=$(grep -F 'ALIAS=' $V_USERS/*/*.conf | \ |
12 | | - grep -v cron.conf | \ |
13 | | - awk -F "ALIAS=" '{print $2}' | \ |
14 | | - cut -f 2 -d \' | \ |
15 | | - sed -e "s/,/\n/g" | \ |
16 | | - grep "^$search_dom$" ) |
17 | | - |
18 | | - # Checking result |
19 | | - if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then |
20 | | - if [ "$output_mode" != 'quiet' ]; then |
21 | | - echo "Error: domain exist" |
| 3 | + config_type="$1" |
| 4 | + dom=${2-domain} |
| 5 | + check_all=$(grep -w $dom $V_USERS/*/*.conf) |
| 6 | + if [ ! -z "$check_all" ]; then |
| 7 | + check_ownership=$(grep -w $dom $V_USERS/$user/*.conf) |
| 8 | + if [ ! -z "$check_ownership" ]; then |
| 9 | + check_type=$(grep -w $dom $V_USERS/$user/$config_type.conf) |
| 10 | + if [ ! -z "$check_type" ]; then |
| 11 | + echo "Error: $dom exist" |
| 12 | + log_event 'debug' "$E_EXISTS $V_EVENT" |
| 13 | + exit $E_EXISTS |
| 14 | + fi |
| 15 | + else |
| 16 | + echo "Error: $dom exist" |
22 | 17 | log_event 'debug' "$E_EXISTS $V_EVENT" |
23 | 18 | exit $E_EXISTS |
24 | 19 | fi |
25 | | - return $E_EXISTS |
26 | | - fi |
27 | | -} |
28 | | - |
29 | | -is_domain_owner() { |
30 | | - search_dom=${1-$domain} |
31 | | - |
32 | | - # Parsing domain values |
33 | | - check_domain=$(grep "DOMAIN='$search_dom'" $V_USERS/$user/*.conf) |
34 | | - |
35 | | - # Parsing alias values |
36 | | - check_alias=$(grep 'ALIAS=' $V_USERS/$user/*.conf | \ |
37 | | - awk -F "ALIAS=" '{print $2}' | \ |
38 | | - cut -f 2 -d \' | \ |
39 | | - sed -e "s/,/\n/g" | \ |
40 | | - grep "^$search_dom$" ) |
41 | | - |
42 | | - # Checking result |
43 | | - if [ -z "$check_domain" ] && [ -z "$check_alias" ]; then |
44 | | - echo "Error: domain not owned" |
45 | | - log_event 'debug' "$E_FORBIDEN $V_EVENT" |
46 | | - exit $E_FORBIDEN |
47 | | - fi |
48 | | -} |
49 | | - |
50 | | -is_dns_domain_free() { |
51 | | - # Parsing domain values |
52 | | - check_domain=$(grep -F "DOMAIN='$domain'" $V_USERS/$user/dns.conf) |
53 | | - |
54 | | - # Checking result |
55 | | - if [ ! -z "$check_domain" ]; then |
56 | | - echo "Error: domain exist" |
57 | | - log_event 'debug' "$E_EXISTS $V_EVENT" |
58 | | - exit $E_EXISTS |
59 | | - fi |
60 | | -} |
61 | | - |
62 | | -is_web_domain_free() { |
63 | | - search_dom=${1-$domain} |
64 | | - # Parsing domain values |
65 | | - check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/$user/web.conf) |
66 | | - |
67 | | - # Parsing alias values |
68 | | - check_alias=$(grep -F 'ALIAS=' $V_USERS/$user/web.conf | \ |
69 | | - awk -F "ALIAS=" '{print $2}' | \ |
70 | | - cut -f 2 -d \' | \ |
71 | | - sed -e "s/,/\n/g" | \ |
72 | | - grep "^$search_dom$" ) |
73 | | - |
74 | | - # Checking result |
75 | | - if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then |
76 | | - echo "Error: domain exist" |
77 | | - log_event 'debug' "$E_EXISTS $V_EVENT" |
78 | | - exit $E_EXISTS |
79 | 20 | fi |
80 | 21 | } |
81 | 22 |
|
|
0 commit comments