cleaning rebuild function

This commit is contained in:
Serghey Rodin 2013-03-23 21:43:25 +02:00
commit ceceb8548e
2 changed files with 55 additions and 50 deletions

View file

@ -37,17 +37,8 @@ is_object_unsuspended 'user' 'USER' "$user"
user_domains=0 user_domains=0
user_records=0 user_records=0
suspended_dns=0 suspended_dns=0
# Checking dns folder
if [ ! -d "$USER_DATA/dns" ]; then
rm -f $USER_DATA/dns
mkdir $USER_DATA/dns
fi
# Defining config and fie
conf="$USER_DATA/dns.conf" conf="$USER_DATA/dns.conf"
# Defining user name servers # Defining user name servers
ns=$(get_user_value '$NS') ns=$(get_user_value '$NS')
i=1 i=1
@ -108,6 +99,7 @@ for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do
records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ')
user_records=$((user_records + records)) user_records=$((user_records + records))
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
done done

View file

@ -39,17 +39,17 @@ user_domains=0
user_ssl=0 user_ssl=0
user_aliases=0 user_aliases=0
suspended_web=0 suspended_web=0
conf=$USER_DATA/web.conf
fields='$DOMAIN'
nohead=1
domain_counter=0
# Clean up old config # Clean up old config
rm -f $HOMEDIR/$user/conf/tmp_*.conf rm -f $HOMEDIR/$user/conf/tmp_*.conf
# Defining config
conf=$USER_DATA/web.conf
fields='$DOMAIN'
nohead=1
# Starting loop # Starting loop
for domain in $(shell_list) ; do for domain in $(shell_list); do
((++ domain_counter))
# Rebuilding directories # Rebuilding directories
mkdir -p $HOMEDIR/$user/web/$domain \ mkdir -p $HOMEDIR/$user/web/$domain \
@ -241,57 +241,70 @@ for domain in $(shell_list) ; do
done done
# Renaming tmp config # Config path
tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" httpd_conf='/etc/httpd/conf.d/vesta.conf'
conf="$HOMEDIR/$user/conf/web/httpd.conf" nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
if [ -e "$tmp_conf" ]; then
mv $tmp_conf $conf
fi
# Checking include in main httpd.conf # Checking if there is at least 1 domain
main_conf='/etc/httpd/conf.d/vesta.conf' if [ "$domain_counter" -lt 1 ]; then
main_conf_check=$(grep "$conf" $main_conf )
if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then
echo "Include $conf" >>$main_conf
fi
# Checking ssl # Deleting web configs
if [ "$ssl_change" = 'yes' ]; then rm -f $HOMEDIR/$user/conf/web/*
tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" sed -i "/.*\/$user\/.*httpd.conf/d" $httpd_conf
conf="$HOMEDIR/$user/conf/web/shttpd.conf" if [ -e "$nginx_conf" ]; then
mv $tmp_conf $conf sed -i "/.*\/$user\/.*nginx.conf/d" $nginx_conf
# Checking include in main httpd.conf
main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then
echo "Include $conf" >>$main_conf
fi fi
fi
# Checking nginx else
if [ "$ngix_change" = 'yes' ]; then
nginx_conf='/etc/nginx/conf.d/vesta_users.conf' # Renaming tmp config
tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
mv $tmp_conf $conf mv $tmp_conf $conf
nginx_conf_check=$(grep "$conf" $nginx_conf ) # Checking httpd.conf include
if [ -z "$nginx_conf_check" ]; then httpd_include=$(grep "$conf" $httpd_conf )
echo "include $conf;" >>$nginx_conf if [ -z "$httpd_include" ]; then
echo "Include $conf" >> $httpd_conf
fi
# Checking ssl
if [ "$ssl_change" = 'yes' ]; then
tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
mv $tmp_conf $conf
fi
# Checking ssl include
httpd_include=$(grep "$conf" $httpd_conf )
if [ -z "$httpd_include" ]; then
echo "Include $conf" >> $httpd_conf
fi
# Checking nginx
if [ "$ngix_change" = 'yes' ]; then
tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
mv $tmp_conf $conf
fi
nginx_include=$(grep "$conf" $nginx_conf )
if [ -z "$nginx_include" ]; then
echo "include $conf;" >> $nginx_conf
fi fi
# Checking ssl for nginx # Checking ssl for nginx
if [ "$ssl_change" = 'yes' ]; then if [ "$ngix_change" = 'yes' ] && [ "$ssl_change" = 'yes' ]; then
tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
mv $tmp_conf $conf mv $tmp_conf $conf
nginx_conf_check=$(grep "$conf" $nginx_conf ) nginx_include=$(grep "$conf" $nginx_conf )
if [ -z "$nginx_conf_check" ]; then if [ -z "$nginx_include" ]; then
echo "include $conf;" >>$nginx_conf echo "include $conf;" >> $nginx_conf
fi fi
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#