diff --git a/bin/v_add_web_domain_alias b/bin/v_add_web_domain_alias index 7c0a272c..10f65c0c 100755 --- a/bin/v_add_web_domain_alias +++ b/bin/v_add_web_domain_alias @@ -62,14 +62,10 @@ is_package_full 'web_alias' # Action # #----------------------------------------------------------# -# Get template name +# Defining params for change function 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='ServerAlias' # Defining new alias string @@ -86,20 +82,16 @@ fi str_repl=" ServerAlias ${new_alias_idn//,/ }" # Adding alias -httpd_change_config +change_web_config # Checking ssl domain cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$cert" ]; then - # Defining ssl template + # Defining params for change function tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - - # Defining ssl config conf="$V_HOME/$user/conf/shttpd.conf" - - # Adding alias - httpd_change_config + change_web_config fi diff --git a/bin/v_add_web_domain_cgi b/bin/v_add_web_domain_cgi index 1b740581..ccd99be2 100755 --- a/bin/v_add_web_domain_cgi +++ b/bin/v_add_web_domain_cgi @@ -1,5 +1,5 @@ #!/bin/bash -# info: adding cgi for domain +# info: adding cgi support for domain #----------------------------------------------------------# # Variable&Function # @@ -53,55 +53,32 @@ is_web_domain_key_empty '$CGI' tpl_name=$(get_web_domain_value '$TPL') tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" -# Defining config +# Defining params for ScriptAlias conf="$V_HOME/$user/conf/httpd.conf" - -# Defining search phrase search_phrase='ScriptAlias ' - -# Defining replace string str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin/" +change_web_config -# Adding cgi-bin support -httpd_change_config - -# Defining search phrase +# Defining params for Options search_phrase='Options ' - -# Defining replace string str_repl=' Options +Includes -Indexes +ExecCGI' - -# Adding execscgi support -httpd_change_config +change_web_config # Checking ssl cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$cert" ]; then - # Get ssl template name + # Defining params for ScriptAlias tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - - # Defining ssl config conf="$V_HOME/$user/conf/shttpd.conf" - - # Defining search phrase search_phrase='ScriptAlias ' - - # Defining replace string str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin/" + change_web_config - # Adding cgi-bin support - httpd_change_config - - # Defining search phrase + # Defining params for Options search_phrase='Options ' - - # Defining replace string str_repl=' Options +Includes -Indexes +ExecCGI' - - # Adding execscgi support - httpd_change_config - + change_web_config fi diff --git a/bin/v_add_web_domain_elog b/bin/v_add_web_domain_elog index 61fc8081..e4a30ffc 100755 --- a/bin/v_add_web_domain_elog +++ b/bin/v_add_web_domain_elog @@ -63,7 +63,7 @@ search_phrase='ErrorLog ' str_repl=" ErrorLog /var/log/httpd/domains/$domain.error.log" # Adding errolog support -httpd_change_config +change_web_config # Checking ssl cert=$(get_web_domain_value '$SSL_CERT') @@ -76,7 +76,7 @@ if [ ! -z "$cert" ]; then conf="$V_HOME/$user/conf/shttpd.conf" # Adding errolog support - httpd_change_config + change_web_config fi diff --git a/bin/v_change_web_domain_sslcert b/bin/v_change_web_domain_sslcert index a19a3275..26b12a96 100755 --- a/bin/v_change_web_domain_sslcert +++ b/bin/v_change_web_domain_sslcert @@ -71,7 +71,7 @@ search_phrase='SSLCertificateFile' str_repl=" SSLCertificateFile $ssl_cert" # Changing sslhome -httpd_change_config +change_web_config # Defining search phrase search_phrase='SSLCertificateKeyFile' @@ -80,7 +80,7 @@ search_phrase='SSLCertificateKeyFile' str_repl=" SSLCertificateKeyFile $ssl_key" # Changing sslhome -httpd_change_config +change_web_config # Adding certificate to user dir if [ ! -e "$ssl_cert" ]; then diff --git a/bin/v_change_web_domain_sslhome b/bin/v_change_web_domain_sslhome index a5b3dce4..da11cc28 100755 --- a/bin/v_change_web_domain_sslhome +++ b/bin/v_change_web_domain_sslhome @@ -71,7 +71,7 @@ esac str_repl=" DocumentRoot $docroot" # Changing sslhome -httpd_change_config +change_web_config # Get old sslhome value ssl_home=$(get_web_domain_value '$SSL_HOME') @@ -90,7 +90,7 @@ search_phrase="" str_repl=" " # Changing sslhome directory tag -httpd_change_config +change_web_config #----------------------------------------------------------# diff --git a/bin/v_del_web_domain_alias b/bin/v_del_web_domain_alias index f2738593..58271017 100755 --- a/bin/v_del_web_domain_alias +++ b/bin/v_del_web_domain_alias @@ -58,45 +58,34 @@ fi # Defining new alias string new_alias=$(echo "$cur_alias" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$dom_alias$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') + 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') + sed -e "s/,/\n/g"|\ + sed -e "s/^$dom_alias$//g"|\ + sed -e "/^$/d"|\ + sed -e ':a;N;$!ba;s/\n/,/g') -# 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='ServerAlias' - -# Defining replace string str_repl=" ServerAlias ${new_alias_idn//,/ }" # Deleting alias -httpd_change_config +change_web_config -# Checking ssl domain +# Checking ssl cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$cert" ]; then - # Defining ssl template + # Defining ssl options tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - - # Defining ssl config conf="$V_HOME/$user/conf/shttpd.conf" - - # Deleting ssl alias - httpd_change_config + change_web_config fi diff --git a/bin/v_del_web_domain_cgi b/bin/v_del_web_domain_cgi index 47a9d869..80337fe8 100755 --- a/bin/v_del_web_domain_cgi +++ b/bin/v_del_web_domain_cgi @@ -53,55 +53,32 @@ is_web_domain_value_exist '$CGI' tpl_name=$(get_web_domain_value '$TPL') tpl_file="$V_WEBTPL/apache_$tpl_name.tpl" -# Defining config +# Defining params for ScriptAlias conf="$V_HOME/$user/conf/httpd.conf" - -# Defining search phrase search_phrase='ScriptAlias ' - -# Defining replace string str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin" +change_web_config -# Deleting cgi-bin support -httpd_change_config - -# Defining search phrase +# Defining params for Options search_phrase='Options ' - -# Defining replace string str_repl=' Options +Includes -Indexes -ExecCGI' - -# Deleting execscgi support -httpd_change_config +change_web_config # Checking ssl cert=$(get_web_domain_value '$SSL_CERT') if [ ! -z "$cert" ]; then - # Get ssl template name + # Defining params for ScriptAlias tpl_file="$V_WEBTPL/apache_$tpl_name.stpl" - - # Defining ssl config conf="$V_HOME/$user/conf/shttpd.conf" - - # Defining search phrase search_phrase='ScriptAlias ' - - # Defining replace string str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin" + change_web_config - # Deleting cgi-bin support - httpd_change_config - - # Defining search phrase + # Defining params for Options search_phrase='Options ' - - # Defining replace string str_repl=' Options +Includes -Indexes -ExecCGI' - - # Deleting execscgi support - httpd_change_config - + change_web_config fi diff --git a/bin/v_del_web_domain_elog b/bin/v_del_web_domain_elog index a4121579..0f6a4656 100755 --- a/bin/v_del_web_domain_elog +++ b/bin/v_del_web_domain_elog @@ -63,7 +63,7 @@ search_phrase='ErrorLog ' str_repl=" #ErrorLog /var/log/httpd/domains/$domain.error.log" # Deleting errolog support -httpd_change_config +change_web_config # Checking ssl cert=$(get_web_domain_value '$SSL_CERT') @@ -76,7 +76,7 @@ if [ ! -z "$cert" ]; then conf="$V_HOME/$user/conf/shttpd.conf" # Deleting errolog support - httpd_change_config + change_web_config fi diff --git a/bin/v_suspend_web_domain b/bin/v_suspend_web_domain index 326ad9ea..35e927f2 100755 --- a/bin/v_suspend_web_domain +++ b/bin/v_suspend_web_domain @@ -60,7 +60,7 @@ search_phrase='DocumentRoot ' str_repl=" Redirect / http://$url/" # Suspending vhost -httpd_change_config +change_web_config # Check ssl vhost cert=$(get_web_domain_value '$SSL_CERT') @@ -75,7 +75,7 @@ if [ ! -z "$cert" ]; then str_repl=" Redirect / http://$url/" # Suspending vhost - httpd_change_config + change_web_config fi diff --git a/bin/v_suspend_web_domains b/bin/v_suspend_web_domains index b154b6db..e84690c8 100755 --- a/bin/v_suspend_web_domains +++ b/bin/v_suspend_web_domains @@ -67,7 +67,7 @@ for domain in $domains; do str_repl=" Redirect / http://$url/" # Suspending vhost - httpd_change_config + change_web_config # Check ssl vhost cert=$(get_web_domain_value '$SSL_CERT') @@ -82,7 +82,7 @@ for domain in $domains; do str_repl=" Redirect / http://$url/" # Suspending vhost - httpd_change_config + change_web_config fi # Adding suspend in config diff --git a/bin/v_unsuspend_web_domain b/bin/v_unsuspend_web_domain index 93f44c57..a820ee28 100755 --- a/bin/v_unsuspend_web_domain +++ b/bin/v_unsuspend_web_domain @@ -57,7 +57,7 @@ search_phrase='Redirect / ' str_repl=" DocumentRoot $V_HOME/$user/domains/$domain/public_html" # Unsuspending vhost -httpd_change_config +change_web_config # Check ssl vhost cert=$(get_web_domain_value '$SSL_CERT') @@ -79,7 +79,7 @@ if [ ! -z "$cert" ]; then str_repl=" DocumentRoot $docroot" # Unsuspending vhost - httpd_change_config + change_web_config fi diff --git a/bin/v_unsuspend_web_domains b/bin/v_unsuspend_web_domains index e318160c..ac9d0668 100755 --- a/bin/v_unsuspend_web_domains +++ b/bin/v_unsuspend_web_domains @@ -64,7 +64,7 @@ for domain in $domains; do str_repl=" DocumentRoot $V_HOME/$user/domains/$domain/public_html" # Unsuspending vhost - httpd_change_config + change_web_config # Check ssl vhost cert=$(get_web_domain_value '$SSL_CERT') @@ -86,7 +86,7 @@ for domain in $domains; do str_repl=" DocumentRoot $docroot" # Unsuspending vhost - httpd_change_config + change_web_config fi # Adding unsuspend in config diff --git a/func/domain_func.sh b/func/domain_func.sh index e3993e28..e930479a 100644 --- a/func/domain_func.sh +++ b/func/domain_func.sh @@ -243,28 +243,20 @@ add_web_config() { >> $conf } -httpd_change_config() { - # Get ServerName line - serv_line=$(grep -n 'ServerName %domain_idn%' "$tpl_file" | cut -f 1 -d :) - - # Get tpl_file last line +change_web_config() { + # Defining template borders + serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :) last_line=$(wc -l $tpl_file | cut -f 1 -d ' ') - - # Get before line bfr_line=$((serv_line - 1)) - - # Get after line aftr_line=$((last_line - serv_line - 1)) - # Parsing httpd.conf - vhost=$(grep -A $aftr_line -B $bfr_line -n "ServerName $domain_idn" $conf) - - # Searching prhase + # Parsing config + vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf) str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1) # Checking parsing result if [ -z "$str" ] || [ -z "$serv_line" ] || [ -z "$aftr_line" ]; then - echo "Error: httpd parsing error" + echo "Error: config parsing error" log_event 'debug' "$E_PARSE_ERROR $V_EVENT" exit $E_PARSE_ERROR fi