mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-21 05:44:07 -07:00
cleaning rebuild function
This commit is contained in:
parent
6f28668e40
commit
ceceb8548e
2 changed files with 55 additions and 50 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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,18 +241,31 @@ for domain in $(shell_list) ; do
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Config path
|
||||||
|
httpd_conf='/etc/httpd/conf.d/vesta.conf'
|
||||||
|
nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
|
||||||
|
|
||||||
|
# Checking if there is at least 1 domain
|
||||||
|
if [ "$domain_counter" -lt 1 ]; then
|
||||||
|
|
||||||
|
# Deleting web configs
|
||||||
|
rm -f $HOMEDIR/$user/conf/web/*
|
||||||
|
sed -i "/.*\/$user\/.*httpd.conf/d" $httpd_conf
|
||||||
|
if [ -e "$nginx_conf" ]; then
|
||||||
|
sed -i "/.*\/$user\/.*nginx.conf/d" $nginx_conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
# Renaming tmp config
|
# Renaming tmp config
|
||||||
tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
|
tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
|
||||||
conf="$HOMEDIR/$user/conf/web/httpd.conf"
|
conf="$HOMEDIR/$user/conf/web/httpd.conf"
|
||||||
if [ -e "$tmp_conf" ]; then
|
|
||||||
mv $tmp_conf $conf
|
mv $tmp_conf $conf
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking include in main httpd.conf
|
# Checking httpd.conf include
|
||||||
main_conf='/etc/httpd/conf.d/vesta.conf'
|
httpd_include=$(grep "$conf" $httpd_conf )
|
||||||
main_conf_check=$(grep "$conf" $main_conf )
|
if [ -z "$httpd_include" ]; then
|
||||||
if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then
|
echo "Include $conf" >> $httpd_conf
|
||||||
echo "Include $conf" >>$main_conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking ssl
|
# Checking ssl
|
||||||
|
@ -260,38 +273,38 @@ if [ "$ssl_change" = 'yes' ]; then
|
||||||
tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
|
tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
|
||||||
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
|
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
|
||||||
mv $tmp_conf $conf
|
mv $tmp_conf $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
|
||||||
|
|
||||||
|
# Checking ssl include
|
||||||
|
httpd_include=$(grep "$conf" $httpd_conf )
|
||||||
|
if [ -z "$httpd_include" ]; then
|
||||||
|
echo "Include $conf" >> $httpd_conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking nginx
|
# Checking nginx
|
||||||
if [ "$ngix_change" = 'yes' ]; then
|
if [ "$ngix_change" = 'yes' ]; then
|
||||||
nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
|
|
||||||
tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
|
tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
|
||||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||||
mv $tmp_conf $conf
|
mv $tmp_conf $conf
|
||||||
|
fi
|
||||||
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
|
||||||
|
|
||||||
# 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 #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue