improoved suspend function

This commit is contained in:
Serghey Rodin 2012-06-29 13:09:32 +03:00
commit e177cefef9
34 changed files with 75 additions and 172 deletions

View file

@ -72,7 +72,6 @@ fi
group="$user"
email="$user@$domain"
docroot="$HOMEDIR/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$template.tpl"

View file

@ -73,14 +73,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config

View file

@ -66,14 +66,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config

View file

@ -49,7 +49,7 @@ is_nginx_template_valid
get_domain_values 'web'
NGINX="$template"
NGINX_EXT="$extentions"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
# Preparing domain values for the template substitution
@ -69,8 +69,7 @@ fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config

View file

@ -84,7 +84,7 @@ fi
# Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot
fi
# Checking main vesta httpd config
@ -98,7 +98,7 @@ fi
if [ ! -z "$NGINX" ]; then
# Adding domain to the snginx.conf
conf="$HOMEDIR/$user/conf/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
add_web_config
chown root:nginx $conf

View file

@ -163,14 +163,14 @@ then
# Nginx config
if [ ! -z "$NGINX" ] ; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
# SSL check
if [ "$SSL" = 'yes' ] ; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf

View file

@ -60,14 +60,14 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
replace_web_config
fi
# Checking nginx
if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
replace_web_config
fi

View file

@ -48,7 +48,7 @@ is_nginx_template_valid
# Parsing domain values
get_domain_values 'web'
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
# Delete old vhost
@ -56,7 +56,7 @@ del_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi
@ -64,7 +64,7 @@ fi
# Add new vhost
NGINX="$template"
NGINX_EXT="$extentions"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
upd_web_domain_values
add_web_config
@ -73,8 +73,7 @@ chmod 640 $conf
# Checking ssl
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config
chown root:nginx $conf

View file

@ -56,7 +56,7 @@ replace_web_config
# Checking nginx config
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web//snginx.conf"
replace_web_config
fi

View file

@ -58,55 +58,9 @@ if [ "$SSL" = 'yes' ]; then
fi
# Defining variables for new vhost config
ip=$IP
email="$user@$domain"
group="$user"
docroot="$HOMEDIR/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
upd_web_domain_values
tpl_file="$WEBTPL/apache_$template.tpl"
# Parsing domain aliases
i=1
j=1
OLD_IFS="$IFS"
IFS=','
for dom_alias in $ALIAS; do
dom_alias=$(idn -t --quiet -a $dom_alias)
# Spliting ServerAlias lines
check_8k="$server_alias $dom_alias"
if [ "${#check_8k}" -ge '8100' ]; then
if [ "$j" -eq 1 ]; then
alias_string="ServerAlias $server_alias"
else
alias_string="$alias_string\n ServerAlias $server_alias"
fi
(( ++j))
server_alias=''
fi
if [ "$i" -eq 1 ]; then
aliases_idn="$dom_alias"
server_alias="$dom_alias"
alias_string="ServerAlias $server_alias"
else
aliases_idn="$aliases_idn,$dom_alias"
server_alias="$server_alias $dom_alias"
fi
(( ++i))
done
if [ -z "$alias_string" ]; then
alias_string="ServerAlias $server_alias"
else
if [ ! -z "$server_alias" ]; then
alias_string="$alias_string\n ServerAlias $server_alias"
fi
fi
IFS=$OLD_IFS
# Parsing new template
template_data=$(cat $WEBTPL/apache_$template.descr | grep -v '#')
for keys in $template_data; do
@ -130,28 +84,15 @@ fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
# Defining SSL vars
ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
if [ ! -e "$USER_DATA/web/ssl/$domain.ca" ]; then
ssl_ca_str='#'
fi
case $SSL_HOME in
single) docroot="$HOMEDIR/$user/web/$domain/public_shtml" ;;
same) docroot="$HOMEDIR/$user/web/$domain/public_html" ;;
esac
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$template.stpl"
# Adding domain to the httpd.conf
add_web_config
# Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh \
"$user" "$domain" "$ip" "$HOMEDIR" "$docroot"
"$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot"
fi
fi

View file

@ -70,13 +70,12 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi

View file

@ -72,14 +72,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config

View file

@ -64,14 +64,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config

View file

@ -41,13 +41,13 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
# Defining domain parameters
get_domain_values 'web'
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi

View file

@ -49,7 +49,7 @@ del_web_config
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi

View file

@ -21,8 +21,8 @@ json_list_wtpl() {
i='1' # iterator
echo '{'
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
if [ -e "$WEBTPL/ngingx_vhost_$template.descr" ]; then
descr=$(cat $WEBTPL/ngingx_vhost_$template.descr | grep '#'|\
if [ -e "$WEBTPL/ngingx_$template.descr" ]; then
descr=$(cat $WEBTPL/ngingx_$template.descr | grep '#'|\
sed -e ':a;N;$!ba;s/\n/ /g')
if [ $i -ne 1 ]; then
echo -e "\t},"
@ -42,8 +42,8 @@ json_list_wtpl() {
# Shell function
shell_list_wtpl() {
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
if [ -e "$WEBTPL/ngingx_vhost_$template.descr" ]; then
tpl_descr=$(cat $WEBTPL/ngingx_vhost_$template.descr |grep '#')
if [ -e "$WEBTPL/ngingx_$template.descr" ]; then
tpl_descr=$(cat $WEBTPL/ngingx_$template.descr |grep '#')
if [ -z "$nohead" ]; then
echo "----------"
fi

View file

@ -18,14 +18,13 @@ source $VESTA/func/main.sh
source $VESTA/func/domain.sh
source $VESTA/func/ip.sh
url=${2-$SUSPEND_URL}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'user [suspend_url]'
validate_format 'user' 'url'
check_args '1' "$#" 'user'
validate_format 'user'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
@ -177,7 +176,7 @@ for domain in $(shell_list) ; do
# Running template trigger
if [ -x $WEBTPL/apache_$TPL.sh ]; then
$WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot
$WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot
fi
user_ssl=$((user_ssl + 1))
@ -186,20 +185,14 @@ for domain in $(shell_list) ; do
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
add_web_config
chown root:nginx $conf
chmod 640 $conf
if [ "$SSL" = 'yes' ]; then
if [ "$SUSPENDED" = 'yes' ]; then
proxy_string="rewrite ^(.*)\$ http://$url;"
else
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
fi
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
add_web_config
chown root:nginx $conf

View file

@ -15,22 +15,21 @@
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
url="${3-$SUSPEND_URL}"
restart=$4
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user domain [suspend_url]'
validate_format 'user' 'domain' 'url'
check_args '2' "$#" 'user domain [restart]'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
@ -64,14 +63,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
proxy_string="rewrite ^(.*)\$ http://$url;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config

View file

@ -17,9 +17,6 @@ source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
# Defining url
url="${2-$SUSPEND_URL}"
#----------------------------------------------------------#
# Verifications #

View file

@ -25,7 +25,7 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user domain'
check_args '2' "$#" 'user domain [restart]'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -60,14 +60,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config