mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 13:24:25 -07:00
added nginx support
This commit is contained in:
parent
71385857ed
commit
91794b59b9
3 changed files with 74 additions and 8 deletions
|
@ -8,22 +8,24 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user="$1"
|
||||||
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/domain_func.sh
|
source $V_FUNC/domain_func.sh
|
||||||
source $V_FUNC/ip_func.sh
|
source $V_FUNC/ip_func.sh
|
||||||
|
|
||||||
|
url="${2-$V_SUSPEND_URL}"
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
# Checking arg number
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user [suspend_url]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user'
|
format_validation 'user' 'url'
|
||||||
|
|
||||||
# Checking web system is enabled
|
# Checking web system is enabled
|
||||||
is_system_enabled 'web'
|
is_system_enabled 'web'
|
||||||
|
@ -48,7 +50,7 @@ search_string="DOMAIN"
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
field='$DOMAIN'
|
field='$DOMAIN'
|
||||||
|
|
||||||
# Parsing unsuspeneded domains
|
# Parsing all domains
|
||||||
domains=$(dom_clear_search)
|
domains=$(dom_clear_search)
|
||||||
|
|
||||||
# Starting loop
|
# Starting loop
|
||||||
|
@ -59,13 +61,13 @@ for domain in $domains; do
|
||||||
tpl_file="$V_WEBTPL/apache_$template.tpl"
|
tpl_file="$V_WEBTPL/apache_$template.tpl"
|
||||||
ip=$(get_web_domain_value '$IP')
|
ip=$(get_web_domain_value '$IP')
|
||||||
web_port=$(get_config_value '$WEB_PORT')
|
web_port=$(get_config_value '$WEB_PORT')
|
||||||
domain=$(get_web_domain_value '$DOMAIN')
|
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
group="$user"
|
group="$user"
|
||||||
docroot="$V_HOME/$user/web/$domain/public_html"
|
docroot="$V_HOME/$user/web/$domain/public_html"
|
||||||
email="$user@$domain"
|
email="$user@$domain"
|
||||||
aliases=$(get_web_domain_value '$ALIAS')
|
aliases=$(get_web_domain_value '$ALIAS')
|
||||||
aliases_idn=$(idn -t --quiet -a "$aliases")
|
aliases_idn=$(idn -t --quiet -a "$aliases")
|
||||||
|
suspend=$(get_web_domain_value '$SUSPEND')
|
||||||
|
|
||||||
# Checking error log status
|
# Checking error log status
|
||||||
elog=$(get_web_domain_value '$ELOG')
|
elog=$(get_web_domain_value '$ELOG')
|
||||||
|
@ -99,6 +101,18 @@ for domain in $domains; do
|
||||||
change_web_config
|
change_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Checking suspend
|
||||||
|
if [ "$suspend" = 'yes' ]; then
|
||||||
|
# Defining search phrase
|
||||||
|
search_phrase='DocumentRoot '
|
||||||
|
|
||||||
|
# Defining replace string
|
||||||
|
str_repl=" Redirect / http://$url"
|
||||||
|
|
||||||
|
# Suspending vhost
|
||||||
|
change_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
# Checking ssl
|
# Checking ssl
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
if [ ! -z "$cert" ]; then
|
if [ ! -z "$cert" ]; then
|
||||||
|
@ -136,23 +150,50 @@ for domain in $domains; do
|
||||||
str_repl=' Options +Includes -Indexes -ExecCGI'
|
str_repl=' Options +Includes -Indexes -ExecCGI'
|
||||||
change_web_config
|
change_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Checking suspend
|
||||||
|
if [ "$suspend" = 'yes' ]; then
|
||||||
|
# Defining search phrase
|
||||||
|
search_phrase='DocumentRoot '
|
||||||
|
|
||||||
|
# Defining replace string
|
||||||
|
str_repl=" Redirect / http://$url"
|
||||||
|
|
||||||
|
# Suspending vhost
|
||||||
|
change_web_config
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking nginx
|
# Checking nginx
|
||||||
nginx=$(get_web_domain_value '$NGINX')
|
nginx=$(get_web_domain_value '$NGINX')
|
||||||
if [ ! -z "$nginx" ]; then
|
if [ ! -z "$nginx" ]; then
|
||||||
proxy_port=$(get_config_value '$PROXY_PORT')
|
proxy_port=$(get_config_value '$PROXY_PORT')
|
||||||
ext=$(get_web_domain_value '$NGINX_EXT')
|
extentions=$(get_web_domain_value '$NGINX_EXT')
|
||||||
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
|
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
|
||||||
conf="$V_HOME/$user/conf/tmp_nginx.conf"
|
conf="$V_HOME/$user/conf/tmp_nginx.conf"
|
||||||
add_web_config
|
add_web_config
|
||||||
|
|
||||||
|
if [ "$suspend" = 'yes' ]; then
|
||||||
|
search_phrase='proxy_pass'
|
||||||
|
str_repl=" rewrite ^(.*)\$ http://$url;"
|
||||||
|
change_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -z "$cert" ]; then
|
if [ ! -z "$cert" ]; then
|
||||||
proxy_ssl_port=$(get_config_value '$PROXY_SSL_PORT')
|
|
||||||
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
|
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
|
||||||
conf="$V_HOME/$user/conf/tmp_snginx.conf"
|
conf="$V_HOME/$user/conf/tmp_snginx.conf"
|
||||||
add_web_config
|
add_web_config
|
||||||
|
|
||||||
|
if [ "$suspend" = 'yes' ]; then
|
||||||
|
search_phrase='proxy_pass'
|
||||||
|
str_repl=" rewrite ^(.*)\$ http://$url;"
|
||||||
|
change_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
ngix_change='yes'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
@ -185,12 +226,13 @@ if [ ! -z "$ssl_cert" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking nginx
|
# Checking nginx
|
||||||
if [ ! -z "$nginx" ]; then
|
if [ "$ngix_change" = 'yes' ]; then
|
||||||
nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
|
nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
|
||||||
tmp_conf="$V_HOME/$user/conf/tmp_nginx.conf"
|
tmp_conf="$V_HOME/$user/conf/tmp_nginx.conf"
|
||||||
conf="$V_HOME/$user/conf/nginx.conf"
|
conf="$V_HOME/$user/conf/nginx.conf"
|
||||||
mv $tmp_conf $conf
|
mv $tmp_conf $conf
|
||||||
|
|
||||||
|
|
||||||
nginx_conf_check=$(grep "$conf" $nginx_conf )
|
nginx_conf_check=$(grep "$conf" $nginx_conf )
|
||||||
if [ -z "$nginx_conf_check" ]; then
|
if [ -z "$nginx_conf_check" ]; then
|
||||||
echo "include $conf;" >>$nginx_conf
|
echo "include $conf;" >>$nginx_conf
|
||||||
|
|
|
@ -50,6 +50,8 @@ domains=$(dom_clear_search)
|
||||||
# Starting unsuspend loop
|
# Starting unsuspend loop
|
||||||
for domain in $domains; do
|
for domain in $domains; do
|
||||||
|
|
||||||
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
# Get template name
|
# Get template name
|
||||||
tpl_name=$(get_web_domain_value '$TPL')
|
tpl_name=$(get_web_domain_value '$TPL')
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
||||||
|
@ -89,6 +91,26 @@ for domain in $domains; do
|
||||||
change_web_config
|
change_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check nginx vhost
|
||||||
|
nginx=$(get_web_domain_value '$NGINX')
|
||||||
|
if [ ! -z "$nginx" ]; then
|
||||||
|
ip=$(get_web_domain_value '$IP')
|
||||||
|
web_port=$(get_config_value '$WEB_PORT')
|
||||||
|
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
|
||||||
|
conf="$V_HOME/$user/conf/nginx.conf"
|
||||||
|
search_phrase='rewrite ^(.*)$'
|
||||||
|
str_repl=" proxy_pass http://$ip:$web_port;"
|
||||||
|
change_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$nginx" ] && [ ! -z "$cert" ]; then
|
||||||
|
web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
|
||||||
|
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
|
||||||
|
conf="$V_HOME/$user/conf/snginx.conf"
|
||||||
|
str_repl=" proxy_pass https://$ip:$web_ssl_port;"
|
||||||
|
change_web_config
|
||||||
|
fi
|
||||||
|
|
||||||
# Adding unsuspend in config
|
# Adding unsuspend in config
|
||||||
update_web_domain_value '$SUSPEND' 'no'
|
update_web_domain_value '$SUSPEND' 'no'
|
||||||
done
|
done
|
||||||
|
|
|
@ -281,7 +281,9 @@ change_web_config() {
|
||||||
-e 's/\//\\\//g')
|
-e 's/\//\\\//g')
|
||||||
|
|
||||||
# Changing config
|
# Changing config
|
||||||
sed -i "$str_numb s/.*/$str_repl/" $conf
|
if [ ! -z "$str" ]; then
|
||||||
|
sed -i "$str_numb s/.*/$str_repl/" $conf
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_web_domain_value() {
|
get_web_domain_value() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue