mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 13:24:25 -07:00
unified is_domain_new function
This commit is contained in:
parent
758b5e7a3e
commit
e6113ed80a
4 changed files with 17 additions and 101 deletions
|
@ -52,15 +52,7 @@ is_user_valid
|
||||||
is_user_suspended
|
is_user_suspended
|
||||||
|
|
||||||
# Checking domain
|
# Checking domain
|
||||||
is_domain_new 'quiet'
|
is_domain_new 'dns'
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
|
|
||||||
# Checking domain owner
|
|
||||||
is_domain_owner
|
|
||||||
|
|
||||||
# Checking domain service
|
|
||||||
is_dns_domain_free
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking package
|
# Checking package
|
||||||
is_package_full 'dns'
|
is_package_full 'dns'
|
||||||
|
|
|
@ -50,16 +50,7 @@ is_user_valid
|
||||||
is_user_suspended
|
is_user_suspended
|
||||||
|
|
||||||
# Checking domain
|
# Checking domain
|
||||||
is_domain_new 'quiet'
|
is_domain_new 'dns'
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
|
|
||||||
# Checking domain owner
|
|
||||||
is_domain_owner
|
|
||||||
|
|
||||||
# Checking domain service
|
|
||||||
is_web_domain_free
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking ip
|
# Checking ip
|
||||||
is_ip_avalable
|
is_ip_avalable
|
||||||
|
|
|
@ -52,15 +52,7 @@ is_domain_valid 'web'
|
||||||
is_domain_suspended 'web'
|
is_domain_suspended 'web'
|
||||||
|
|
||||||
# Checking alias on the server
|
# Checking alias on the server
|
||||||
is_domain_new 'quiet' "$dom_alias"
|
is_domain_new 'web' "$dom_alias"
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
|
|
||||||
# Checking alias owner
|
|
||||||
is_domain_owner "$dom_alias"
|
|
||||||
|
|
||||||
# Checking alias service
|
|
||||||
is_web_domain_free "$dom_alias"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking package
|
# Checking package
|
||||||
is_package_full 'web_alias'
|
is_package_full 'web_alias'
|
||||||
|
|
|
@ -1,81 +1,22 @@
|
||||||
# Checking domain existance
|
# Checking domain existance
|
||||||
is_domain_new() {
|
is_domain_new() {
|
||||||
output_mode="$1"
|
config_type="$1"
|
||||||
search_dom=${2-$domain}
|
dom=${2-domain}
|
||||||
|
check_all=$(grep -w $dom $V_USERS/*/*.conf)
|
||||||
# Parsing domain values
|
if [ ! -z "$check_all" ]; then
|
||||||
check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/*/*.conf| \
|
check_ownership=$(grep -w $dom $V_USERS/$user/*.conf)
|
||||||
grep -v cron.conf)
|
if [ ! -z "$check_ownership" ]; then
|
||||||
|
check_type=$(grep -w $dom $V_USERS/$user/$config_type.conf)
|
||||||
# Parsing alias values
|
if [ ! -z "$check_type" ]; then
|
||||||
check_alias=$(grep -F 'ALIAS=' $V_USERS/*/*.conf | \
|
echo "Error: $dom exist"
|
||||||
grep -v cron.conf | \
|
|
||||||
awk -F "ALIAS=" '{print $2}' | \
|
|
||||||
cut -f 2 -d \' | \
|
|
||||||
sed -e "s/,/\n/g" | \
|
|
||||||
grep "^$search_dom$" )
|
|
||||||
|
|
||||||
# Checking result
|
|
||||||
if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then
|
|
||||||
if [ "$output_mode" != 'quiet' ]; then
|
|
||||||
echo "Error: domain exist"
|
|
||||||
log_event 'debug' "$E_EXISTS $V_EVENT"
|
log_event 'debug' "$E_EXISTS $V_EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
return $E_EXISTS
|
else
|
||||||
fi
|
echo "Error: $dom exist"
|
||||||
}
|
|
||||||
|
|
||||||
is_domain_owner() {
|
|
||||||
search_dom=${1-$domain}
|
|
||||||
|
|
||||||
# Parsing domain values
|
|
||||||
check_domain=$(grep "DOMAIN='$search_dom'" $V_USERS/$user/*.conf)
|
|
||||||
|
|
||||||
# Parsing alias values
|
|
||||||
check_alias=$(grep 'ALIAS=' $V_USERS/$user/*.conf | \
|
|
||||||
awk -F "ALIAS=" '{print $2}' | \
|
|
||||||
cut -f 2 -d \' | \
|
|
||||||
sed -e "s/,/\n/g" | \
|
|
||||||
grep "^$search_dom$" )
|
|
||||||
|
|
||||||
# Checking result
|
|
||||||
if [ -z "$check_domain" ] && [ -z "$check_alias" ]; then
|
|
||||||
echo "Error: domain not owned"
|
|
||||||
log_event 'debug' "$E_FORBIDEN $V_EVENT"
|
|
||||||
exit $E_FORBIDEN
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_dns_domain_free() {
|
|
||||||
# Parsing domain values
|
|
||||||
check_domain=$(grep -F "DOMAIN='$domain'" $V_USERS/$user/dns.conf)
|
|
||||||
|
|
||||||
# Checking result
|
|
||||||
if [ ! -z "$check_domain" ]; then
|
|
||||||
echo "Error: domain exist"
|
|
||||||
log_event 'debug' "$E_EXISTS $V_EVENT"
|
log_event 'debug' "$E_EXISTS $V_EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
is_web_domain_free() {
|
|
||||||
search_dom=${1-$domain}
|
|
||||||
# Parsing domain values
|
|
||||||
check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/$user/web.conf)
|
|
||||||
|
|
||||||
# Parsing alias values
|
|
||||||
check_alias=$(grep -F 'ALIAS=' $V_USERS/$user/web.conf | \
|
|
||||||
awk -F "ALIAS=" '{print $2}' | \
|
|
||||||
cut -f 2 -d \' | \
|
|
||||||
sed -e "s/,/\n/g" | \
|
|
||||||
grep "^$search_dom$" )
|
|
||||||
|
|
||||||
# Checking result
|
|
||||||
if [ ! -z "$check_domain" ] || [ ! -z "$check_alias" ]; then
|
|
||||||
echo "Error: domain exist"
|
|
||||||
log_event 'debug' "$E_EXISTS $V_EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue