From 9b5caa198caef2d9dcf71626aad1bc166bfcbf8a Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 22 Jun 2011 00:43:30 +0300 Subject: [PATCH] added https support --- bin/v_rebuild_web_domains | 44 +++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/bin/v_rebuild_web_domains b/bin/v_rebuild_web_domains index 58afeba80..391666ee9 100755 --- a/bin/v_rebuild_web_domains +++ b/bin/v_rebuild_web_domains @@ -67,22 +67,43 @@ for domain in $domains; do aliases=$(get_web_domain_value '$ALIAS') aliases_idn=$(idn -t --quiet -a "$aliases") - #ssl_cert=$() - #ssl_key=$() - # Adding domain to the tmp_httpd.conf conf="$V_HOME/$user/conf/tmp_httpd.conf" httpd_add_config # Running template trigger - if [ -e $V_WEBTPL/apache_$template.sh ]; then + if [ -x $V_WEBTPL/apache_$template.sh ]; then $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot $port fi + # Checking ssl + ssl=$(get_web_domain_value '$SSL') + if [ "$ssl" = 'yes' ]; then + # Parsing certificate params + cert=$(get_web_domain_value '$SSL_CERT') + 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/domains/$domain/public_shtml" ;; + same) docroot="$V_HOME/$user/domains/$domain/public_html" ;; + *) check_args '3' "$#" 'user domain certificate [sslhome]' + esac + + # Adding domain to the httpd.conf + conf="$V_HOME/$user/conf/tmp_shttpd.conf" + tpl_file="$V_WEBTPL/apache_$template.stpl" + httpd_add_config + + if [ -x $V_WEBTPL/apache_$template.sh ]; then + $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME \ + $docroot $port + fi + fi done # Renaming tmp config -tmp_conf="$conf" +tmp_conf="$V_HOME/$user/conf/tmp_httpd.conf" conf="$V_HOME/$user/conf/httpd.conf" mv $tmp_conf $conf @@ -93,7 +114,18 @@ if [ -z "$main_conf_check" ]; then echo "Include $conf" >>$main_conf fi -exit +# Checking ssl +if [ ! -z "$ssl_cert" ]; then + tmp_conf="$V_HOME/$user/conf/tmp_shttpd.conf" + conf="$V_HOME/$user/conf/shttpd.conf" + mv $tmp_conf $conf + + # Checking include in main httpd.conf + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf + fi +fi #----------------------------------------------------------#