simple way to remove old configs

This commit is contained in:
Serghey Rodin 2013-03-23 00:12:30 +02:00
parent 844168f53f
commit 6f28668e40
2 changed files with 14 additions and 21 deletions

View file

@ -111,38 +111,32 @@ rm -f /var/log/httpd/domains/$domain.error*
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
# Checking last ssl domain # Checking last ssl domain
conf='/etc/httpd/conf.d/vesta.conf'
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l) ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l)
if [ "$ssl_dom" -eq '0' ]; then if [ "$ssl_dom" -eq '0' ]; then
sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf sed -i "/.*\/$user\/.*shttpd.conf/d" $conf
rm -f $HOMEDIR/$user/conf/web/shttpd.conf
fi fi
# Checking last domain # Checking last domain
domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ') domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ')
if [ "$domains" -eq '0' ]; then if [ "$domains" -eq '0' ]; then
conf='/etc/httpd/conf.d/vesta.conf' sed -i "/.*\/$user\/.*httpd.conf/d" $conf
line=$(grep -n "$HOMEDIR/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : ) rm -f $HOMEDIR/$user/conf/web/httpd.conf
if [ ! -z "$line" ]; then
sed -i "$line d" $conf
fi
fi fi
# Checking last nginx domain # Checking last ssl nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf' 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'") last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then if [ -z "$last_snginx" ]; then
sline=$(grep -n "$HOMEDIR/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :) sed -i "/.*\/$user\/.*snginx.conf/d" $conf
if [ ! -z "$sline" ]; then
sed -i "$sline d" $conf
fi
rm -f $HOMEDIR/$user/conf/web/snginx.conf rm -f $HOMEDIR/$user/conf/web/snginx.conf
fi fi
# Checking last nginx domain
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
if [ -z "$last_nginx" ]; then if [ -z "$last_nginx" ]; then
line=$(grep -n "$HOMEDIR/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : ) sed -i "/.*\/$user\/.*nginx.conf/d" $conf
if [ ! -z "$line" ]; then
sed -i "$line d" $conf
fi
rm -f $HOMEDIR/$user/conf/web/nginx.conf rm -f $HOMEDIR/$user/conf/web/nginx.conf
fi fi

View file

@ -70,11 +70,10 @@ update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no'
# Checking last ssl domain # Checking last ssl domain
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf) ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf)
main_conf='/etc/httpd/conf.d/vesta.conf' conf='/etc/httpd/conf.d/vesta.conf'
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
if [ -z "$ssl_dom" ]; then if [ -z "$ssl_dom" ]; then
sed -i "/Include ${conf////\/}/d" $main_conf sed -i "/.*\/$user\/.*shttpd.conf/d" $conf
rm -f $conf rm -f $HOMEDIR/$user/conf/web/shttpd.conf
fi fi
# Checking last nginx domain # Checking last nginx domain
@ -82,7 +81,7 @@ conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then if [ -z "$last_snginx" ]; then
sed -i "/$user\/conf\/web\/snginx.conf/d" $conf sed -i "/.*\/$user\/.*snginx.conf/d" $conf
rm -f $HOMEDIR/$user/conf/web/snginx.conf rm -f $HOMEDIR/$user/conf/web/snginx.conf
fi fi