mirror of
https://github.com/myvesta/vesta
synced 2025-07-05 20:41:53 -07:00
101 lines
2.7 KiB
Bash
Executable file
101 lines
2.7 KiB
Bash
Executable file
#!/bin/bash
|
|
# info: delete web domain ssl support
|
|
# options: user domain
|
|
#
|
|
# The function disable https support and deletes SSL certificates.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
user=$1
|
|
domain=$(idn -t --quiet -u "$2" )
|
|
domain_idn=$(idn -t --quiet -a "$domain")
|
|
restart=$3
|
|
|
|
# Includes
|
|
source $VESTA/conf/vesta.conf
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/func/domain.sh
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'user domain'
|
|
validate_format 'user' 'domain'
|
|
is_system_enabled "$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"
|
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Parsing domain values
|
|
get_domain_values 'web'
|
|
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
|
|
tpl_file="$WEBTPL/apache_$TPL.stpl"
|
|
|
|
# Deleting domain
|
|
del_web_config
|
|
|
|
# Checking nginx
|
|
if [ ! -z "$NGINX" ]; then
|
|
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
|
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
|
del_web_config
|
|
fi
|
|
|
|
# Deleting old certificate
|
|
tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d)
|
|
rm -f $HOMEDIR/$user/conf/ssl.$domain.*
|
|
mv $USER_DATA/ssl/$domain.* $tmpdir
|
|
chown -R $user:$user $tmpdir
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Update config
|
|
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no'
|
|
|
|
# Checking last ssl domain
|
|
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf)
|
|
main_conf='/etc/httpd/conf.d/vesta.conf'
|
|
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
|
|
if [ -z "$ssl_dom" ]; then
|
|
sed -i "/Include ${conf////\/}/d" $main_conf
|
|
rm -f $conf
|
|
fi
|
|
|
|
# Checking last nginx domain
|
|
conf='/etc/nginx/conf.d/vesta_users.conf'
|
|
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
|
|
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
|
|
if [ -z "$last_snginx" ]; then
|
|
sed -i "/$user\/conf\/web\/snginx.conf/d" $conf
|
|
rm -f $HOMEDIR/$user/conf/web/snginx.conf
|
|
fi
|
|
|
|
# Decreasing domain value
|
|
decrease_user_value "$user" '$U_WEB_SSL'
|
|
|
|
# Restart web server
|
|
if [ "$restart" != 'no' ]; then
|
|
$BIN/v-restart-web "$EVENT"
|
|
fi
|
|
|
|
# Logging
|
|
log_history "disabled ssl support for $domain"
|
|
log_event "$OK" "$EVENT"
|
|
|
|
exit
|