1
0
mirror of https://github.com/myvesta/vesta.git synced 2025-03-11 12:02:42 -07:00
myvesta/bin/v-delete-web-domain-backend

82 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2015-04-16 02:43:31 +03:00
#!/bin/bash
# info: deleting web domain backend configuration
# options: USER DOMAIN [RESTART]
#
# The function of deleting the virtualhost backend configuration.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2015-04-16 02:43:31 +03:00
user=$1
domain=$2
2017-03-05 23:34:07 +01:00
domain_idn=$2
2015-04-16 02:43:31 +03:00
# Includes
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/conf/vesta.conf
# Additional argument formatting
format_domain
format_domain_idn
2017-03-05 23:34:07 +01:00
# TODO: $domain_idn not used in this script - maybe $domain should be converted to $doman_idn ?
2015-04-16 02:43:31 +03:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER DOMAIN'
2016-06-09 17:09:25 +03:00
is_format_valid 'user' 'domain'
2015-04-16 02:43:31 +03:00
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
2016-06-09 17:09:25 +03:00
# Defining pool directory
pool=$(find -L /etc/php* -type d \( -name "pool.d" -o -name "*fpm.d" \))
2016-06-09 17:09:25 +03:00
if [ ! -e "$pool" ]; then
2016-11-23 11:20:34 +02:00
check_result $E_NOTEXIST "php-fpm pool doesn't exist"
2016-06-09 17:09:25 +03:00
fi
# Defining backend type
backend_type="$domain"
if [ "$WEB_BACKEND_POOL" = 'user' ]; then
backend_type="$user"
fi
# Checking last webdomain
if [ "$WEB_BACKEND_POOL" = 'user' ]; then
domains=$(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'|wc -l)
if [ "$backend" = "$user" ] && [ "$domains" -gt 1 ]; then
exit
fi
fi
2015-04-16 02:43:31 +03:00
# Deleting backend
2016-06-09 17:09:25 +03:00
rm -f $pool/$backend_type.conf
2015-04-16 02:43:31 +03:00
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
2015-10-28 16:34:41 +02:00
# Restarting backend server
$BIN/v-restart-web-backend $restart
check_result $? "Backend restart failed" >/dev/null
2015-04-16 02:43:31 +03:00
# Logging
log_history "deleting backend support for $domain"
2016-06-09 17:09:25 +03:00
log_event "$OK" "$ARGUMENTS"
2015-04-16 02:43:31 +03:00
exit