8k alias fix + new tpl convention

This commit is contained in:
Serghey Rodin 2011-11-21 15:37:23 +02:00
commit 7ce7cf1797
41 changed files with 721 additions and 908 deletions

View file

@ -7,7 +7,7 @@
# Argument defenition # Argument defenition
user=$1 user=$1
cert=$2 ssl=$2
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
@ -19,10 +19,10 @@ source $V_FUNC/cert.func
#----------------------------------------------------------# #----------------------------------------------------------#
# Checking arg number # Checking arg number
check_args '2' "$#" 'user certificate' check_args '2' "$#" 'user ssl_certificate'
# Checking argument format # Checking argument format
format_validation 'user' 'certificate' format_validation 'user' 'ssl'
# Checking user # Checking user
is_user_valid is_user_valid
@ -42,8 +42,8 @@ is_cert_valid "$V_TMP"
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding certificate to user dir # Adding certificate to user dir
mv $V_TMP/$cert.crt $V_USERS/$user/cert/ mv $V_TMP/$ssl.crt $V_USERS/$user/cert/
mv $V_TMP/$cert.key $V_USERS/$user/cert/ mv $V_TMP/$ssl.key $V_USERS/$user/cert/
#----------------------------------------------------------# #----------------------------------------------------------#
@ -51,7 +51,7 @@ mv $V_TMP/$cert.key $V_USERS/$user/cert/
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "$V_EVENT" "v_del_ssl_certificate $user $cert" log_history "$V_EVENT" "v_del_ssl_certificate $user $ssl"
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"
exit exit

View file

@ -14,6 +14,7 @@ template=${4-default}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
source $V_FUNC/ip.func source $V_FUNC/ip.func
@ -66,6 +67,7 @@ is_template_valid "web"
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining domain aliases # Defining domain aliases
IP=$ip
ip_name=$(get_ip_name) ip_name=$(get_ip_name)
ip_name_idn=$(idn -t --quiet -a "$ip_name") ip_name_idn=$(idn -t --quiet -a "$ip_name")
domain_alias="www.$domain" domain_alias="www.$domain"
@ -75,16 +77,19 @@ if [ ! -z "$ip_name" ]; then
domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn" domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn"
aliases="$domain_alias,$domain_alias_dash" aliases="$domain_alias,$domain_alias_dash"
aliases_idn="$domain_alias_idn,$domain_alias_dash_idn" aliases_idn="$domain_alias_idn,$domain_alias_dash_idn"
alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn"
else else
aliases="$domain_alias" aliases="$domain_alias"
aliases_idn="$domain_alias_idn" aliases_idn="$domain_alias_idn"
alias_string="ServerAlias $domain_alias_idn"
fi fi
# Defining vars for add_config function # Defining vars for add_config function
web_port=$(get_config_value '$WEB_PORT')
group="$user" group="$user"
email="$user@$domain" email="$user@$domain"
docroot="$V_HOME/$user/web/$domain/public_html" docroot="$V_HOME/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
tpl_file="$V_WEBTPL/apache_$template.tpl" tpl_file="$V_WEBTPL/apache_$template.tpl"
@ -96,9 +101,18 @@ done
# Checking error log status # Checking error log status
if [ "$ELOG" = 'no' ]; then if [ "$ELOG" = 'no' ]; then
elog=' #' elog='#'
else else
elog=' ' elog=''
fi
# Checking cgi
if [ "$CGI" != 'yes' ]; then
cgi='#'
cgi_option='-ExecCGI'
else
cgi=''
cgi_option='+ExecCGI'
fi fi
# Adding domain to the httpd.conf # Adding domain to the httpd.conf
@ -177,7 +191,7 @@ fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing ip value # Increasing ip value
increase_ip_value increase_ip_value "$ip"
# Increasing domain value # Increasing domain value
increase_user_value "$user" '$U_WEB_DOMAINS' increase_user_value "$user" '$U_WEB_DOMAINS'
@ -189,7 +203,7 @@ v_str="$v_str U_DISK='0'"
v_str="$v_str U_BANDWIDTH='0'" v_str="$v_str U_BANDWIDTH='0'"
v_str="$v_str TPL='$template'" v_str="$v_str TPL='$template'"
v_str="$v_str ALIAS='$aliases'" v_str="$v_str ALIAS='$aliases'"
v_str="$v_str $template_data" # Inserting PHP,CGI and ELOG keys v_str="$v_str $template_data" # Inserting PHP, CGI and ELOG keys
v_str="$v_str STATS='' STATS_AUTH=''" v_str="$v_str STATS='' STATS_AUTH=''"
v_str="$v_str SSL_HOME='' SSL_CERT=''" v_str="$v_str SSL_HOME='' SSL_CERT=''"
v_str="$v_str NGINX='' NGINX_EXT='' SUSPEND='no' DATE='$V_DATE'" v_str="$v_str NGINX='' NGINX_EXT='' SUSPEND='no' DATE='$V_DATE'"

View file

@ -14,6 +14,7 @@ dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -62,36 +63,46 @@ is_package_full 'web_alias'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining params for change function # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
search_phrase='ServerAlias'
# Defining new alias string # Parsing domain aliases
curr_alias=$(get_web_domain_value '$ALIAS') if [ -z "$ALIAS" ]; then
if [ -z "$curr_alias" ]; then ALIAS="$dom_alias"
new_alias="$dom_alias"
new_alias_idn="$dom_alias_idn"
else else
new_alias="$curr_alias,$dom_alias" ALIAS="$ALIAS,$dom_alias"
new_alias_idn=$(idn -t --quiet -a "$curr_alias,$dom_alias")
fi fi
# Defining replace string # Preparing domain values for the template substitution
str_repl=" ServerAlias ${new_alias_idn//,/ }" upd_web_domain_values
# Adding alias # Recreating vhost
change_web_config del_web_config
add_web_config
# Checking ssl domain if [ ! -z "$SSL_CERT" ]; then
cert=$(get_web_domain_value '$SSL_CERT') tpl_file="$V_WEBTPL/apache_$TPL.stpl"
if [ ! -z "$cert" ]; then
# Defining params for change function
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
change_web_config del_web_config
add_web_config
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
del_web_config
add_web_config
if [ ! -z "$SSL_CERT" ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
add_web_config
fi
fi fi
@ -100,7 +111,7 @@ fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding new alias # Adding new alias
update_web_domain_value '$ALIAS' "$new_alias" update_web_domain_value '$ALIAS' "$ALIAS"
# Adding task to the vesta pipe # Adding task to the vesta pipe
restart_schedule 'web' restart_schedule 'web'

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -49,36 +50,25 @@ is_web_domain_key_empty '$CGI'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" tpl_file="$V_WEBTPL/apache_$TPL.tpl"
# Defining params for ScriptAlias
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
search_phrase='ScriptAlias ' CGI='yes'
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin/"
change_web_config
# Defining params for Options # Preparing domain values for the template substitution
search_phrase='Options ' upd_web_domain_values
str_repl=' Options +Includes -Indexes +ExecCGI'
change_web_config # Recreating vhost
del_web_config
add_web_config
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Defining params for ScriptAlias
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
search_phrase='ScriptAlias ' del_web_config
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin/" add_web_config
change_web_config
# Defining params for Options
search_phrase='Options '
str_repl=' Options +Includes -Indexes +ExecCGI'
change_web_config
fi fi

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -49,35 +50,41 @@ is_web_domain_key_empty '$ELOG'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" tpl_file="$V_WEBTPL/apache_$TPL.tpl"
# Defining config
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
ELOG='yes'
# Defining search phrase # Preparing domain values for the template substitution
search_phrase='ErrorLog ' upd_web_domain_values
# Defining replace string # Recreating vhost
str_repl=" ErrorLog /var/log/httpd/domains/$domain.error.log" del_web_config
add_web_config
# Adding errolog support
change_web_config
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Get ssl template name
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
# Defining ssl config
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
del_web_config
add_web_config
fi
# Adding errolog support # Checking nginx
change_web_config if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
del_web_config
add_web_config
if [ ! -z "$SSL_CERT" ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
add_web_config
fi
fi fi

View file

@ -16,6 +16,7 @@ extentions=${4-$default_extentions}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -57,71 +58,32 @@ is_template_valid "proxy"
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining domain parameters # Defining domain parameters
ip=$(get_web_domain_value '$IP') get_web_domain_values
web_port=$(get_config_value '$WEB_PORT') NGINX="$template"
proxy_port=$(get_config_value '$PROXY_PORT') NGINX_EXT="$extentions"
domain_idn=$(idn -t --quiet -a "$domain") tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
group="$user"
docroot="$V_HOME/$user/web/$domain/public_html"
email="$user@$domain"
aliases=$(get_web_domain_value '$ALIAS')
aliases_idn=$(idn -t --quiet -a "$aliases")
# Checking error log status
elog=$(get_web_domain_value '$ELOG')
if [ "$elog" = 'no' ]; then
elog=' #'
else
elog=' '
fi
# Adding domain to the nginx.conf
tpl_file="$V_WEBTPL/ngingx_vhost_$template.tpl"
conf="$V_HOME/$user/conf/nginx.conf" conf="$V_HOME/$user/conf/nginx.conf"
# Preparing domain values for the template substitution
upd_web_domain_values
add_web_config add_web_config
# Checking vesta nginx config if [ ! -z "$SSL_CERT" ]; then
main_conf='/etc/nginx/conf.d/vesta_users.conf' proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
main_conf_check=$(grep "$conf" $main_conf ) tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
if [ -z "$main_conf_check" ]; then
echo "include $conf;" >>$main_conf
fi
# Checking ssl
cert=$(get_web_domain_value '$SSL_CERT')
if [ ! -z "$cert" ]; then
# Defining certificate params
ssl_cert="$V_HOME/$user/conf/$cert.crt"
ssl_key="$V_HOME/$user/conf/$cert.key"
tpl_option=$(get_web_domain_value '$SSL_HOME')
case $tpl_option in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
same) docroot="$V_HOME/$user/web/$domain/public_html" ;;
*) check_args '3' "$#" 'user domain certificate [sslhome]'
esac
web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
proxy_ssl_port=$(get_config_value '$PROXY_SSL_PORT')
# Adding domain to the snginx.conf
conf="$V_HOME/$user/conf/snginx.conf" conf="$V_HOME/$user/conf/snginx.conf"
tpl_file="$V_WEBTPL/ngingx_vhost_$template.stpl"
add_web_config add_web_config
# Checking vesta nginx config
main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then
echo "include $conf;" >>$main_conf
fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
echo "NGINX=$NGINX"
echo "NGINX_EXT=$NGINX_EXT"
# Adding nginx params to config # Adding nginx params to config
update_web_domain_value '$NGINX' "$template" update_web_domain_value '$NGINX' "$NGINX"
update_web_domain_value '$NGINX_EXT' "$extentions" update_web_domain_value '$NGINX_EXT' "$extentions"
# Adding task to the vesta pipe # Adding task to the vesta pipe

View file

@ -9,11 +9,12 @@
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
cert=$3 ssl=$3
tpl_option=${4-single} ssl_home=${4-single}
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
source $V_FUNC/ip.func source $V_FUNC/ip.func
@ -27,7 +28,7 @@ source $V_FUNC/ip.func
check_args '3' "$#" 'user domain certificate [sslhome]' check_args '3' "$#" 'user domain certificate [sslhome]'
# Checking argument format # Checking argument format
format_validation 'user' 'domain' 'certificate' format_validation 'user' 'domain' 'ssl'
# Checking web system is enabled # Checking web system is enabled
is_system_enabled 'web' is_system_enabled 'web'
@ -47,58 +48,36 @@ is_domain_suspended 'web'
# Checking package # Checking package
is_package_full 'web_ssl' is_package_full 'web_ssl'
# Checking ip ownership
ip=$(get_web_domain_value '$IP')
is_sys_ip_owner
# Check ssl is not added # Check ssl is not added
is_web_domain_key_empty '$SSL_CERT' is_web_domain_key_empty '$SSL_CERT'
# Checking ssl certificate # Checking ssl certificate
is_web_domain_cert_valid is_web_domain_cert_valid
# Checking template
templates=$(get_user_value '$WEB_TPL')
template=$(get_web_domain_value '$TPL')
is_template_valid 'web'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining variables for template replace # Parsing domain values
web_ssl_port=$(get_config_value '$WEB_SSL_PORT') get_web_domain_values
aliases=$(get_web_domain_value '$ALIAS')
aliases_idn=$(idn -t --quiet -a "$aliases")
email="$user@$domain"
ssl_cert="$V_HOME/$user/conf/$cert.crt"
ssl_key="$V_HOME/$user/conf/$cert.key"
case $tpl_option in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
same) docroot="$V_HOME/$user/web/$domain/public_html" ;;
*) check_args '3' "$#" 'user domain certificate [sslhome]'
esac
group="$user"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
tpl_file="$V_WEBTPL/apache_$template.stpl" tpl_file="$V_WEBTPL/apache_$TPL.stpl"
SSL_CERT=$ssl
SSL_HOME=$ssl_home
# Checking error log status # Checking ip ownership
elog=$(get_web_domain_value '$ELOG') is_sys_ip_owner
if [ "$elog" = 'no' ]; then
elog=' #'
else
elog=' '
fi
# Adding domain to the httpd.conf # Preparing domain values for the template substitution
upd_web_domain_values
# Adding domain to the shttpd.conf
add_web_config add_web_config
# Adding certificate to user dir # Adding certificate to user dir
if [ ! -e "$ssl_cert" ]; then cp -f $V_USERS/$user/cert/$SSL_CERT.crt $ssl_cert
cp -f $V_USERS/$user/cert/$cert.crt $ssl_cert cp -f $V_USERS/$user/cert/$SSL_CERT.key $ssl_key
cp -f $V_USERS/$user/cert/$cert.key $ssl_key
fi
# Running template trigger # Running template trigger
if [ -x $V_WEBTPL/apache_$template.sh ]; then if [ -x $V_WEBTPL/apache_$template.sh ]; then
@ -109,7 +88,22 @@ fi
main_conf='/etc/httpd/conf.d/vesta.conf' main_conf='/etc/httpd/conf.d/vesta.conf'
main_conf_check=$(grep "$conf" $main_conf ) main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then if [ -z "$main_conf_check" ]; then
echo "Include $conf" >>$main_conf echo "Include $conf" >> $main_conf
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
# Adding domain to the snginx.conf
conf="$V_HOME/$user/conf/snginx.conf"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
add_web_config
# Checking vesta nginx config
main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then
echo "include $conf;" >>$main_conf
fi
fi fi
@ -121,8 +115,8 @@ fi
increase_user_value "$user" '$U_WEB_SSL' increase_user_value "$user" '$U_WEB_SSL'
# Adding ssl values # Adding ssl values
update_web_domain_value '$SSL_HOME' "$tpl_option" update_web_domain_value '$SSL_CERT' "$SSL_CERT"
update_web_domain_value '$SSL_CERT' "$cert" update_web_domain_value '$SSL_HOME' "$SSL_HOME"
# Logging # Logging
log_history "$V_EVENT" "v_del_web_domain_ssl $user $domain" log_history "$V_EVENT" "v_del_web_domain_ssl $user $domain"

View file

@ -13,6 +13,7 @@ type=$3
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -55,13 +56,18 @@ is_web_domain_key_empty '$STATS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Parse aliases # Parse aliases
aliases=$(get_web_domain_value '$ALIAS') get_web_domain_values
aliases_idn=$(idn -t --quiet -a "$aliases")
# Preparing domain values for the template substitution
upd_web_domain_values
# Adding statistic config # Adding statistic config
cat $V_WEBTPL/$type.tpl |\ cat $V_WEBTPL/$type.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%port%/$port/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
-e "s/%proxy_port%/$PROXY_PORT/g" \
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
-e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \ -e "s/%domain%/$domain/g" \
-e "s/%user%/$user/g" \ -e "s/%user%/$user/g" \

View file

@ -13,6 +13,7 @@ auth_pass=$4
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func

View file

@ -63,7 +63,6 @@ done
# Get current time # Get current time
start_time=$(date '+%s') start_time=$(date '+%s')
sleep 131
# Creating temporary random directory # Creating temporary random directory
tmpdir=$(mktemp -p $V_TMP -d) tmpdir=$(mktemp -p $V_TMP -d)
@ -618,7 +617,10 @@ fi
# Deleting old backup records # Deleting old backup records
for backup_record in $deprecated; do for backup_record in $deprecated; do
sed -i "/DATE='$backup_record/d" $V_USERS/$user/backup.conf if [ -e "$V_USERS/$user/backup.conf" ]; then
echo "sed -i /DATE='$backup_record/d $V_USERS/$user/backup.conf"
sed -i "/DATE='$backup_record/d" $V_USERS/$user/backup.conf
fi
done done
# Concatenating string # Concatenating string

View file

@ -13,6 +13,7 @@ ip=$3
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
source $V_FUNC/ip.func source $V_FUNC/ip.func
@ -51,26 +52,33 @@ is_ip_avalable
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get tpl # Define variable for replace
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
old_ip=$(get_web_domain_value '$IP') old=$IP
new=$ip
# Changing ip replace_web_config
change_domain_ip "$conf" "$domain" "$ip" "$old_ip" "$tpl_file"
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Get tpl
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
replace_web_config
fi
# Adding elog # Checking nginx
change_domain_ip "$conf" "$domain" "$ip" "$old_ip" "$tpl_file" if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
replace_web_config
fi
# Checking nginx
if [ ! -z "$SSL_CERT" ] && [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
replace_web_config
fi fi
@ -79,13 +87,13 @@ fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing ip value # Increasing ip value
increase_ip_value increase_ip_value "$new"
# Decreasing old ip value # Decreasing old ip value
decrease_ip_value "$old_ip" decrease_ip_value "$old"
# Adding ip in config # Adding ip in config
update_web_domain_value '$IP' "$ip" update_web_domain_value '$IP' "$new"
# Adding task to the vesta pipe # Adding task to the vesta pipe
restart_schedule 'web' restart_schedule 'web'

View file

@ -9,10 +9,11 @@
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
certificate=$3 ssl=$3
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -25,7 +26,7 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain certificate' check_args '3' "$#" 'user domain certificate'
# Checking argument format # Checking argument format
format_validation 'user' 'domain' 'certificate' format_validation 'user' 'domain' 'ssl'
# Checking web system is enabled # Checking web system is enabled
is_system_enabled 'web' is_system_enabled 'web'
@ -53,39 +54,38 @@ is_web_domain_cert_valid
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Defininig config
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
old_ssl="$SSL_CERT"
SSL_CERT="$ssl"
# Defining ssl key and certificate # Preparing domain values for the template substitution
ssl_cert="$V_HOME/$user/conf/$certificate.crt" upd_web_domain_values
ssl_key="$V_HOME/$user/conf/$certificate.key"
# Defining search phrase # Recreating vhost
search_phrase='SSLCertificateFile' del_web_config
add_web_config
# Defining replace string # Checking nginx
str_repl=" SSLCertificateFile $ssl_cert" if [ ! -z "$NGINX" ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
add_web_config
fi
# Changing sslhome # Adding new certificate to user dir
change_web_config cp -f $V_USERS/$user/cert/$SSL_CERT.crt $ssl_cert
cp -f $V_USERS/$user/cert/$SSL_CERT.key $ssl_key
# Defining search phrase # Deleting old certificate
search_phrase='SSLCertificateKeyFile' check_cert=$(grep "SSL_CERT='$old_ssl'" $V_USERS/$user/web.conf |wc -l)
if [ "$check_cert" -lt 2 ]; then
# Defining replace string rm -f $V_HOME/$user/conf/$old_ssl.crt
str_repl=" SSLCertificateKeyFile $ssl_key" rm -f $V_HOME/$user/conf/$old_ssl.key
# Changing sslhome
change_web_config
# Adding certificate to user dir
if [ ! -e "$ssl_cert" ]; then
cp -f $V_USERS/$user/cert/$certificate.crt $ssl_cert
cp -f $V_USERS/$user/cert/$certificate.key $ssl_key
fi fi
@ -93,17 +93,14 @@ fi
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get old sslhome value
old_ssl_cert=$(get_web_domain_value '$SSL_CERT')
# Adding sslcert in config # Adding sslcert in config
update_web_domain_value '$SSL_CERT' "$certificate" update_web_domain_value '$SSL_CERT' "$SSL_CERT"
# Adding task to the vesta pipe # Adding task to the vesta pipe
restart_schedule 'web' restart_schedule 'web'
# Logging # Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ssl_cert" log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ssl"
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"
exit exit

View file

@ -9,10 +9,11 @@
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
tpl_option=$3 ssl_home=$3
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -50,47 +51,31 @@ is_web_domain_value_exist '$SSL_CERT'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Get domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" old_ssl_home=$SSL_HOME
SSL_HOME=$ssl_home
# Defininig config tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
# Defining search phrase
search_phrase='DocumentRoot'
# Parsing tpl_option # Parsing tpl_option
case $tpl_option in case $SSL_HOME in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;; single) new="$V_HOME/$user/web/$domain/public_shtml" ;
same) docroot="$V_HOME/$user/web/$domain/public_html" ;; old="$V_HOME/$user/web/$domain/public_html" ;;
*) check_args '3' "2" 'user domain sslhome' same) new="$V_HOME/$user/web/$domain/public_html" ;
old="$V_HOME/$user/web/$domain/public_shtml" ;;
*) check_args '3' "2" 'user domain sslhome'
esac esac
# Defining replace string # Changing sslhome directory
str_repl=" DocumentRoot $docroot" replace_web_config
# Changing sslhome # Checking nginx config
change_web_config if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
# Get old sslhome value conf="$V_HOME/$user/conf/snginx.conf"
ssl_home=$(get_web_domain_value '$SSL_HOME') replace_web_config
fi
# Parsing old sslhome
case $ssl_home in
single) dirroot="$V_HOME/$user/web/$domain/public_shtml" ;;
same) dirroot="$V_HOME/$user/web/$domain/public_html" ;;
*) check_args '3' "2" 'user domain sslhome'
esac
# Defining search phrase
search_phrase="<Directory $dirroot>"
# Defining replace string
str_repl=" <Directory $docroot>"
# Changing sslhome directory tag
change_web_config
#----------------------------------------------------------# #----------------------------------------------------------#
@ -98,13 +83,13 @@ change_web_config
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding sslhome in config # Adding sslhome in config
update_web_domain_value '$SSL_HOME' "$tpl_option" update_web_domain_value '$SSL_HOME' "$SSL_HOME"
# Adding task to the vesta pipe # Adding task to the vesta pipe
restart_schedule 'web' restart_schedule 'web'
# Logging # Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $ssl_home" log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ssl_home"
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"
exit exit

View file

@ -13,6 +13,7 @@ template=$3
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -51,57 +52,82 @@ is_template_valid "web"
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
conf="$V_HOME/$user/conf/httpd.conf"
# Deleting domain # Deleting domain
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
old_tpl=$TPL
conf="$V_HOME/$user/conf/httpd.conf"
del_web_config del_web_config
# Checking ssl # Deleting ssl vhost
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Get tpl
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
# Deleting domain
del_web_config del_web_config
fi fi
# Defining variables for template replace # Defining variables for new vhost config
ip=$(get_web_domain_value '$IP') ip=$IP
aliases=$(get_web_domain_value '$ALIAS')
i=1
for dom_alias in ${aliases//,/ }; do
dom_alias=$(idn -t --quiet -a $dom_alias)
if [ "$i" -eq 1 ]; then
aliases_idn="$dom_alias"
else
aliases_idn="$aliases_idn,$dom_alias"
fi
i=$((i + 1))
done
web_port=$(get_config_value '$WEB_PORT')
email="$user@$domain" email="$user@$domain"
group="$user"
docroot="$V_HOME/$user/web/$domain/public_html" docroot="$V_HOME/$user/web/$domain/public_html"
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
tpl_file="$V_WEBTPL/apache_$template.tpl" tpl_file="$V_WEBTPL/apache_$template.tpl"
group="$user"
# Parsing template keys
template_data=$(cat $V_WEBTPL/apache_$template.descr|grep -v '#') # 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 $V_WEBTPL/apache_$template.descr | grep -v '#')
for keys in $template_data; do for keys in $template_data; do
eval ${keys%%=*}=${keys#*=} eval ${keys%%=*}=${keys#*=}
done done
# Checking error log status # Checking error log
if [ "$ELOG" = 'no' ]; then if [ "$ELOG" = 'no' ]; then
elog=' #' elog='#'
else else
elog=' ' elog=''
fi fi
# Adding domain to the httpd.conf # Adding domain to the httpd.conf
@ -113,15 +139,13 @@ if [ -x $V_WEBTPL/apache_$template.sh ]; then
fi fi
# Checking ssl # Checking ssl
if [ ! -z "$cert" ]; then if [ ! -z "$SSL_CERT" ]; then
# Defining variables for ssl template replace # Defining variables for ssl template replace
web_ssl_port=$(get_config_value '$WEB_SSL_PORT') ssl_cert="$V_HOME/$user/conf/$SSL_CERT.crt"
tpl_option=$(get_web_domain_value '$SSL_HOME') ssl_key="$V_HOME/$user/conf/$SSL_CERT.key"
ssl_cert="$V_HOME/$user/conf/$cert.crt" case $SSL_HOME in
ssl_key="$V_HOME/$user/conf/$cert.key"
case $tpl_option in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;; single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
*) docroot="$V_HOME/$user/web/$domain/public_html" ;; same) docroot="$V_HOME/$user/web/$domain/public_html" ;;
esac esac
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
tpl_file="$V_WEBTPL/apache_$template.stpl" tpl_file="$V_WEBTPL/apache_$template.stpl"
@ -155,6 +179,7 @@ done
restart_schedule 'web' restart_schedule 'web'
# Logging # Logging
log_history "$V_EVENT" "v_change_web_domain_tpl $user $domain $old_tpl"
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"
exit exit

View file

@ -7,7 +7,7 @@
# Argument defenition # Argument defenition
user=$1 user=$1
cert=$2 ssl=$2
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
@ -31,9 +31,6 @@ is_user_valid
# Checking user is active # Checking user is active
is_user_suspended is_user_suspended
# Checking ssl ceritificate
is_cert_valid "$V_USERS/$user/cert"
# Checking certificate # Checking certificate
is_cert_used is_cert_used
@ -43,7 +40,7 @@ is_cert_used
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting certificate # Deleting certificate
rm -f $V_USERS/$user/cert/$cert.* rm -f $V_USERS/$user/cert/$ssl.*
#----------------------------------------------------------# #----------------------------------------------------------#

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
source $V_FUNC/ip.func source $V_FUNC/ip.func
@ -48,31 +49,46 @@ is_domain_suspended 'web'
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Get template name
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
old_ip=$(get_web_domain_value '$IP') tpl_file="$V_WEBTPL/apache_$TPL.tpl"
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
# Deleting domain # Deleting domain
del_web_config del_web_config
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Get tpl
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
# Deleting domain
del_web_config del_web_config
# Deleting old certificate
check_cert=$(grep "SSL_CERT='$SSL_CERT'" $V_USERS/$user/web.conf |wc -l)
if [ "$check_cert" -lt 2 ]; then
rm -f $V_HOME/$user/conf/$SSL_CERT.crt
rm -f $V_HOME/$user/conf/$SSL_CERT.key
fi
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
del_web_config
if [ ! -z "$SSL_CERT" ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
fi
fi fi
# Checking stats # Checking stats
stats_type=$(get_web_domain_value '$STATS') if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then
if [ ! -z "$stats_type" ] && [ "$stats_type" != 'no' ]; then
# Parsing pipe line # Parsing pipe line
line=$(grep -n "$type.$domain.conf" $V_QUEUE/stats.pipe | \ line=$(grep -n "$STATS.$domain.conf" $V_QUEUE/stats.pipe | \
cut -f 1 -d : | head -n 1 ) cut -f 1 -d : | head -n 1 )
# Deleting pipe command # Deleting pipe command
@ -81,7 +97,7 @@ if [ ! -z "$stats_type" ] && [ "$stats_type" != 'no' ]; then
fi fi
# Deleteing config # Deleteing config
rm -f $V_HOME/$user/conf/$type.$domain.conf rm -f $V_HOME/$user/conf/$STATS.$domain.conf
fi fi
# Deleting directory # Deleting directory
@ -137,7 +153,7 @@ if [ -z "$last_nginx" ]; then
fi fi
# Decreasing ip value # Decreasing ip value
decrease_ip_value "$old_ip" decrease_ip_value "$IP"
# Decreasing domain value # Decreasing domain value
decrease_user_value "$user" '$U_WEB_DOMAINS' decrease_user_value "$user" '$U_WEB_DOMAINS'

View file

@ -14,6 +14,7 @@ dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -44,8 +45,8 @@ is_web_domain_valid
is_domain_suspended 'web' is_domain_suspended 'web'
# Checking alias is added # Checking alias is added
cur_alias=$(get_web_domain_value '$ALIAS') get_web_domain_values
check_alias=$(echo ${cur_alias//,/ }|grep -w "$dom_alias") check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias")
if [ -z "$check_alias" ]; then if [ -z "$check_alias" ]; then
echo "Error: alias not exist" echo "Error: alias not exist"
log_event 'debug' "$E_DOM_NOTEXIST $V_EVENT" log_event 'debug' "$E_DOM_NOTEXIST $V_EVENT"
@ -57,35 +58,42 @@ fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining new alias string # Defining new alias string
new_alias=$(echo "$cur_alias" |\ ALIAS=$(echo "$ALIAS" |\
sed -e "s/,/\n/g"|\ sed -e "s/,/\n/g"|\
sed -e "s/^$dom_alias$//g"|\ sed -e "s/^$dom_alias$//g"|\
sed -e "/^$/d"|\ sed -e "/^$/d"|\
sed -e ':a;N;$!ba;s/\n/,/g') sed -e ':a;N;$!ba;s/\n/,/g')
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
new_alias_idn=$(idn -t --quiet -a "$cur_alias" |\
sed -e "s/,/\n/g"|\
sed -e "s/^$dom_alias$//g"|\
sed -e "/^$/d"|\
sed -e ':a;N;$!ba;s/\n/,/g')
tpl_name=$(get_web_domain_value '$TPL')
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
search_phrase='ServerAlias'
str_repl=" ServerAlias ${new_alias_idn//,/ }"
# Deleting alias # Preparing domain values for the template substitution
change_web_config upd_web_domain_values
# Checking ssl # Recreating vhost
cert=$(get_web_domain_value '$SSL_CERT') del_web_config
if [ ! -z "$cert" ]; then add_web_config
# Defining ssl options if [ ! -z "$SSL_CERT" ]; then
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
change_web_config del_web_config
add_web_config
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
del_web_config
add_web_config
if [ ! -z "$SSL_CERT" ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
add_web_config
fi
fi fi
@ -94,7 +102,7 @@ fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting alias # Deleting alias
update_web_domain_value '$ALIAS' "$new_alias" update_web_domain_value '$ALIAS' "$ALIAS"
# Adding task to the vesta pipe # Adding task to the vesta pipe
restart_schedule 'web' restart_schedule 'web'

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -49,36 +50,24 @@ is_web_domain_value_exist '$CGI'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name get_web_domain_values
tpl_name=$(get_web_domain_value '$TPL') tpl_file="$V_WEBTPL/apache_$TPL.tpl"
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
# Defining params for ScriptAlias
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
search_phrase='ScriptAlias ' CGI='no'
str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin"
change_web_config
# Defining params for Options # Preparing domain values for the template substitution
search_phrase='Options ' upd_web_domain_values
str_repl=' Options +Includes -Indexes -ExecCGI'
change_web_config # Recreating vhost
del_web_config
add_web_config
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Defining params for ScriptAlias
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
search_phrase='ScriptAlias ' del_web_config
str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin" add_web_config
change_web_config
# Defining params for Options
search_phrase='Options '
str_repl=' Options +Includes -Indexes -ExecCGI'
change_web_config
fi fi

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -49,35 +50,41 @@ is_web_domain_value_exist '$ELOG'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" tpl_file="$V_WEBTPL/apache_$TPL.tpl"
# Defining config
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
ELOG='no'
# Defining search phrase # Preparing domain values for the template substitution
search_phrase='ErrorLog ' upd_web_domain_values
# Defining replace string # Recreating vhost
str_repl=" #ErrorLog /var/log/httpd/domains/$domain.error.log" del_web_config
add_web_config
# Deleting errolog support
change_web_config
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Get ssl template name
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
# Defining ssl config
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
del_web_config
add_web_config
fi
# Deleting errolog support # Checking nginx
change_web_config if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
del_web_config
add_web_config
if [ ! -z "$SSL_CERT" ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
add_web_config
fi
fi fi

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# info: deliting web domain nginx config # info: deleting web domain nginx config
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -49,19 +50,15 @@ is_web_domain_value_exist '$NGINX'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get domain values # Defining domain parameters
tpl_name=$(get_web_domain_value '$NGINX') get_web_domain_values
tpl_file="$V_WEBTPL/ngingx_vhost_$tpl_name.tpl" tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf" conf="$V_HOME/$user/conf/nginx.conf"
ext=$(get_web_domain_value '$NGINX_EXT' )
# Deleting domain
del_web_config del_web_config
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
tpl_file="$V_WEBTPL/ngingx_vhost_$tpl_name.stpl"
conf="$V_HOME/$user/conf/snginx.conf" conf="$V_HOME/$user/conf/snginx.conf"
del_web_config del_web_config
fi fi
@ -99,7 +96,7 @@ fi
restart_schedule 'web' restart_schedule 'web'
# Logging # Logging
log_history "$V_EVENT" "v_add_web_domain_nginx $user $domain $tpl_name $ext" log_history "$V_EVENT" "v_add_web_domain_nginx $user $domain $NGINX $NGINX_EXT"
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"
exit exit

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -49,23 +50,34 @@ is_web_domain_value_exist '$SSL_CERT'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
old_ssl="$SSL_CERT"
# Deleting domain # Deleting domain
del_web_config del_web_config
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
fi
# Deleting old certificate
check_cert=$(grep "SSL_CERT='$old_ssl'" $V_USERS/$user/web.conf |wc -l)
if [ "$check_cert" -lt 2 ]; then
rm -f $V_HOME/$user/conf/$old_ssl.crt
rm -f $V_HOME/$user/conf/$old_ssl.key
fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get old values
cert=$(get_web_domain_value '$SSL_CERT' )
tpl_option=$(get_web_domain_value '$SSL_HOME' )
# Deleting ssl in config # Deleting ssl in config
update_web_domain_value '$SSL_HOME' '' update_web_domain_value '$SSL_HOME' ''
update_web_domain_value '$SSL_CERT' '' update_web_domain_value '$SSL_CERT' ''
@ -79,23 +91,26 @@ if [ -z "$ssl_dom" ]; then
rm -f $conf rm -f $conf
fi fi
# Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf)
last_snginx=$(echo "$last_nginx" | grep -v "SSL_CERT=''")
if [ -z "$last_snginx" ]; then
sline=$(grep -n "$V_HOME/$user/conf/snginx.conf" $conf | cut -f 1 -d : )
if [ ! -z "$sline" ]; then
sed -i "$sline d" $conf
fi
rm -f $V_HOME/$user/conf/snginx.conf
fi
# Decreasing domain value # Decreasing domain value
decrease_user_value "$user" '$U_WEB_SSL' decrease_user_value "$user" '$U_WEB_SSL'
# Checking cert parents
conf="$V_USERS/$user/web.conf"
field='$DOMAIN'
search_string="SSL_CERT='$cert'"
cert_parents=$(dom_clear_search)
if [ -z "$cert_parents" ]; then
rm -f $V_HOME/$user/conf/$cert.crt $V_HOME/$user/conf/$cert.key
fi
# Adding task to the vesta pipe # Adding task to the vesta pipe
restart_schedule 'web' restart_schedule 'web'
# Logging # Logging
log_history "$V_EVENT" "v_add_web_domain_ssl $user $domain $cert $tpl_option" log_history "$V_EVENT" "v_add_web_domain_ssl $user $domain $SSL_CERT $SSL_HOME"
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"
exit exit

View file

@ -11,6 +11,7 @@ domain=$(idn -t --quiet -u "$2" )
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -65,14 +66,8 @@ rm -f $V_HOME/$user/conf/$type.$domain.conf
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing pipe line
line=$(grep -n "$type.$domain.conf" $V_QUEUE/stats.pipe | \
cut -f 1 -d : | head -n 1 )
# Deleting pipe command # Deleting pipe command
if [ ! -z "$line" ]; then sed -i "/ $domain$/d" $V_QUEUE/stats.pipe
sed -i "$line d" $V_QUEUE/stats.pipe
fi
# Deleting stats # Deleting stats
update_web_domain_value '$STATS' '' update_web_domain_value '$STATS' ''

View file

@ -12,6 +12,7 @@ auth_user=$3
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -54,10 +55,7 @@ stat_dir="$V_HOME/$user/web/$domain/stats"
# Checking auth_user # Checking auth_user
if [ ! -z "$auth_user" ]; then if [ ! -z "$auth_user" ]; then
# Checking argument format
format_validation 'auth_user' format_validation 'auth_user'
htpasswd -D $stat_dir/.htpasswd "$auth_user" >/dev/null 2>&1 htpasswd -D $stat_dir/.htpasswd "$auth_user" >/dev/null 2>&1
fi fi

View file

@ -10,6 +10,7 @@ user=$1
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func

View file

@ -13,6 +13,7 @@ key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -44,10 +45,7 @@ is_domain_suspended 'web'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Checking key
value=$(get_web_domain_value "$key") value=$(get_web_domain_value "$key")
# Printing value
echo "$value" echo "$value"
@ -55,7 +53,4 @@ echo "$value"
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit exit

View file

@ -10,6 +10,7 @@ user=$1
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
source $V_FUNC/ip.func source $V_FUNC/ip.func
@ -40,175 +41,68 @@ is_user_suspended
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining port configuration # Clean up old config
proxy_port=$(get_config_value '$PROXY_PORT') rm -f $V_HOME/$user/conf/tmp_*.conf
proxy_ssl_port=$(get_config_value '$PROXY_SSL_PORT')
web_port=$(get_config_value '$WEB_PORT')
web_ssl_port=$(get_config_value '$WEB_SSL_PORT')
# Defining config # Defining config
conf="$V_USERS/$user/web.conf" conf=$V_USERS/$user/web.conf
fields='$DOMAIN'
# Defining search string nohead=1
search_string="DOMAIN"
# Defining fileds to select
field='$DOMAIN'
# Parsing all domains
domains=$(dom_clear_search)
# Starting loop # Starting loop
for domain in $domains; do for domain in $(shell_list) ; do
# Defining domain parameters
template=$(get_web_domain_value '$TPL')
tpl_file="$V_WEBTPL/apache_$template.tpl"
ip=$(get_web_domain_value '$IP')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
group="$user"
docroot="$V_HOME/$user/web/$domain/public_html"
email="$user@$domain"
aliases=$(get_web_domain_value '$ALIAS')
i=1
for dom_alias in ${aliases//,/ }; do
dom_alias=$(idn -t --quiet -a $dom_alias)
if [ "$i" -eq 1 ]; then
aliases_idn="$dom_alias"
else
aliases_idn="$aliases_idn,$dom_alias"
fi
i=$((i + 1))
done
suspend=$(get_web_domain_value '$SUSPEND')
# Checking error log status # Parsing domain values
elog=$(get_web_domain_value '$ELOG') get_web_domain_values
if [ "$elog" = 'no' ]; then
elog=' #' # Preparing domain values for the template substitution
else upd_web_domain_values
elog=' '
fi
# Adding domain to the tmp_httpd.conf # Adding domain to the tmp_httpd.conf
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/tmp_httpd.conf" conf="$V_HOME/$user/conf/tmp_httpd.conf"
add_web_config add_web_config
# Running template trigger # Running template trigger
if [ -x $V_WEBTPL/apache_$template.sh ]; then if [ -x $V_WEBTPL/apache_$TPL.sh ]; then
$V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot $V_WEBTPL/apache_$TPL.sh $user $domain $ip $V_HOME $docroot
fi
# Checking cgi
cgi=$(get_web_domain_value '$CGI')
if [ "$cgi" != 'yes' ]; then
# Defining params for ScriptAlias
search_phrase='ScriptAlias '
str_repl=" #ScriptAlias /cgi-bin/"
str_repl="$str_repl $V_HOME/$user/web/$domain/cgi-bin/"
change_web_config
# Defining params for Options
search_phrase='Options '
str_repl=' Options +Includes -Indexes -ExecCGI'
change_web_config
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
# Checking ssl # Checking ssl
cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$SSL_CERT" ]; then
if [ ! -z "$cert" ]; then
# Defining certificate params
ssl_cert="$V_HOME/$user/conf/$cert.crt"
ssl_key="$V_HOME/$user/conf/$cert.key"
tpl_option=$(get_web_domain_value '$SSL_HOME')
case $tpl_option in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
same) docroot="$V_HOME/$user/web/$domain/public_html" ;;
*) check_args '3' "$#" 'user domain certificate [sslhome]'
esac
# Adding domain to the shttpd.conf # Adding domain to the shttpd.conf
conf="$V_HOME/$user/conf/tmp_shttpd.conf" conf="$V_HOME/$user/conf/tmp_shttpd.conf"
tpl_file="$V_WEBTPL/apache_$template.stpl" tpl_file="$V_WEBTPL/apache_$TPL.stpl"
add_web_config add_web_config
# Running template trigger # Running template trigger
if [ -x $V_WEBTPL/apache_$template.sh ]; then if [ -x $V_WEBTPL/apache_$TPL.sh ]; then
$V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot $V_WEBTPL/apache_$TPL.sh $user $domain $ip $V_HOME $docroot
fi fi
# Checking cgi ssl_change='yes'
if [ "$cgi" != 'yes' ]; then
# Defining params for ScriptAlias
search_phrase='ScriptAlias '
str_repl=" #ScriptAlias /cgi-bin/"
str_repl="$str_repl $V_HOME/$user/web/$domain/cgi-bin/"
change_web_config
# Defining params for Options
search_phrase='Options '
str_repl=' Options +Includes -Indexes -ExecCGI'
change_web_config
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') if [ ! -z "$NGINX" ]; then
if [ ! -z "$nginx" ]; then tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
proxy_port=$(get_config_value '$PROXY_PORT')
extentions=$(get_web_domain_value '$NGINX_EXT')
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 if [ ! -z "$SSL_CERT" ]; then
search_phrase='proxy_pass' if [ "$SUSPEND" = 'yes' ]; then
str_repl=" rewrite ^(.*)\$ http://$url;" proxy_string="rewrite ^(.*)\$ http://$url;"
change_web_config else
fi proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
fi
if [ ! -z "$cert" ]; then
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' ngix_change='yes'
fi fi
done done
# Renaming tmp config # Renaming tmp config
@ -226,7 +120,7 @@ if [ ! -z "$domains" ] && [ -z "$main_conf_check" ]; then
fi fi
# Checking ssl # Checking ssl
if [ ! -z "$ssl_cert" ]; then if [ "$ssl_change" = 'yes' ]; then
tmp_conf="$V_HOME/$user/conf/tmp_shttpd.conf" tmp_conf="$V_HOME/$user/conf/tmp_shttpd.conf"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
mv $tmp_conf $conf mv $tmp_conf $conf
@ -252,7 +146,7 @@ if [ "$ngix_change" = 'yes' ]; then
fi fi
# Checking ssl for nginx # Checking ssl for nginx
if [ ! -z "$ssl_cert" ]; then if [ "$ssl_change" = 'yes' ]; then
tmp_conf="$V_HOME/$user/conf/tmp_snginx.conf" tmp_conf="$V_HOME/$user/conf/tmp_snginx.conf"
conf="$V_HOME/$user/conf/snginx.conf" conf="$V_HOME/$user/conf/snginx.conf"
mv $tmp_conf $conf mv $tmp_conf $conf

View file

@ -4,6 +4,7 @@
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
# Restart functions # Restart functions
apache() { apache() {
@ -22,16 +23,12 @@ nginx() {
fi fi
} }
# Parsing config # Checking system
web_system=$(grep 'WEB_SYSTEM=' $V_CONF/vesta.conf | cut -f 2 -d \' ) if [ "$WEB_SYSTEM" = 'apache' ]; then
proxy_system=$(grep 'PROXY_SYSTEM=' $V_CONF/vesta.conf | cut -f 2 -d \' )
# Checking values
if [ "$web_system" = 'apache' ]; then
apache apache
fi fi
if [ "$proxy_system" = 'nginx' ]; then if [ "$PROXY_SYSTEM" = 'nginx' ]; then
nginx nginx
fi fi

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -46,47 +47,41 @@ is_domain_suspended 'web'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" tpl_file="$V_WEBTPL/apache_$TPL.tpl"
# Defining config
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
SUSPEND='yes'
# Defining search phrase # Preparing domain values for the template substitution
search_phrase='DocumentRoot ' upd_web_domain_values
# Defining replace string # Recreating vhost
str_repl=" Redirect / http://$url" del_web_config
add_web_config
# Suspending vhost # Check ssl
change_web_config if [ ! -z "$SSL_CERT" ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Check ssl vhost
cert=$(get_web_domain_value '$SSL_CERT')
if [ ! -z "$cert" ]; then
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
str_repl=" Redirect / http://$url" del_web_config
change_web_config add_web_config
fi fi
# Check nginx vhost # Checking nginx
nginx=$(get_web_domain_value '$NGINX') if [ ! -z "$NGINX" ]; then
if [ ! -z "$nginx" ]; then tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
conf="$V_HOME/$user/conf/nginx.conf" conf="$V_HOME/$user/conf/nginx.conf"
search_phrase='proxy_pass' del_web_config
str_repl=" rewrite ^(.*)\$ http://$url;" add_web_config
change_web_config
fi
if [ ! -z "$nginx" ] && [ ! -z "$cert" ]; then if [ ! -z "$SSL_CERT" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl" proxy_string="rewrite ^(.*)\$ http://$url;"
conf="$V_HOME/$user/conf/snginx.conf" tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
search_phrase='proxy_pass' conf="$V_HOME/$user/conf/snginx.conf"
str_repl=" rewrite ^(.*)\$ http://$url;" del_web_config
change_web_config add_web_config
fi
fi fi

View file

@ -10,6 +10,7 @@ user=$1
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -43,71 +44,12 @@ conf="$V_USERS/$user/web.conf"
# Defining fileds to select # Defining fileds to select
field='$DOMAIN' field='$DOMAIN'
# Defining search string
search_string="SUSPEND='no'" search_string="SUSPEND='no'"
# Parsing unsuspeneded domains
domains=$(dom_clear_search) domains=$(dom_clear_search)
# Starting suspend loop # Starting suspend loop
for domain in $domains; do for domain in $domains; do
$V_BIN/v_suspend_web_domain "$user" "$domain" "$url"
domain_idn=$(idn -t --quiet -a "$domain")
# Get template name
tpl_name=$(get_web_domain_value '$TPL')
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
# Defining config
conf="$V_HOME/$user/conf/httpd.conf"
# Defining search phrase
search_phrase='DocumentRoot '
# Defining replace string
str_repl=" Redirect / http://$url/"
# Suspending vhost
change_web_config
# Check ssl vhost
cert=$(get_web_domain_value '$SSL_CERT')
if [ ! -z "$cert" ]; then
# Defining teplate name
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
# Defining config
conf="$V_HOME/$user/conf/shttpd.conf"
# Reefining replace string - old str_repl contains escaped chars
str_repl=" Redirect / http://$url/"
# Suspending vhost
change_web_config
fi
# Check nginx vhost
nginx=$(get_web_domain_value '$NGINX')
if [ ! -z "$nginx" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
search_phrase='proxy_pass'
str_repl=" rewrite ^(.*)\$ http://$url;"
change_web_config
fi
if [ ! -z "$nginx" ] && [ ! -z "$cert" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
search_phrase='proxy_pass'
str_repl=" rewrite ^(.*)\$ http://$url;"
change_web_config
fi
# Adding suspend in config
update_web_domain_value '$SUSPEND' 'yes'
done done
@ -115,9 +57,6 @@ done
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'web'
# Logging # Logging
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -43,64 +44,43 @@ is_domain_unsuspended 'web'
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Parsing domain values
tpl_name=$(get_web_domain_value '$TPL') get_web_domain_values
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" tpl_file="$V_WEBTPL/apache_$TPL.tpl"
# Defining config
conf="$V_HOME/$user/conf/httpd.conf" conf="$V_HOME/$user/conf/httpd.conf"
SUSPEND='no'
# Defining search phrase # Preparing domain values for the template substitution
search_phrase='Redirect / ' upd_web_domain_values
# Defining replace string # Recreating vhost
str_repl=" DocumentRoot $V_HOME/$user/web/$domain/public_html" del_web_config
add_web_config
# Unsuspending vhost # Check ssl
change_web_config if [ ! -z "$SSL_CERT" ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
# Check ssl vhost
cert=$(get_web_domain_value '$SSL_CERT')
if [ ! -z "$cert" ]; then
# Defining teplate name and ssl documentroot option
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
tpl_option=$(get_web_domain_value '$SSL_HOME')
# Defining config
conf="$V_HOME/$user/conf/shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf"
del_web_config
# Switching on option add_web_config
case $tpl_option in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
*) docroot="$V_HOME/$user/web/$domain/public_html" ;;
esac
# Defining replace string
str_repl=" DocumentRoot $docroot"
# Unsuspending vhost
change_web_config
fi fi
# Check nginx vhost # Checking nginx
nginx=$(get_web_domain_value '$NGINX') if [ ! -z "$NGINX" ]; then
if [ ! -z "$nginx" ]; then tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
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" conf="$V_HOME/$user/conf/nginx.conf"
search_phrase='rewrite ^(.*)$' del_web_config
str_repl=" proxy_pass http://$ip:$web_port;" add_web_config
change_web_config
if [ ! -z "$SSL_CERT" ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
del_web_config
add_web_config
fi
fi 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
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #

View file

@ -10,6 +10,7 @@ user=$1
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -35,84 +36,15 @@ is_user_valid
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web.conf"
# Defining fileds to select # Defining fileds to select
conf="$V_USERS/$user/web.conf"
field='$DOMAIN' field='$DOMAIN'
# Defining search string
search_string="SUSPEND='yes'" search_string="SUSPEND='yes'"
# Parsing suspeneded domains
domains=$(dom_clear_search) domains=$(dom_clear_search)
# Starting unsuspend loop # Starting unsuspend loop
for domain in $domains; do for domain in $domains; do
$V_BIN/v_unsuspend_web_domain "$user" "$domain"
domain_idn=$(idn -t --quiet -a "$domain")
# Get template name
tpl_name=$(get_web_domain_value '$TPL')
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
# Defining config
conf="$V_HOME/$user/conf/httpd.conf"
# Defining search phrase
search_phrase='Redirect / '
# Defining replace string
str_repl=" DocumentRoot $V_HOME/$user/web/$domain/public_html"
# Unsuspending vhost
change_web_config
# Check ssl vhost
cert=$(get_web_domain_value '$SSL_CERT')
if [ ! -z "$cert" ]; then
# Defining teplate name and ssl documentroot option
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
tpl_opt=$(get_web_domain_value '$SSL_HOME')
# Defining config
conf="$V_HOME/$user/conf/shttpd.conf"
# Switching on option
case $tpl_opt in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
*) docroot="$V_HOME/$user/web/$domain/public_html" ;;
esac
# Defining replace string
str_repl=" DocumentRoot $docroot"
# Unsuspending vhost
change_web_config
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
update_web_domain_value '$SUSPEND' 'no'
done done
@ -120,9 +52,6 @@ done
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'web'
# Logging # Logging
log_event 'system' "$V_EVENT" log_event 'system' "$V_EVENT"

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func

View file

@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func

View file

@ -10,6 +10,7 @@ user=$1
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -40,11 +41,7 @@ conf="$V_USERS/$user/web.conf"
# Defining fileds to select # Defining fileds to select
field='$DOMAIN' field='$DOMAIN'
# Defining search string
search_string="SUSPEND='no'" search_string="SUSPEND='no'"
# Parsing unsuspeneded domains
domains=$(dom_clear_search) domains=$(dom_clear_search)
# Starting update disk loop # Starting update disk loop

View file

@ -10,6 +10,7 @@ user=$1
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func
@ -35,13 +36,9 @@ is_user_valid
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web.conf"
# Defining fileds to select # Defining fileds to select
field='$DOMAIN' field='$DOMAIN'
conf="$V_USERS/$user/web.conf"
# Defining search string
search_string="SUSPEND='no'" search_string="SUSPEND='no'"
# Parsing domain list # Parsing domain list
@ -60,6 +57,7 @@ for domain in $domains; do
fi fi
done done
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#

View file

@ -10,6 +10,7 @@ user=$1
# Importing variables # Importing variables
source $VESTA/conf/vars.conf source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func source $V_FUNC/shared.func
source $V_FUNC/domain.func source $V_FUNC/domain.func

View file

@ -14,14 +14,14 @@ is_cert_valid() {
path="$1" path="$1"
# Checking file existance # Checking file existance
if [ ! -e "$path/$cert.crt" ] || [ ! -e "$path/$cert.key" ]; then if [ ! -e "$path/$ssl.crt" ] || [ ! -e "$path/$ssl.key" ]; then
echo "Error: certificate not exist" echo "Error: certificate not exist"
log_event 'debug' "$E_CERT_NOTEXIST $V_EVENT" log_event 'debug' "$E_CERT_NOTEXIST $V_EVENT"
exit $E_CERT_NOTEXIST exit $E_CERT_NOTEXIST
fi fi
# Checking crt file # Checking crt file
crt=$(openssl verify "$path/$cert.crt" 2>/dev/null|tail -n 1|grep -w 'OK') crt=$(openssl verify "$path/$ssl.crt" 2>/dev/null|tail -n 1|grep -w 'OK')
if [ -z "$crt" ]; then if [ -z "$crt" ]; then
echo "Error: certificate invalid" echo "Error: certificate invalid"
log_event 'debug' "$E_CERT_INVALID $V_EVENT" log_event 'debug' "$E_CERT_INVALID $V_EVENT"
@ -29,7 +29,7 @@ is_cert_valid() {
fi fi
# Checking key file # Checking key file
key=$(openssl rsa -in "$path/$cert.key" -check 2>/dev/null|\ key=$(openssl rsa -in "$path/$ssl.key" -check 2>/dev/null|\
head -n1|grep -w 'ok') head -n1|grep -w 'ok')
if [ -z "$key" ]; then if [ -z "$key" ]; then
echo "Error: key invalid" echo "Error: key invalid"
@ -39,7 +39,7 @@ is_cert_valid() {
# FIXME we should run server on free port # FIXME we should run server on free port
# Checking server # Checking server
cmd="openssl s_server -quiet -cert $path/$cert.crt -key $path/$cert.key" cmd="openssl s_server -quiet -cert $path/$ssl.crt -key $path/$ssl.key"
$cmd & $cmd &
# Defining pid # Defining pid
@ -65,7 +65,7 @@ is_cert_valid() {
is_cert_used() { is_cert_used() {
# Parsing config # Parsing config
check_cert=$(grep "SSL_CERT='$cert'" $V_USERS/$user/web.conf) check_cert=$(grep "SSL_CERT='$ssl'" $V_USERS/$user/web.conf)
# Checking result # Checking result
if [ ! -z "$check_cert" ]; then if [ ! -z "$check_cert" ]; then

View file

@ -223,23 +223,28 @@ add_web_config() {
# Adding template to config # Adding template to config
cat $tpl_file | \ cat $tpl_file | \
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$web_port/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$web_ssl_port/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
-e "s/%proxy_port%/$proxy_port/g" \ -e "s/%proxy_string%/${proxy_string////\/}/g" \
-e "s/%proxy_ssl_port%/$proxy_ssl_port/g" \ -e "s/%proxy_port%/$PROXY_PORT/g" \
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
-e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \ -e "s/%domain%/$domain/g" \
-e "s/%user%/$user/g" \ -e "s/%user%/$user/g" \
-e "s/%group%/$group/g" \ -e "s/%group%/$group/g" \
-e "s/%home%/${V_HOME////\/}/g" \ -e "s/%home%/${V_HOME////\/}/g" \
-e "s/%docroot%/${docroot////\/}/g" \ -e "s/%docroot%/${docroot////\/}/g" \
-e "s/%docroot_string%/${docroot_string////\/}/g" \
-e "s/%email%/$email/g" \ -e "s/%email%/$email/g" \
-e "s/%alias_string%/$alias_string/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
-e "s/%alias%/${aliases//,/ }/g" \ -e "s/%alias%/${aliases//,/ }/g" \
-e "s/%ssl_cert%/${ssl_cert////\/}/g" \ -e "s/%ssl_cert%/${ssl_cert////\/}/g" \
-e "s/%ssl_key%/${ssl_key////\/}/g" \ -e "s/%ssl_key%/${ssl_key////\/}/g" \
-e "s/%extentions%/${extentions//,/|}/g" \ -e "s/%nginx_extentions%/${NGINX_EXT//,/|}/g" \
-e "s/%elog%/$elog/g" \ -e "s/%elog%/$elog/g" \
-e "s/%cgi%/$cgi/g" \
-e "s/%cgi_option%/$cgi_option/g" \
>> $conf >> $conf
} }
@ -260,6 +265,13 @@ get_web_config_brds() {
str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :) str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
top_line=$((str - serv_line + 1)) top_line=$((str - serv_line + 1))
bottom_line=$((top_line + last_line -1)) bottom_line=$((top_line + last_line -1))
# Check for multialias (8k alias issue)
multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
if [ "$multi" -ge 2 ]; then
bottom_line=$((bottom_line + multi -1))
fi
} }
change_web_config() { change_web_config() {
@ -286,6 +298,25 @@ change_web_config() {
fi fi
} }
replace_web_config() {
# Get config borders
get_web_config_brds || exit $?
# Escaping chars
clean_new=$(echo "$new" | sed \
-e 's/\\/\\\\/g' \
-e 's/&/\\&/g' \
-e 's/\//\\\//g')
clean_old=$(echo "$old" | sed \
-e 's/\\/\\\\/g' \
-e 's/&/\\&/g' \
-e 's/\//\\\//g')
# Replacing string in config
sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
}
get_web_domain_value() { get_web_domain_value() {
key="$1" key="$1"
@ -304,6 +335,16 @@ get_web_domain_value() {
echo "$value" echo "$value"
} }
get_web_domain_values() {
# Defining domain parameters
for line in $(grep "DOMAIN='$domain'" $V_USERS/$user/web.conf); do
# Assing key=value
for key in $line; do
eval ${key%%=*}=${key#*=}
done
done
}
get_dns_domain_value() { get_dns_domain_value() {
key="$1" key="$1"
@ -406,6 +447,17 @@ is_web_domain_key_empty() {
fi fi
} }
is_web_domain_cert_valid() {
# Checking file existance
path="$V_USERS/$user/cert"
if [ ! -e "$path/$ssl.crt" ] || [ ! -e "$path/$ssl.key" ]; then
echo "Error: certificate not exist"
log_event 'debug' "$E_CERT_NOTEXIST $V_EVENT"
exit $E_CERT_NOTEXIST
fi
}
is_dns_record_valid() { is_dns_record_valid() {
# Checking record id # Checking record id
check_id=$(grep "^ID='$id'" $V_USERS/$user/zones/$domain) check_id=$(grep "^ID='$id'" $V_USERS/$user/zones/$domain)
@ -610,3 +662,82 @@ namehost_ip_disable() {
web_restart='yes' web_restart='yes'
fi fi
} }
upd_web_domain_values() {
ip=$IP
group="$user"
email="$user@$domain"
docroot="$V_HOME/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
proxy_string="proxy_pass http://$ip:$WEB_PORT;"
# Parsing domain aliases
i=1
j=1
OLD_IFS="$IFS"
IFS=','
server_alias=''
alias_string=''
for dalias in $ALIAS; do
dalias=$(idn -t --quiet -a $dalias)
# Spliting ServerAlias lines
check_8k="$server_alias $dalias"
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="$dalias"
server_alias="$dalias"
alias_string="ServerAlias $server_alias"
else
aliases_idn="$aliases_idn,$dalias"
server_alias="$server_alias $dalias"
fi
(( ++i))
done
if [ "$j" -gt 1 ]; then
alias_string="$alias_string\n ServerAlias $server_alias"
else
alias_string="ServerAlias $server_alias"
fi
IFS=$OLD_IFS
# Checking error log status
if [ "$ELOG" = 'no' ]; then
elog='#'
else
elog=''
fi
# Checking cgi
if [ "$CGI" != 'yes' ]; then
cgi='#'
cgi_option='-ExecCGI'
else
cgi=''
cgi_option='+ExecCGI'
fi
# Checking suspend
if [ "$SUSPEND" = 'yes' ]; then
docroot_string="Redirect / http://$url"
proxy_string="rewrite ^(.*)\$ http://$url;"
fi
# Defining SSL vars
ssl_cert="$V_HOME/$user/conf/$SSL_CERT.crt"
ssl_key="$V_HOME/$user/conf/$SSL_CERT.key"
case $SSL_HOME in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
same) docroot="$V_HOME/$user/web/$domain/public_html" ;;
esac
}

View file

@ -117,6 +117,7 @@ is_ip_avalable() {
is_sys_ip_owner() { is_sys_ip_owner() {
# Parsing ip # Parsing ip
ip="$IP"
ip_owner=$(grep 'OWNER=' $V_IPS/$ip|cut -f 2 -d \') ip_owner=$(grep 'OWNER=' $V_IPS/$ip|cut -f 2 -d \')
if [ "$ip_owner" != "$user" ]; then if [ "$ip_owner" != "$user" ]; then
echo "Error: IP not owned" echo "Error: IP not owned"
@ -131,13 +132,14 @@ get_ip_name() {
} }
increase_ip_value() { increase_ip_value() {
sip=${1-ip}
USER=$user USER=$user
web_key='U_WEB_DOMAINS' web_key='U_WEB_DOMAINS'
usr_key='U_SYS_USERS' usr_key='U_SYS_USERS'
# Parsing values # Parsing values
current_web=$(grep "$web_key=" $V_IPS/$ip |cut -f 2 -d \') current_web=$(grep "$web_key=" $V_IPS/$sip |cut -f 2 -d \')
current_usr=$(grep "$usr_key=" $V_IPS/$ip |cut -f 2 -d \') current_usr=$(grep "$usr_key=" $V_IPS/$sip |cut -f 2 -d \')
# Checking result # Checking result
if [ -z "$current_web" ]; then if [ -z "$current_web" ]; then
@ -221,40 +223,6 @@ get_sys_ip_value() {
echo "$value" echo "$value"
} }
change_domain_ip() {
# Defining vars
conf="$1"
domain="$2"
ip="$3"
old_ip="$4"
tpl_file="$5"
# Get ServerName line
serv_line=$(grep -n 'ServerName %domain_idn%' "$tpl_file" |cut -f 1 -d :)
# Get tpl_file last line
last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
# Get before line
bfr_line=$((serv_line - 1))
# Parsing httpd.conf
str=$(grep -B $bfr_line -n "ServerName $domain" $conf|grep '<VirtualHost')
# Checking integrity
if [ -z "$str" ] || [ -z "$serv_line" ] || [ -z "$bfr_line" ]; then
echo "Error: httpd parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
fi
# String number
str_number=$(echo $str | sed -e "s/-/+/" | cut -f 1 -d '+')
# Changing elog in config
sed -i "$str_number s/$old_ip/$ip/g" $conf
}
get_current_interface() { get_current_interface() {
# Parsing ifconfig # Parsing ifconfig
i=$(/sbin/ifconfig |grep -B1 "addr:$ip "|head -n 1 |cut -f 1 -d ' ') i=$(/sbin/ifconfig |grep -B1 "addr:$ip "|head -n 1 |cut -f 1 -d ' ')

View file

@ -5,17 +5,13 @@ log_event() {
event="$2" event="$2"
# Checking logging system # Checking logging system
log_system=$(grep 'LOG_SYSTEM=' $V_CONF/vesta.conf | cut -f 2 -d \' ) if [ "$LOG_SYSTEM" = 'yes' ]; then
if [ "$log_system" = 'yes' ]; then
# Checking logging level # Checking logging level
log=$(grep 'LOG_LEVEL=' $V_CONF/vesta.conf|\ log=$(echo "$LOG_LEVEL" | cut -f 2 -d \' | grep -w "$level" )
cut -f 2 -d \'|grep -w "$level" )
if [ ! -z "$log" ]; then if [ ! -z "$log" ]; then
echo "$event" >> $V_LOG/$level.log echo "$event" >> $V_LOG/$level.log
fi fi
fi fi
} }
# Log user history # Log user history
@ -24,8 +20,7 @@ log_history() {
undo="$2" undo="$2"
# Checking logging system # Checking logging system
log_history=$(grep 'LOG_HISTORY=' $V_CONF/vesta.conf | cut -f 2 -d \' ) if [ "$LOG_HISTORY" = 'yes' ]; then
if [ "$log_history" = 'yes' ]; then
echo "$event [$undo]" >> $V_USERS/$user/history.log echo "$event [$undo]" >> $V_USERS/$user/history.log
fi fi
} }
@ -328,7 +323,7 @@ format_validation() {
dom_alias) format_dom "$v" ;; dom_alias) format_dom "$v" ;;
auth_pass) format_pwd "$v" ;; auth_pass) format_pwd "$v" ;;
auth_user) format_usr "$v" ;; auth_user) format_usr "$v" ;;
certificate) format_usr "$v" ;; ssl) format_usr "$v" ;;
domain) format_dom "$v" ;; domain) format_dom "$v" ;;
database) format_db "$v" ;; database) format_db "$v" ;;
db_user) format_dbu "$v" ;; db_user) format_dbu "$v" ;;
@ -376,11 +371,7 @@ is_system_enabled() {
stype="$1" stype="$1"
web_function() { web_function() {
# Parsing config if [ -z "$WEB_SYSTEM" ] || [ "$WEB_SYSTEM" = "no" ]; then
web_system=$(grep "WEB_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$web_system" ] || [ "$web_system" = "no" ]; then
echo "Error: web hosting support disabled" echo "Error: web hosting support disabled"
log_event 'debug' "$E_WEB_DISABLED $V_EVENT" log_event 'debug' "$E_WEB_DISABLED $V_EVENT"
exit $E_WEB_DISABLED exit $E_WEB_DISABLED
@ -388,11 +379,7 @@ is_system_enabled() {
} }
proxy_function() { proxy_function() {
# Parsing config if [ "$PROXY_SYSTEM" != 'nginx' ]; then # only nginx
proxy_system=$(grep "PROXY_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ "$proxy_system" != 'nginx' ]; then # only nginx
echo "Error: proxy hosting support disabled" # support for echo "Error: proxy hosting support disabled" # support for
log_event 'debug' "$E_PROXY_DISABLED $V_EVENT" # now log_event 'debug' "$E_PROXY_DISABLED $V_EVENT" # now
exit $E_PROXY_DISABLED exit $E_PROXY_DISABLED
@ -400,11 +387,7 @@ is_system_enabled() {
} }
dns_function() { dns_function() {
# Parsing config if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = "no" ]; then
dns_system=$(grep "DNS_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$dns_system" ] || [ "$cron_system" = "no" ]; then
echo "Error: dns support disabled" echo "Error: dns support disabled"
log_event 'debug' "$E_DNS_DISABLED $V_EVENT" log_event 'debug' "$E_DNS_DISABLED $V_EVENT"
exit $E_DNS_DISABLED exit $E_DNS_DISABLED
@ -412,11 +395,7 @@ is_system_enabled() {
} }
cron_function() { cron_function() {
# Parsing config if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = "no" ]; then
cron_system=$(grep "CRON_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$cron_system" ] || [ "$cron_system" = "no" ]; then
echo "Error: crond support disabled" echo "Error: crond support disabled"
log_event 'debug' "$E_CRON_DISABLED $V_EVENT" log_event 'debug' "$E_CRON_DISABLED $V_EVENT"
exit $E_CRON_DISABLED exit $E_CRON_DISABLED
@ -424,11 +403,7 @@ is_system_enabled() {
} }
db_function() { db_function() {
# Parsing config if [ -z "$DB_SYSTEM" ] || [ "$DB_SYSTEM" = "no" ]; then
db_system=$(grep "DB_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$db_system" ] || [ "$db_system" = "no" ]; then
echo "Error: db support disabled" echo "Error: db support disabled"
log_event 'debug' "$E_DB_DISABLED $V_EVENT" log_event 'debug' "$E_DB_DISABLED $V_EVENT"
exit $E_DB_DISABLED exit $E_DB_DISABLED
@ -436,11 +411,7 @@ is_system_enabled() {
} }
backup_function() { backup_function() {
# Parsing config if [ -z "$BACKUP_SYSTEM" ] || [ "$BACKUP_SYSTEM" = "no" ]; then
bck_system=$(grep "BACKUP_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$bck_system" ] || [ "$bck_system" = "no" ]; then
echo "Error: backup support disabled" echo "Error: backup support disabled"
log_event 'debug' "$E_BACKUP_DISABLED $V_EVENT" log_event 'debug' "$E_BACKUP_DISABLED $V_EVENT"
exit $E_BACKUP_DISABLED exit $E_BACKUP_DISABLED
@ -803,16 +774,6 @@ increase_user_value() {
sed -i "s/$key='$current_value'/$key='$new_value'/g" $conf sed -i "s/$key='$current_value'/$key='$new_value'/g" $conf
} }
is_web_domain_cert_valid() {
# Checking file existance
path="$V_USERS/$user/cert"
if [ ! -e "$path/$cert.crt" ] || [ ! -e "$path/$cert.key" ]; then
echo "Error: certificate not exist"
log_event 'debug' "$E_CERT_NOTEXIST $V_EVENT"
exit $E_CERT_NOTEXIST
fi
}
is_type_valid() { is_type_valid() {
# Argument defenition # Argument defenition
sys="$1" sys="$1"
@ -965,9 +926,9 @@ json_list() {
# Printing child # Printing child
if [ $i -lt $fileds_count ]; then if [ $i -lt $fileds_count ]; then
(( ++i)) (( ++i))
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," echo -e "\t\t\"${field//$/}\": \"$value\","
else else
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" echo -e "\t\t\"${field//$/}\": \"$value\""
data=1 data=1
fi fi
fi fi