mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 02:28:03 -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
|
||||
|
||||
# Checking domain
|
||||
is_domain_new 'quiet'
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
# Checking domain owner
|
||||
is_domain_owner
|
||||
|
||||
# Checking domain service
|
||||
is_dns_domain_free
|
||||
fi
|
||||
is_domain_new 'dns'
|
||||
|
||||
# Checking package
|
||||
is_package_full 'dns'
|
||||
|
|
|
@ -50,16 +50,7 @@ is_user_valid
|
|||
is_user_suspended
|
||||
|
||||
# Checking domain
|
||||
is_domain_new 'quiet'
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
# Checking domain owner
|
||||
is_domain_owner
|
||||
|
||||
# Checking domain service
|
||||
is_web_domain_free
|
||||
|
||||
fi
|
||||
is_domain_new 'dns'
|
||||
|
||||
# Checking ip
|
||||
is_ip_avalable
|
||||
|
|
|
@ -52,15 +52,7 @@ is_domain_valid 'web'
|
|||
is_domain_suspended 'web'
|
||||
|
||||
# Checking alias on the server
|
||||
is_domain_new 'quiet' "$dom_alias"
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
# Checking alias owner
|
||||
is_domain_owner "$dom_alias"
|
||||
|
||||
# Checking alias service
|
||||
is_web_domain_free "$dom_alias"
|
||||
fi
|
||||
is_domain_new 'web' "$dom_alias"
|
||||
|
||||
# Checking package
|
||||
is_package_full 'web_alias'
|
||||
|
|
|
@ -1,81 +1,22 @@
|
|||
# Checking domain existance
|
||||
is_domain_new() {
|
||||
output_mode="$1"
|
||||
search_dom=${2-$domain}
|
||||
|
||||
# Parsing domain values
|
||||
check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/*/*.conf| \
|
||||
grep -v cron.conf)
|
||||
|
||||
# Parsing alias values
|
||||
check_alias=$(grep -F 'ALIAS=' $V_USERS/*/*.conf | \
|
||||
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"
|
||||
config_type="$1"
|
||||
dom=${2-domain}
|
||||
check_all=$(grep -w $dom $V_USERS/*/*.conf)
|
||||
if [ ! -z "$check_all" ]; then
|
||||
check_ownership=$(grep -w $dom $V_USERS/$user/*.conf)
|
||||
if [ ! -z "$check_ownership" ]; then
|
||||
check_type=$(grep -w $dom $V_USERS/$user/$config_type.conf)
|
||||
if [ ! -z "$check_type" ]; then
|
||||
echo "Error: $dom exist"
|
||||
log_event 'debug' "$E_EXISTS $V_EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
else
|
||||
echo "Error: $dom exist"
|
||||
log_event 'debug' "$E_EXISTS $V_EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
return $E_EXISTS
|
||||
fi
|
||||
}
|
||||
|
||||
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"
|
||||
exit $E_EXISTS
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue