From 7ce7cf17978281baded003090142ed4ff3bc28b5 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Mon, 21 Nov 2011 15:37:23 +0200 Subject: [PATCH] 8k alias fix + new tpl convention --- bin/v_add_ssl_certificate | 12 +-- bin/v_add_web_domain | 24 ++++- bin/v_add_web_domain_alias | 57 ++++++----- bin/v_add_web_domain_cgi | 40 +++----- bin/v_add_web_domain_elog | 49 +++++---- bin/v_add_web_domain_nginx | 66 +++---------- bin/v_add_web_domain_ssl | 76 +++++++------- bin/v_add_web_domain_stat | 12 ++- bin/v_add_web_domain_stat_auth | 1 + bin/v_backup_sys_user | 6 +- bin/v_change_web_domain_ip | 44 +++++---- bin/v_change_web_domain_sslcert | 65 ++++++------ bin/v_change_web_domain_sslhome | 61 +++++------- bin/v_change_web_domain_tpl | 103 +++++++++++-------- bin/v_del_ssl_certificate | 7 +- bin/v_del_web_domain | 46 ++++++--- bin/v_del_web_domain_alias | 54 +++++----- bin/v_del_web_domain_cgi | 39 +++----- bin/v_del_web_domain_elog | 49 +++++---- bin/v_del_web_domain_nginx | 19 ++-- bin/v_del_web_domain_ssl | 49 +++++---- bin/v_del_web_domain_stat | 9 +- bin/v_del_web_domain_stat_auth | 4 +- bin/v_del_web_domains | 1 + bin/v_get_web_domain_value | 7 +- bin/v_rebuild_web_domains | 170 ++++++-------------------------- bin/v_restart_web | 11 +-- bin/v_suspend_web_domain | 59 +++++------ bin/v_suspend_web_domains | 65 +----------- bin/v_unsuspend_web_domain | 76 ++++++-------- bin/v_unsuspend_web_domains | 77 +-------------- bin/v_upd_web_domain_disk | 1 + bin/v_upd_web_domain_stat | 1 + bin/v_upd_web_domain_traff | 1 + bin/v_upd_web_domains_disk | 5 +- bin/v_upd_web_domains_stat | 8 +- bin/v_upd_web_domains_traff | 1 + func/cert.func | 10 +- func/domain.func | 141 +++++++++++++++++++++++++- func/ip.func | 40 +------- func/shared.func | 63 +++--------- 41 files changed, 721 insertions(+), 908 deletions(-) diff --git a/bin/v_add_ssl_certificate b/bin/v_add_ssl_certificate index 1c87da5d..8387c36b 100755 --- a/bin/v_add_ssl_certificate +++ b/bin/v_add_ssl_certificate @@ -7,7 +7,7 @@ # Argument defenition user=$1 -cert=$2 +ssl=$2 # Importing variables source $VESTA/conf/vars.conf @@ -19,10 +19,10 @@ source $V_FUNC/cert.func #----------------------------------------------------------# # Checking arg number -check_args '2' "$#" 'user certificate' +check_args '2' "$#" 'user ssl_certificate' # Checking argument format -format_validation 'user' 'certificate' +format_validation 'user' 'ssl' # Checking user is_user_valid @@ -42,8 +42,8 @@ is_cert_valid "$V_TMP" #----------------------------------------------------------# # Adding certificate to user dir -mv $V_TMP/$cert.crt $V_USERS/$user/cert/ -mv $V_TMP/$cert.key $V_USERS/$user/cert/ +mv $V_TMP/$ssl.crt $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 -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" exit diff --git a/bin/v_add_web_domain b/bin/v_add_web_domain index 7870441c..2fe1eea4 100755 --- a/bin/v_add_web_domain +++ b/bin/v_add_web_domain @@ -14,6 +14,7 @@ template=${4-default} # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func source $V_FUNC/ip.func @@ -66,6 +67,7 @@ is_template_valid "web" #----------------------------------------------------------# # Defining domain aliases +IP=$ip ip_name=$(get_ip_name) ip_name_idn=$(idn -t --quiet -a "$ip_name") domain_alias="www.$domain" @@ -75,16 +77,19 @@ if [ ! -z "$ip_name" ]; then domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn" aliases="$domain_alias,$domain_alias_dash" aliases_idn="$domain_alias_idn,$domain_alias_dash_idn" + alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn" else aliases="$domain_alias" aliases_idn="$domain_alias_idn" + alias_string="ServerAlias $domain_alias_idn" fi # Defining vars for add_config function -web_port=$(get_config_value '$WEB_PORT') group="$user" email="$user@$domain" docroot="$V_HOME/$user/web/$domain/public_html" +docroot_string="DocumentRoot $docroot" + conf="$V_HOME/$user/conf/httpd.conf" tpl_file="$V_WEBTPL/apache_$template.tpl" @@ -96,9 +101,18 @@ done # Checking error log status if [ "$ELOG" = 'no' ]; then - elog=' #' + elog='#' else - elog=' ' + elog='' +fi + +# Checking cgi +if [ "$CGI" != 'yes' ]; then + cgi='#' + cgi_option='-ExecCGI' +else + cgi='' + cgi_option='+ExecCGI' fi # Adding domain to the httpd.conf @@ -177,7 +191,7 @@ fi #----------------------------------------------------------# # Increasing ip value -increase_ip_value +increase_ip_value "$ip" # Increasing domain value 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 TPL='$template'" 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 SSL_HOME='' SSL_CERT=''" v_str="$v_str NGINX='' NGINX_EXT='' SUSPEND='no' DATE='$V_DATE'" diff --git a/bin/v_add_web_domain_alias b/bin/v_add_web_domain_alias index 5b07fd7b..44ec5691 100755 --- a/bin/v_add_web_domain_alias +++ b/bin/v_add_web_domain_alias @@ -14,6 +14,7 @@ dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -62,36 +63,46 @@ is_package_full 'web_alias' # Action # #----------------------------------------------------------# -# Defining params for change function -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" +# Parsing domain values +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" -search_phrase='ServerAlias' -# Defining new alias string -curr_alias=$(get_web_domain_value '$ALIAS') -if [ -z "$curr_alias" ]; then - new_alias="$dom_alias" - new_alias_idn="$dom_alias_idn" +# Parsing domain aliases +if [ -z "$ALIAS" ]; then + ALIAS="$dom_alias" else - new_alias="$curr_alias,$dom_alias" - new_alias_idn=$(idn -t --quiet -a "$curr_alias,$dom_alias") + ALIAS="$ALIAS,$dom_alias" fi -# Defining replace string -str_repl=" ServerAlias ${new_alias_idn//,/ }" +# Preparing domain values for the template substitution +upd_web_domain_values -# Adding alias -change_web_config +# Recreating vhost +del_web_config +add_web_config -# Checking ssl domain -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Defining params for change function - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" 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 @@ -100,7 +111,7 @@ fi #----------------------------------------------------------# # Adding new alias -update_web_domain_value '$ALIAS' "$new_alias" +update_web_domain_value '$ALIAS' "$ALIAS" # Adding task to the vesta pipe restart_schedule 'web' diff --git a/bin/v_add_web_domain_cgi b/bin/v_add_web_domain_cgi index 37b828f8..c4d6746f 100755 --- a/bin/v_add_web_domain_cgi +++ b/bin/v_add_web_domain_cgi @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -49,36 +50,25 @@ is_web_domain_key_empty '$CGI' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" - -# Defining params for ScriptAlias +# Parsing domain values +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" -search_phrase='ScriptAlias ' -str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin/" -change_web_config +CGI='yes' -# Defining params for Options -search_phrase='Options ' -str_repl=' Options +Includes -Indexes +ExecCGI' -change_web_config +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config # Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Defining params for ScriptAlias - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" - search_phrase='ScriptAlias ' - str_repl=" ScriptAlias /cgi-bin/ $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 + del_web_config + add_web_config fi diff --git a/bin/v_add_web_domain_elog b/bin/v_add_web_domain_elog index 38ed3e1d..5d9661cd 100755 --- a/bin/v_add_web_domain_elog +++ b/bin/v_add_web_domain_elog @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -49,35 +50,41 @@ is_web_domain_key_empty '$ELOG' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" - -# Defining config +# Parsing domain values +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" +ELOG='yes' -# Defining search phrase -search_phrase='ErrorLog ' +# Preparing domain values for the template substitution +upd_web_domain_values -# Defining replace string -str_repl=" ErrorLog /var/log/httpd/domains/$domain.error.log" - -# Adding errolog support -change_web_config +# Recreating vhost +del_web_config +add_web_config # Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Get ssl template name - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - - # Defining ssl config +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" + del_web_config + add_web_config +fi - # Adding errolog support - change_web_config +# 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 diff --git a/bin/v_add_web_domain_nginx b/bin/v_add_web_domain_nginx index 8f081f56..c9845415 100755 --- a/bin/v_add_web_domain_nginx +++ b/bin/v_add_web_domain_nginx @@ -16,6 +16,7 @@ extentions=${4-$default_extentions} # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -57,71 +58,32 @@ is_template_valid "proxy" #----------------------------------------------------------# # Defining domain parameters -ip=$(get_web_domain_value '$IP') -web_port=$(get_config_value '$WEB_PORT') -proxy_port=$(get_config_value '$PROXY_PORT') -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') -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" +get_web_domain_values +NGINX="$template" +NGINX_EXT="$extentions" +tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" conf="$V_HOME/$user/conf/nginx.conf" + +# Preparing domain values for the template substitution +upd_web_domain_values 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 - -# 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 +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" - tpl_file="$V_WEBTPL/ngingx_vhost_$template.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 #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# +echo "NGINX=$NGINX" +echo "NGINX_EXT=$NGINX_EXT" # Adding nginx params to config -update_web_domain_value '$NGINX' "$template" +update_web_domain_value '$NGINX' "$NGINX" update_web_domain_value '$NGINX_EXT' "$extentions" # Adding task to the vesta pipe diff --git a/bin/v_add_web_domain_ssl b/bin/v_add_web_domain_ssl index 08ddf950..7ccf5e0f 100755 --- a/bin/v_add_web_domain_ssl +++ b/bin/v_add_web_domain_ssl @@ -9,11 +9,12 @@ user=$1 domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") -cert=$3 -tpl_option=${4-single} +ssl=$3 +ssl_home=${4-single} # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func source $V_FUNC/ip.func @@ -27,7 +28,7 @@ source $V_FUNC/ip.func check_args '3' "$#" 'user domain certificate [sslhome]' # Checking argument format -format_validation 'user' 'domain' 'certificate' +format_validation 'user' 'domain' 'ssl' # Checking web system is enabled is_system_enabled 'web' @@ -47,58 +48,36 @@ is_domain_suspended 'web' # Checking package is_package_full 'web_ssl' -# Checking ip ownership -ip=$(get_web_domain_value '$IP') -is_sys_ip_owner - # Check ssl is not added is_web_domain_key_empty '$SSL_CERT' # Checking ssl certificate is_web_domain_cert_valid -# Checking template -templates=$(get_user_value '$WEB_TPL') -template=$(get_web_domain_value '$TPL') -is_template_valid 'web' - #----------------------------------------------------------# # Action # #----------------------------------------------------------# -# Defining variables for template replace -web_ssl_port=$(get_config_value '$WEB_SSL_PORT') -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" +# Parsing domain values +get_web_domain_values 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 -elog=$(get_web_domain_value '$ELOG') -if [ "$elog" = 'no' ]; then - elog=' #' -else - elog=' ' -fi +# Checking ip ownership +is_sys_ip_owner -# 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 # Adding certificate to user dir -if [ ! -e "$ssl_cert" ]; then - cp -f $V_USERS/$user/cert/$cert.crt $ssl_cert - cp -f $V_USERS/$user/cert/$cert.key $ssl_key -fi +cp -f $V_USERS/$user/cert/$SSL_CERT.crt $ssl_cert +cp -f $V_USERS/$user/cert/$SSL_CERT.key $ssl_key # Running template trigger if [ -x $V_WEBTPL/apache_$template.sh ]; then @@ -109,7 +88,22 @@ fi main_conf='/etc/httpd/conf.d/vesta.conf' main_conf_check=$(grep "$conf" $main_conf ) 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 @@ -121,8 +115,8 @@ fi increase_user_value "$user" '$U_WEB_SSL' # Adding ssl values -update_web_domain_value '$SSL_HOME' "$tpl_option" -update_web_domain_value '$SSL_CERT' "$cert" +update_web_domain_value '$SSL_CERT' "$SSL_CERT" +update_web_domain_value '$SSL_HOME' "$SSL_HOME" # Logging log_history "$V_EVENT" "v_del_web_domain_ssl $user $domain" diff --git a/bin/v_add_web_domain_stat b/bin/v_add_web_domain_stat index 9e4a0f5b..1f6b44f0 100755 --- a/bin/v_add_web_domain_stat +++ b/bin/v_add_web_domain_stat @@ -13,6 +13,7 @@ type=$3 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -55,13 +56,18 @@ is_web_domain_key_empty '$STATS' #----------------------------------------------------------# # Parse aliases -aliases=$(get_web_domain_value '$ALIAS') -aliases_idn=$(idn -t --quiet -a "$aliases") +get_web_domain_values + +# Preparing domain values for the template substitution +upd_web_domain_values # Adding statistic config cat $V_WEBTPL/$type.tpl |\ 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%/$domain/g" \ -e "s/%user%/$user/g" \ diff --git a/bin/v_add_web_domain_stat_auth b/bin/v_add_web_domain_stat_auth index 783b37f9..67455749 100755 --- a/bin/v_add_web_domain_stat_auth +++ b/bin/v_add_web_domain_stat_auth @@ -13,6 +13,7 @@ auth_pass=$4 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func diff --git a/bin/v_backup_sys_user b/bin/v_backup_sys_user index 05c1eade..8efb6dd8 100755 --- a/bin/v_backup_sys_user +++ b/bin/v_backup_sys_user @@ -63,7 +63,6 @@ done # Get current time start_time=$(date '+%s') -sleep 131 # Creating temporary random directory tmpdir=$(mktemp -p $V_TMP -d) @@ -618,7 +617,10 @@ fi # Deleting old backup records 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 # Concatenating string diff --git a/bin/v_change_web_domain_ip b/bin/v_change_web_domain_ip index 8743d422..65f5fc6a 100755 --- a/bin/v_change_web_domain_ip +++ b/bin/v_change_web_domain_ip @@ -13,6 +13,7 @@ ip=$3 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func source $V_FUNC/ip.func @@ -51,26 +52,33 @@ is_ip_avalable # Action # #----------------------------------------------------------# -# Get tpl -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" - +# Define variable for replace +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" -old_ip=$(get_web_domain_value '$IP') - -# Changing ip -change_domain_ip "$conf" "$domain" "$ip" "$old_ip" "$tpl_file" +old=$IP +new=$ip +replace_web_config # Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Get tpl - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" + replace_web_config +fi - # Adding elog - change_domain_ip "$conf" "$domain" "$ip" "$old_ip" "$tpl_file" +# Checking nginx +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 @@ -79,13 +87,13 @@ fi #----------------------------------------------------------# # Increasing ip value -increase_ip_value +increase_ip_value "$new" # Decreasing old ip value -decrease_ip_value "$old_ip" +decrease_ip_value "$old" # Adding ip in config -update_web_domain_value '$IP' "$ip" +update_web_domain_value '$IP' "$new" # Adding task to the vesta pipe restart_schedule 'web' diff --git a/bin/v_change_web_domain_sslcert b/bin/v_change_web_domain_sslcert index c60a5953..c068ef73 100755 --- a/bin/v_change_web_domain_sslcert +++ b/bin/v_change_web_domain_sslcert @@ -9,10 +9,11 @@ user=$1 domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") -certificate=$3 +ssl=$3 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -25,7 +26,7 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain certificate' # Checking argument format -format_validation 'user' 'domain' 'certificate' +format_validation 'user' 'domain' 'ssl' # Checking web system is enabled is_system_enabled 'web' @@ -53,39 +54,38 @@ is_web_domain_cert_valid # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - -# Defininig config +# Parsing domain values +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" +old_ssl="$SSL_CERT" +SSL_CERT="$ssl" -# Defining ssl key and certificate -ssl_cert="$V_HOME/$user/conf/$certificate.crt" -ssl_key="$V_HOME/$user/conf/$certificate.key" +# Preparing domain values for the template substitution +upd_web_domain_values -# Defining search phrase -search_phrase='SSLCertificateFile' +# Recreating vhost +del_web_config +add_web_config -# Defining replace string -str_repl=" SSLCertificateFile $ssl_cert" +# Checking nginx +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 -change_web_config +# Adding new certificate to user dir +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 -search_phrase='SSLCertificateKeyFile' - -# Defining replace string -str_repl=" SSLCertificateKeyFile $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 +# 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 @@ -93,17 +93,14 @@ fi # Vesta # #----------------------------------------------------------# -# Get old sslhome value -old_ssl_cert=$(get_web_domain_value '$SSL_CERT') - # 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 restart_schedule 'web' # 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" exit diff --git a/bin/v_change_web_domain_sslhome b/bin/v_change_web_domain_sslhome index 916a4fb4..dcd2bd1b 100755 --- a/bin/v_change_web_domain_sslhome +++ b/bin/v_change_web_domain_sslhome @@ -9,10 +9,11 @@ user=$1 domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") -tpl_option=$3 +ssl_home=$3 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -50,47 +51,31 @@ is_web_domain_value_exist '$SSL_CERT' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - -# Defininig config +# Get domain values +get_web_domain_values +old_ssl_home=$SSL_HOME +SSL_HOME=$ssl_home +tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" -# Defining search phrase -search_phrase='DocumentRoot' - # Parsing tpl_option -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' "2" 'user domain sslhome' +case $SSL_HOME in + single) new="$V_HOME/$user/web/$domain/public_shtml" ; + old="$V_HOME/$user/web/$domain/public_html" ;; + 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 -# Defining replace string -str_repl=" DocumentRoot $docroot" +# Changing sslhome directory +replace_web_config -# Changing sslhome -change_web_config - -# Get old sslhome value -ssl_home=$(get_web_domain_value '$SSL_HOME') - -# 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="" - -# Defining replace string -str_repl=" " - -# Changing sslhome directory tag -change_web_config +# Checking nginx config +if [ ! -z "$NGINX" ]; then + tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$V_HOME/$user/conf/snginx.conf" + replace_web_config +fi #----------------------------------------------------------# @@ -98,13 +83,13 @@ change_web_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 restart_schedule 'web' # 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" exit diff --git a/bin/v_change_web_domain_tpl b/bin/v_change_web_domain_tpl index 9cf8075b..90254453 100755 --- a/bin/v_change_web_domain_tpl +++ b/bin/v_change_web_domain_tpl @@ -13,6 +13,7 @@ template=$3 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -51,57 +52,82 @@ is_template_valid "web" # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" -conf="$V_HOME/$user/conf/httpd.conf" +# Parsing domain values +get_web_domain_values # Deleting domain +tpl_file="$V_WEBTPL/apache_$TPL.tpl" +old_tpl=$TPL +conf="$V_HOME/$user/conf/httpd.conf" del_web_config -# Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Get tpl - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +# Deleting ssl vhost +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" - - # Deleting domain del_web_config fi -# Defining variables for template replace -ip=$(get_web_domain_value '$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') +# Defining variables for new vhost config +ip=$IP email="$user@$domain" +group="$user" docroot="$V_HOME/$user/web/$domain/public_html" conf="$V_HOME/$user/conf/httpd.conf" 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 eval ${keys%%=*}=${keys#*=} done -# Checking error log status +# Checking error log if [ "$ELOG" = 'no' ]; then - elog=' #' + elog='#' else - elog=' ' + elog='' fi # Adding domain to the httpd.conf @@ -113,15 +139,13 @@ if [ -x $V_WEBTPL/apache_$template.sh ]; then fi # Checking ssl -if [ ! -z "$cert" ]; then +if [ ! -z "$SSL_CERT" ]; then # Defining variables for ssl template replace - web_ssl_port=$(get_config_value '$WEB_SSL_PORT') - tpl_option=$(get_web_domain_value '$SSL_HOME') - ssl_cert="$V_HOME/$user/conf/$cert.crt" - ssl_key="$V_HOME/$user/conf/$cert.key" - case $tpl_option in + 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" ;; - *) docroot="$V_HOME/$user/web/$domain/public_html" ;; + same) docroot="$V_HOME/$user/web/$domain/public_html" ;; esac conf="$V_HOME/$user/conf/shttpd.conf" tpl_file="$V_WEBTPL/apache_$template.stpl" @@ -155,6 +179,7 @@ done restart_schedule 'web' # Logging +log_history "$V_EVENT" "v_change_web_domain_tpl $user $domain $old_tpl" log_event 'system' "$V_EVENT" exit diff --git a/bin/v_del_ssl_certificate b/bin/v_del_ssl_certificate index 82938c31..e0c7a57b 100755 --- a/bin/v_del_ssl_certificate +++ b/bin/v_del_ssl_certificate @@ -7,7 +7,7 @@ # Argument defenition user=$1 -cert=$2 +ssl=$2 # Importing variables source $VESTA/conf/vars.conf @@ -31,9 +31,6 @@ is_user_valid # Checking user is active is_user_suspended -# Checking ssl ceritificate -is_cert_valid "$V_USERS/$user/cert" - # Checking certificate is_cert_used @@ -43,7 +40,7 @@ is_cert_used #----------------------------------------------------------# # Deleting certificate -rm -f $V_USERS/$user/cert/$cert.* +rm -f $V_USERS/$user/cert/$ssl.* #----------------------------------------------------------# diff --git a/bin/v_del_web_domain b/bin/v_del_web_domain index 051b5baa..6156b486 100755 --- a/bin/v_del_web_domain +++ b/bin/v_del_web_domain @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func source $V_FUNC/ip.func @@ -48,31 +49,46 @@ is_domain_suspended 'web' #----------------------------------------------------------# # Get template name -tpl_name=$(get_web_domain_value '$TPL') -old_ip=$(get_web_domain_value '$IP') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" # Deleting domain del_web_config # Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Get tpl - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" - - # Deleting domain 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 # Checking stats -stats_type=$(get_web_domain_value '$STATS') -if [ ! -z "$stats_type" ] && [ "$stats_type" != 'no' ]; then +if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then # 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 ) # Deleting pipe command @@ -81,7 +97,7 @@ if [ ! -z "$stats_type" ] && [ "$stats_type" != 'no' ]; then fi # Deleteing config - rm -f $V_HOME/$user/conf/$type.$domain.conf + rm -f $V_HOME/$user/conf/$STATS.$domain.conf fi # Deleting directory @@ -137,7 +153,7 @@ if [ -z "$last_nginx" ]; then fi # Decreasing ip value -decrease_ip_value "$old_ip" +decrease_ip_value "$IP" # Decreasing domain value decrease_user_value "$user" '$U_WEB_DOMAINS' diff --git a/bin/v_del_web_domain_alias b/bin/v_del_web_domain_alias index 188b06eb..b524745f 100755 --- a/bin/v_del_web_domain_alias +++ b/bin/v_del_web_domain_alias @@ -14,6 +14,7 @@ dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -44,8 +45,8 @@ is_web_domain_valid is_domain_suspended 'web' # Checking alias is added -cur_alias=$(get_web_domain_value '$ALIAS') -check_alias=$(echo ${cur_alias//,/ }|grep -w "$dom_alias") +get_web_domain_values +check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias") if [ -z "$check_alias" ]; then echo "Error: alias not exist" log_event 'debug' "$E_DOM_NOTEXIST $V_EVENT" @@ -57,35 +58,42 @@ fi #----------------------------------------------------------# # Defining new alias string -new_alias=$(echo "$cur_alias" |\ +ALIAS=$(echo "$ALIAS" |\ sed -e "s/,/\n/g"|\ sed -e "s/^$dom_alias$//g"|\ sed -e "/^$/d"|\ sed -e ':a;N;$!ba;s/\n/,/g') - -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" +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" -search_phrase='ServerAlias' -str_repl=" ServerAlias ${new_alias_idn//,/ }" -# Deleting alias -change_web_config +# Preparing domain values for the template substitution +upd_web_domain_values -# Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then +# Recreating vhost +del_web_config +add_web_config - # Defining ssl options - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" 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 @@ -94,7 +102,7 @@ fi #----------------------------------------------------------# # Deleting alias -update_web_domain_value '$ALIAS' "$new_alias" +update_web_domain_value '$ALIAS' "$ALIAS" # Adding task to the vesta pipe restart_schedule 'web' diff --git a/bin/v_del_web_domain_cgi b/bin/v_del_web_domain_cgi index 4d1fe647..e36cf450 100755 --- a/bin/v_del_web_domain_cgi +++ b/bin/v_del_web_domain_cgi @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -49,36 +50,24 @@ is_web_domain_value_exist '$CGI' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" - -# Defining params for ScriptAlias +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" -search_phrase='ScriptAlias ' -str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/web/$domain/cgi-bin" -change_web_config +CGI='no' -# Defining params for Options -search_phrase='Options ' -str_repl=' Options +Includes -Indexes -ExecCGI' -change_web_config +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config # Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Defining params for ScriptAlias - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" - search_phrase='ScriptAlias ' - str_repl=" #ScriptAlias /cgi-bin/ $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 + del_web_config + add_web_config fi diff --git a/bin/v_del_web_domain_elog b/bin/v_del_web_domain_elog index 5a7405fd..f7afb451 100755 --- a/bin/v_del_web_domain_elog +++ b/bin/v_del_web_domain_elog @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -49,35 +50,41 @@ is_web_domain_value_exist '$ELOG' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" - -# Defining config +# Parsing domain values +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" +ELOG='no' -# Defining search phrase -search_phrase='ErrorLog ' +# Preparing domain values for the template substitution +upd_web_domain_values -# Defining replace string -str_repl=" #ErrorLog /var/log/httpd/domains/$domain.error.log" - -# Deleting errolog support -change_web_config +# Recreating vhost +del_web_config +add_web_config # Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - - # Get ssl template name - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - - # Defining ssl config +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" + del_web_config + add_web_config +fi - # Deleting errolog support - change_web_config +# 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 diff --git a/bin/v_del_web_domain_nginx b/bin/v_del_web_domain_nginx index bbc179d7..a984361d 100755 --- a/bin/v_del_web_domain_nginx +++ b/bin/v_del_web_domain_nginx @@ -1,5 +1,5 @@ #!/bin/bash -# info: deliting web domain nginx config +# info: deleting web domain nginx config #----------------------------------------------------------# # Variable&Function # @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -49,19 +50,15 @@ is_web_domain_value_exist '$NGINX' # Action # #----------------------------------------------------------# -# Get domain values -tpl_name=$(get_web_domain_value '$NGINX') -tpl_file="$V_WEBTPL/ngingx_vhost_$tpl_name.tpl" +# Defining domain parameters +get_web_domain_values +tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" conf="$V_HOME/$user/conf/nginx.conf" -ext=$(get_web_domain_value '$NGINX_EXT' ) - -# Deleting domain del_web_config # Checking ssl -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$tpl_name.stpl" +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" conf="$V_HOME/$user/conf/snginx.conf" del_web_config fi @@ -99,7 +96,7 @@ fi restart_schedule 'web' # 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" exit diff --git a/bin/v_del_web_domain_ssl b/bin/v_del_web_domain_ssl index c0fe7ffc..01a24298 100755 --- a/bin/v_del_web_domain_ssl +++ b/bin/v_del_web_domain_ssl @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -49,23 +50,34 @@ is_web_domain_value_exist '$SSL_CERT' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +# Parsing domain values +get_web_domain_values conf="$V_HOME/$user/conf/shttpd.conf" +tpl_file="$V_WEBTPL/apache_$TPL.stpl" +old_ssl="$SSL_CERT" # Deleting domain 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 # #----------------------------------------------------------# -# Get old values -cert=$(get_web_domain_value '$SSL_CERT' ) -tpl_option=$(get_web_domain_value '$SSL_HOME' ) - # Deleting ssl in config update_web_domain_value '$SSL_HOME' '' update_web_domain_value '$SSL_CERT' '' @@ -79,23 +91,26 @@ if [ -z "$ssl_dom" ]; then rm -f $conf 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 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 restart_schedule 'web' # 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" exit diff --git a/bin/v_del_web_domain_stat b/bin/v_del_web_domain_stat index d8e6594d..1d28f745 100755 --- a/bin/v_del_web_domain_stat +++ b/bin/v_del_web_domain_stat @@ -11,6 +11,7 @@ domain=$(idn -t --quiet -u "$2" ) # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -65,14 +66,8 @@ rm -f $V_HOME/$user/conf/$type.$domain.conf # Vesta # #----------------------------------------------------------# -# Parsing pipe line -line=$(grep -n "$type.$domain.conf" $V_QUEUE/stats.pipe | \ - cut -f 1 -d : | head -n 1 ) - # Deleting pipe command -if [ ! -z "$line" ]; then - sed -i "$line d" $V_QUEUE/stats.pipe -fi +sed -i "/ $domain$/d" $V_QUEUE/stats.pipe # Deleting stats update_web_domain_value '$STATS' '' diff --git a/bin/v_del_web_domain_stat_auth b/bin/v_del_web_domain_stat_auth index b32a9557..2d659845 100755 --- a/bin/v_del_web_domain_stat_auth +++ b/bin/v_del_web_domain_stat_auth @@ -12,6 +12,7 @@ auth_user=$3 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -54,10 +55,7 @@ stat_dir="$V_HOME/$user/web/$domain/stats" # Checking auth_user if [ ! -z "$auth_user" ]; then - - # Checking argument format format_validation 'auth_user' - htpasswd -D $stat_dir/.htpasswd "$auth_user" >/dev/null 2>&1 fi diff --git a/bin/v_del_web_domains b/bin/v_del_web_domains index be496f8d..8520120f 100755 --- a/bin/v_del_web_domains +++ b/bin/v_del_web_domains @@ -10,6 +10,7 @@ user=$1 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func diff --git a/bin/v_get_web_domain_value b/bin/v_get_web_domain_value index b2745842..196505c7 100755 --- a/bin/v_get_web_domain_value +++ b/bin/v_get_web_domain_value @@ -13,6 +13,7 @@ key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -44,10 +45,7 @@ is_domain_suspended 'web' # Action # #----------------------------------------------------------# -# Checking key value=$(get_web_domain_value "$key") - -# Printing value echo "$value" @@ -55,7 +53,4 @@ echo "$value" # Vesta # #----------------------------------------------------------# -# Logging -log_event 'system' "$V_EVENT" - exit diff --git a/bin/v_rebuild_web_domains b/bin/v_rebuild_web_domains index 8d5ce9e0..df86d675 100755 --- a/bin/v_rebuild_web_domains +++ b/bin/v_rebuild_web_domains @@ -10,6 +10,7 @@ user=$1 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func source $V_FUNC/ip.func @@ -40,175 +41,68 @@ is_user_suspended # Action # #----------------------------------------------------------# -# Defining port configuration -proxy_port=$(get_config_value '$PROXY_PORT') -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') +# Clean up old config +rm -f $V_HOME/$user/conf/tmp_*.conf # Defining config -conf="$V_USERS/$user/web.conf" - -# Defining search string -search_string="DOMAIN" - -# Defining fileds to select -field='$DOMAIN' - -# Parsing all domains -domains=$(dom_clear_search) +conf=$V_USERS/$user/web.conf +fields='$DOMAIN' +nohead=1 # Starting loop -for domain in $domains; do - - # Defining domain parameters - template=$(get_web_domain_value '$TPL') - tpl_file="$V_WEBTPL/apache_$template.tpl" - ip=$(get_web_domain_value '$IP') +for domain in $(shell_list) ; do 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 - elog=$(get_web_domain_value '$ELOG') - if [ "$elog" = 'no' ]; then - elog=' #' - else - elog=' ' - fi + # Parsing domain values + get_web_domain_values + + # Preparing domain values for the template substitution + upd_web_domain_values # Adding domain to the tmp_httpd.conf + tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/tmp_httpd.conf" add_web_config # Running template trigger - if [ -x $V_WEBTPL/apache_$template.sh ]; then - $V_WEBTPL/apache_$template.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 + if [ -x $V_WEBTPL/apache_$TPL.sh ]; then + $V_WEBTPL/apache_$TPL.sh $user $domain $ip $V_HOME $docroot 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 - - + if [ ! -z "$SSL_CERT" ]; then # Adding domain to the 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 # Running template trigger - if [ -x $V_WEBTPL/apache_$template.sh ]; then - $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot + if [ -x $V_WEBTPL/apache_$TPL.sh ]; then + $V_WEBTPL/apache_$TPL.sh $user $domain $ip $V_HOME $docroot fi - # Checking 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 + ssl_change='yes' fi # Checking nginx - nginx=$(get_web_domain_value '$NGINX') - if [ ! -z "$nginx" ]; then - proxy_port=$(get_config_value '$PROXY_PORT') - extentions=$(get_web_domain_value '$NGINX_EXT') - tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl" + if [ ! -z "$NGINX" ]; then + tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" conf="$V_HOME/$user/conf/tmp_nginx.conf" add_web_config - if [ "$suspend" = 'yes' ]; then - search_phrase='proxy_pass' - str_repl=" rewrite ^(.*)\$ http://$url;" - change_web_config - fi - - if [ ! -z "$cert" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl" + if [ ! -z "$SSL_CERT" ]; then + if [ "$SUSPEND" = 'yes' ]; then + proxy_string="rewrite ^(.*)\$ http://$url;" + else + proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" + fi + + tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" conf="$V_HOME/$user/conf/tmp_snginx.conf" add_web_config - - if [ "$suspend" = 'yes' ]; then - search_phrase='proxy_pass' - str_repl=" rewrite ^(.*)\$ http://$url;" - change_web_config - fi - fi - - ngix_change='yes' fi - done # Renaming tmp config @@ -226,7 +120,7 @@ if [ ! -z "$domains" ] && [ -z "$main_conf_check" ]; then fi # Checking ssl -if [ ! -z "$ssl_cert" ]; then +if [ "$ssl_change" = 'yes' ]; then tmp_conf="$V_HOME/$user/conf/tmp_shttpd.conf" conf="$V_HOME/$user/conf/shttpd.conf" mv $tmp_conf $conf @@ -252,7 +146,7 @@ if [ "$ngix_change" = 'yes' ]; then fi # Checking ssl for nginx - if [ ! -z "$ssl_cert" ]; then + if [ "$ssl_change" = 'yes' ]; then tmp_conf="$V_HOME/$user/conf/tmp_snginx.conf" conf="$V_HOME/$user/conf/snginx.conf" mv $tmp_conf $conf diff --git a/bin/v_restart_web b/bin/v_restart_web index a07feade..61d9bcff 100755 --- a/bin/v_restart_web +++ b/bin/v_restart_web @@ -4,6 +4,7 @@ # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf # Restart functions apache() { @@ -22,16 +23,12 @@ nginx() { fi } -# Parsing config -web_system=$(grep 'WEB_SYSTEM=' $V_CONF/vesta.conf | cut -f 2 -d \' ) -proxy_system=$(grep 'PROXY_SYSTEM=' $V_CONF/vesta.conf | cut -f 2 -d \' ) - -# Checking values -if [ "$web_system" = 'apache' ]; then +# Checking system +if [ "$WEB_SYSTEM" = 'apache' ]; then apache fi -if [ "$proxy_system" = 'nginx' ]; then +if [ "$PROXY_SYSTEM" = 'nginx' ]; then nginx fi diff --git a/bin/v_suspend_web_domain b/bin/v_suspend_web_domain index 4ab997d9..e3c042d9 100755 --- a/bin/v_suspend_web_domain +++ b/bin/v_suspend_web_domain @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -46,47 +47,41 @@ is_domain_suspended 'web' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" - -# Defining config +# Parsing domain values +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" +SUSPEND='yes' -# Defining search phrase -search_phrase='DocumentRoot ' +# Preparing domain values for the template substitution +upd_web_domain_values -# Defining replace string -str_repl=" Redirect / http://$url" +# Recreating vhost +del_web_config +add_web_config -# Suspending vhost -change_web_config - -# Check ssl vhost -cert=$(get_web_domain_value '$SSL_CERT') -if [ ! -z "$cert" ]; then - tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" +# Check ssl +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" - str_repl=" Redirect / http://$url" - change_web_config + del_web_config + add_web_config fi -# Check nginx vhost -nginx=$(get_web_domain_value '$NGINX') -if [ ! -z "$nginx" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl" +# Checking 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 + del_web_config + add_web_config -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 + if [ ! -z "$SSL_CERT" ]; then + proxy_string="rewrite ^(.*)\$ http://$url;" + tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$V_HOME/$user/conf/snginx.conf" + del_web_config + add_web_config + fi fi diff --git a/bin/v_suspend_web_domains b/bin/v_suspend_web_domains index 2fb34e93..7a2a81ea 100755 --- a/bin/v_suspend_web_domains +++ b/bin/v_suspend_web_domains @@ -10,6 +10,7 @@ user=$1 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -43,71 +44,12 @@ conf="$V_USERS/$user/web.conf" # Defining fileds to select field='$DOMAIN' - -# Defining search string search_string="SUSPEND='no'" - -# Parsing unsuspeneded domains domains=$(dom_clear_search) # Starting suspend loop for domain in $domains; do - - 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' - + $V_BIN/v_suspend_web_domain "$user" "$domain" "$url" done @@ -115,9 +57,6 @@ done # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'web' - # Logging log_event 'system' "$V_EVENT" diff --git a/bin/v_unsuspend_web_domain b/bin/v_unsuspend_web_domain index 769f96ee..db43bddd 100755 --- a/bin/v_unsuspend_web_domain +++ b/bin/v_unsuspend_web_domain @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -43,64 +44,43 @@ is_domain_unsuspended 'web' # Action # #----------------------------------------------------------# -# Get template name -tpl_name=$(get_web_domain_value '$TPL') -tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - -# Defining config +# Parsing domain values +get_web_domain_values +tpl_file="$V_WEBTPL/apache_$TPL.tpl" conf="$V_HOME/$user/conf/httpd.conf" +SUSPEND='no' -# Defining search phrase -search_phrase='Redirect / ' +# Preparing domain values for the template substitution +upd_web_domain_values -# Defining replace string -str_repl=" DocumentRoot $V_HOME/$user/web/$domain/public_html" +# Recreating vhost +del_web_config +add_web_config -# 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_option=$(get_web_domain_value '$SSL_HOME') - - # Defining config +# Check ssl +if [ ! -z "$SSL_CERT" ]; then + tpl_file="$V_WEBTPL/apache_$TPL.stpl" conf="$V_HOME/$user/conf/shttpd.conf" - - # Switching on option - 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 + del_web_config + add_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" +# Checking nginx +if [ ! -z "$NGINX" ]; then + 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 + 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 -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 # diff --git a/bin/v_unsuspend_web_domains b/bin/v_unsuspend_web_domains index 8ff75d74..0597de0b 100755 --- a/bin/v_unsuspend_web_domains +++ b/bin/v_unsuspend_web_domains @@ -10,6 +10,7 @@ user=$1 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -35,84 +36,15 @@ is_user_valid # Action # #----------------------------------------------------------# -# Defining config -conf="$V_USERS/$user/web.conf" - # Defining fileds to select +conf="$V_USERS/$user/web.conf" field='$DOMAIN' - -# Defining search string search_string="SUSPEND='yes'" - -# Parsing suspeneded domains domains=$(dom_clear_search) # Starting unsuspend loop for domain in $domains; do - - 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' + $V_BIN/v_unsuspend_web_domain "$user" "$domain" done @@ -120,9 +52,6 @@ done # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'web' - # Logging log_event 'system' "$V_EVENT" diff --git a/bin/v_upd_web_domain_disk b/bin/v_upd_web_domain_disk index 9de9b649..7beaa5e6 100755 --- a/bin/v_upd_web_domain_disk +++ b/bin/v_upd_web_domain_disk @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func diff --git a/bin/v_upd_web_domain_stat b/bin/v_upd_web_domain_stat index 974778fd..fe7c2c36 100755 --- a/bin/v_upd_web_domain_stat +++ b/bin/v_upd_web_domain_stat @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func diff --git a/bin/v_upd_web_domain_traff b/bin/v_upd_web_domain_traff index 82523d80..750a47c8 100755 --- a/bin/v_upd_web_domain_traff +++ b/bin/v_upd_web_domain_traff @@ -12,6 +12,7 @@ domain_idn=$(idn -t --quiet -a "$domain") # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func diff --git a/bin/v_upd_web_domains_disk b/bin/v_upd_web_domains_disk index 79ba5033..ceff8bd4 100755 --- a/bin/v_upd_web_domains_disk +++ b/bin/v_upd_web_domains_disk @@ -10,6 +10,7 @@ user=$1 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -40,11 +41,7 @@ conf="$V_USERS/$user/web.conf" # Defining fileds to select field='$DOMAIN' - -# Defining search string search_string="SUSPEND='no'" - -# Parsing unsuspeneded domains domains=$(dom_clear_search) # Starting update disk loop diff --git a/bin/v_upd_web_domains_stat b/bin/v_upd_web_domains_stat index a27a95dd..d9ed1433 100755 --- a/bin/v_upd_web_domains_stat +++ b/bin/v_upd_web_domains_stat @@ -10,6 +10,7 @@ user=$1 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func @@ -35,13 +36,9 @@ is_user_valid # Action # #----------------------------------------------------------# -# Defining config -conf="$V_USERS/$user/web.conf" - # Defining fileds to select field='$DOMAIN' - -# Defining search string +conf="$V_USERS/$user/web.conf" search_string="SUSPEND='no'" # Parsing domain list @@ -60,6 +57,7 @@ for domain in $domains; do fi done + #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# diff --git a/bin/v_upd_web_domains_traff b/bin/v_upd_web_domains_traff index a49b39a3..3cc642bf 100755 --- a/bin/v_upd_web_domains_traff +++ b/bin/v_upd_web_domains_traff @@ -10,6 +10,7 @@ user=$1 # Importing variables source $VESTA/conf/vars.conf +source $V_CONF/vesta.conf source $V_FUNC/shared.func source $V_FUNC/domain.func diff --git a/func/cert.func b/func/cert.func index f89e5467..0037748d 100644 --- a/func/cert.func +++ b/func/cert.func @@ -14,14 +14,14 @@ is_cert_valid() { path="$1" # 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" log_event 'debug' "$E_CERT_NOTEXIST $V_EVENT" exit $E_CERT_NOTEXIST fi # 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 echo "Error: certificate invalid" log_event 'debug' "$E_CERT_INVALID $V_EVENT" @@ -29,7 +29,7 @@ is_cert_valid() { fi # 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') if [ -z "$key" ]; then echo "Error: key invalid" @@ -39,7 +39,7 @@ is_cert_valid() { # FIXME we should run server on free port # 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 & # Defining pid @@ -65,7 +65,7 @@ is_cert_valid() { is_cert_used() { # 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 if [ ! -z "$check_cert" ]; then diff --git a/func/domain.func b/func/domain.func index 87249bf0..2e7f51b5 100644 --- a/func/domain.func +++ b/func/domain.func @@ -223,23 +223,28 @@ add_web_config() { # Adding template to config cat $tpl_file | \ sed -e "s/%ip%/$ip/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/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_string%/${proxy_string////\/}/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%/$domain/g" \ -e "s/%user%/$user/g" \ -e "s/%group%/$group/g" \ -e "s/%home%/${V_HOME////\/}/g" \ -e "s/%docroot%/${docroot////\/}/g" \ + -e "s/%docroot_string%/${docroot_string////\/}/g" \ -e "s/%email%/$email/g" \ + -e "s/%alias_string%/$alias_string/g" \ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ -e "s/%alias%/${aliases//,/ }/g" \ -e "s/%ssl_cert%/${ssl_cert////\/}/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/%cgi%/$cgi/g" \ + -e "s/%cgi_option%/$cgi_option/g" \ >> $conf } @@ -260,6 +265,13 @@ get_web_config_brds() { str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :) top_line=$((str - serv_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() { @@ -286,6 +298,25 @@ change_web_config() { 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() { key="$1" @@ -304,6 +335,16 @@ get_web_domain_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() { key="$1" @@ -406,6 +447,17 @@ is_web_domain_key_empty() { 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() { # Checking record id check_id=$(grep "^ID='$id'" $V_USERS/$user/zones/$domain) @@ -610,3 +662,82 @@ namehost_ip_disable() { web_restart='yes' 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 +} + diff --git a/func/ip.func b/func/ip.func index ace664b8..b4ba4d74 100644 --- a/func/ip.func +++ b/func/ip.func @@ -117,6 +117,7 @@ is_ip_avalable() { is_sys_ip_owner() { # Parsing ip + ip="$IP" ip_owner=$(grep 'OWNER=' $V_IPS/$ip|cut -f 2 -d \') if [ "$ip_owner" != "$user" ]; then echo "Error: IP not owned" @@ -131,13 +132,14 @@ get_ip_name() { } increase_ip_value() { + sip=${1-ip} USER=$user web_key='U_WEB_DOMAINS' usr_key='U_SYS_USERS' # Parsing values - current_web=$(grep "$web_key=" $V_IPS/$ip |cut -f 2 -d \') - current_usr=$(grep "$usr_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/$sip |cut -f 2 -d \') # Checking result if [ -z "$current_web" ]; then @@ -221,40 +223,6 @@ get_sys_ip_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 '> $V_LOG/$level.log fi fi - } # Log user history @@ -24,8 +20,7 @@ log_history() { undo="$2" # 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 fi } @@ -328,7 +323,7 @@ format_validation() { dom_alias) format_dom "$v" ;; auth_pass) format_pwd "$v" ;; auth_user) format_usr "$v" ;; - certificate) format_usr "$v" ;; + ssl) format_usr "$v" ;; domain) format_dom "$v" ;; database) format_db "$v" ;; db_user) format_dbu "$v" ;; @@ -376,11 +371,7 @@ is_system_enabled() { stype="$1" web_function() { - # Parsing config - web_system=$(grep "WEB_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' ) - - # Checking result - if [ -z "$web_system" ] || [ "$web_system" = "no" ]; then + if [ -z "$WEB_SYSTEM" ] || [ "$WEB_SYSTEM" = "no" ]; then echo "Error: web hosting support disabled" log_event 'debug' "$E_WEB_DISABLED $V_EVENT" exit $E_WEB_DISABLED @@ -388,11 +379,7 @@ is_system_enabled() { } proxy_function() { - # Parsing config - proxy_system=$(grep "PROXY_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' ) - - # Checking result - if [ "$proxy_system" != 'nginx' ]; then # only nginx + if [ "$PROXY_SYSTEM" != 'nginx' ]; then # only nginx echo "Error: proxy hosting support disabled" # support for log_event 'debug' "$E_PROXY_DISABLED $V_EVENT" # now exit $E_PROXY_DISABLED @@ -400,11 +387,7 @@ is_system_enabled() { } dns_function() { - # Parsing config - dns_system=$(grep "DNS_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' ) - - # Checking result - if [ -z "$dns_system" ] || [ "$cron_system" = "no" ]; then + if [ -z "$DNS_SYSTEM" ] || [ "$DNS_SYSTEM" = "no" ]; then echo "Error: dns support disabled" log_event 'debug' "$E_DNS_DISABLED $V_EVENT" exit $E_DNS_DISABLED @@ -412,11 +395,7 @@ is_system_enabled() { } cron_function() { - # Parsing config - cron_system=$(grep "CRON_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' ) - - # Checking result - if [ -z "$cron_system" ] || [ "$cron_system" = "no" ]; then + if [ -z "$CRON_SYSTEM" ] || [ "$CRON_SYSTEM" = "no" ]; then echo "Error: crond support disabled" log_event 'debug' "$E_CRON_DISABLED $V_EVENT" exit $E_CRON_DISABLED @@ -424,11 +403,7 @@ is_system_enabled() { } db_function() { - # Parsing config - db_system=$(grep "DB_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' ) - - # Checking result - if [ -z "$db_system" ] || [ "$db_system" = "no" ]; then + if [ -z "$DB_SYSTEM" ] || [ "$DB_SYSTEM" = "no" ]; then echo "Error: db support disabled" log_event 'debug' "$E_DB_DISABLED $V_EVENT" exit $E_DB_DISABLED @@ -436,11 +411,7 @@ is_system_enabled() { } backup_function() { - # Parsing config - bck_system=$(grep "BACKUP_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' ) - - # Checking result - if [ -z "$bck_system" ] || [ "$bck_system" = "no" ]; then + if [ -z "$BACKUP_SYSTEM" ] || [ "$BACKUP_SYSTEM" = "no" ]; then echo "Error: backup support disabled" log_event 'debug' "$E_BACKUP_DISABLED $V_EVENT" exit $E_BACKUP_DISABLED @@ -803,16 +774,6 @@ increase_user_value() { 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() { # Argument defenition sys="$1" @@ -965,9 +926,9 @@ json_list() { # Printing child if [ $i -lt $fileds_count ]; then (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + echo -e "\t\t\"${field//$/}\": \"$value\"," else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + echo -e "\t\t\"${field//$/}\": \"$value\"" data=1 fi fi