mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
addopted httpd_change_config for nginx and renamed it
This commit is contained in:
parent
30512ea575
commit
c5a7bdc8d5
13 changed files with 55 additions and 128 deletions
|
@ -62,14 +62,10 @@ is_package_full 'web_alias'
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Get template name
|
# Defining params for change function
|
||||||
tpl_name=$(get_web_domain_value '$TPL')
|
tpl_name=$(get_web_domain_value '$TPL')
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
||||||
|
|
||||||
# Defining config
|
|
||||||
conf="$V_HOME/$user/conf/httpd.conf"
|
conf="$V_HOME/$user/conf/httpd.conf"
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='ServerAlias'
|
search_phrase='ServerAlias'
|
||||||
|
|
||||||
# Defining new alias string
|
# Defining new alias string
|
||||||
|
@ -86,20 +82,16 @@ fi
|
||||||
str_repl=" ServerAlias ${new_alias_idn//,/ }"
|
str_repl=" ServerAlias ${new_alias_idn//,/ }"
|
||||||
|
|
||||||
# Adding alias
|
# Adding alias
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Checking ssl domain
|
# Checking ssl domain
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
if [ ! -z "$cert" ]; then
|
if [ ! -z "$cert" ]; then
|
||||||
|
|
||||||
# Defining ssl template
|
# Defining params for change function
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
|
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"
|
||||||
|
change_web_config
|
||||||
# Adding alias
|
|
||||||
httpd_change_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: adding cgi for domain
|
# info: adding cgi support for domain
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
|
@ -53,55 +53,32 @@ is_web_domain_key_empty '$CGI'
|
||||||
tpl_name=$(get_web_domain_value '$TPL')
|
tpl_name=$(get_web_domain_value '$TPL')
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
||||||
|
|
||||||
# Defining config
|
# Defining params for ScriptAlias
|
||||||
conf="$V_HOME/$user/conf/httpd.conf"
|
conf="$V_HOME/$user/conf/httpd.conf"
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='ScriptAlias '
|
search_phrase='ScriptAlias '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin/"
|
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin/"
|
||||||
|
change_web_config
|
||||||
|
|
||||||
# Adding cgi-bin support
|
# Defining params for Options
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='Options '
|
search_phrase='Options '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=' Options +Includes -Indexes +ExecCGI'
|
str_repl=' Options +Includes -Indexes +ExecCGI'
|
||||||
|
change_web_config
|
||||||
# Adding execscgi support
|
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
# Checking ssl
|
# Checking ssl
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
if [ ! -z "$cert" ]; then
|
if [ ! -z "$cert" ]; then
|
||||||
|
|
||||||
# Get ssl template name
|
# Defining params for ScriptAlias
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
|
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"
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='ScriptAlias '
|
search_phrase='ScriptAlias '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin/"
|
str_repl=" ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin/"
|
||||||
|
change_web_config
|
||||||
|
|
||||||
# Adding cgi-bin support
|
# Defining params for Options
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='Options '
|
search_phrase='Options '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=' Options +Includes -Indexes +ExecCGI'
|
str_repl=' Options +Includes -Indexes +ExecCGI'
|
||||||
|
change_web_config
|
||||||
# Adding execscgi support
|
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ search_phrase='ErrorLog '
|
||||||
str_repl=" ErrorLog /var/log/httpd/domains/$domain.error.log"
|
str_repl=" ErrorLog /var/log/httpd/domains/$domain.error.log"
|
||||||
|
|
||||||
# Adding errolog support
|
# Adding errolog support
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Checking ssl
|
# Checking ssl
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
|
@ -76,7 +76,7 @@ if [ ! -z "$cert" ]; then
|
||||||
conf="$V_HOME/$user/conf/shttpd.conf"
|
conf="$V_HOME/$user/conf/shttpd.conf"
|
||||||
|
|
||||||
# Adding errolog support
|
# Adding errolog support
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ search_phrase='SSLCertificateFile'
|
||||||
str_repl=" SSLCertificateFile $ssl_cert"
|
str_repl=" SSLCertificateFile $ssl_cert"
|
||||||
|
|
||||||
# Changing sslhome
|
# Changing sslhome
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Defining search phrase
|
# Defining search phrase
|
||||||
search_phrase='SSLCertificateKeyFile'
|
search_phrase='SSLCertificateKeyFile'
|
||||||
|
@ -80,7 +80,7 @@ search_phrase='SSLCertificateKeyFile'
|
||||||
str_repl=" SSLCertificateKeyFile $ssl_key"
|
str_repl=" SSLCertificateKeyFile $ssl_key"
|
||||||
|
|
||||||
# Changing sslhome
|
# Changing sslhome
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Adding certificate to user dir
|
# Adding certificate to user dir
|
||||||
if [ ! -e "$ssl_cert" ]; then
|
if [ ! -e "$ssl_cert" ]; then
|
||||||
|
|
|
@ -71,7 +71,7 @@ esac
|
||||||
str_repl=" DocumentRoot $docroot"
|
str_repl=" DocumentRoot $docroot"
|
||||||
|
|
||||||
# Changing sslhome
|
# Changing sslhome
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Get old sslhome value
|
# Get old sslhome value
|
||||||
ssl_home=$(get_web_domain_value '$SSL_HOME')
|
ssl_home=$(get_web_domain_value '$SSL_HOME')
|
||||||
|
@ -90,7 +90,7 @@ search_phrase="<Directory $dirroot>"
|
||||||
str_repl=" <Directory $docroot>"
|
str_repl=" <Directory $docroot>"
|
||||||
|
|
||||||
# Changing sslhome directory tag
|
# Changing sslhome directory tag
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -69,34 +69,23 @@ new_alias_idn=$(idn -t --quiet -a "$cur_alias" |\
|
||||||
sed -e "/^$/d"|\
|
sed -e "/^$/d"|\
|
||||||
sed -e ':a;N;$!ba;s/\n/,/g')
|
sed -e ':a;N;$!ba;s/\n/,/g')
|
||||||
|
|
||||||
# Get template name
|
|
||||||
tpl_name=$(get_web_domain_value '$TPL')
|
tpl_name=$(get_web_domain_value '$TPL')
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
||||||
|
|
||||||
# Defining config
|
|
||||||
conf="$V_HOME/$user/conf/httpd.conf"
|
conf="$V_HOME/$user/conf/httpd.conf"
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='ServerAlias'
|
search_phrase='ServerAlias'
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=" ServerAlias ${new_alias_idn//,/ }"
|
str_repl=" ServerAlias ${new_alias_idn//,/ }"
|
||||||
|
|
||||||
# Deleting alias
|
# Deleting alias
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Checking ssl domain
|
# Checking ssl
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
if [ ! -z "$cert" ]; then
|
if [ ! -z "$cert" ]; then
|
||||||
|
|
||||||
# Defining ssl template
|
# Defining ssl options
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
|
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"
|
||||||
|
change_web_config
|
||||||
# Deleting ssl alias
|
|
||||||
httpd_change_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,55 +53,32 @@ is_web_domain_value_exist '$CGI'
|
||||||
tpl_name=$(get_web_domain_value '$TPL')
|
tpl_name=$(get_web_domain_value '$TPL')
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
|
||||||
|
|
||||||
# Defining config
|
# Defining params for ScriptAlias
|
||||||
conf="$V_HOME/$user/conf/httpd.conf"
|
conf="$V_HOME/$user/conf/httpd.conf"
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='ScriptAlias '
|
search_phrase='ScriptAlias '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin"
|
str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin"
|
||||||
|
change_web_config
|
||||||
|
|
||||||
# Deleting cgi-bin support
|
# Defining params for Options
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='Options '
|
search_phrase='Options '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=' Options +Includes -Indexes -ExecCGI'
|
str_repl=' Options +Includes -Indexes -ExecCGI'
|
||||||
|
change_web_config
|
||||||
# Deleting execscgi support
|
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
# Checking ssl
|
# Checking ssl
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
if [ ! -z "$cert" ]; then
|
if [ ! -z "$cert" ]; then
|
||||||
|
|
||||||
# Get ssl template name
|
# Defining params for ScriptAlias
|
||||||
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
|
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"
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='ScriptAlias '
|
search_phrase='ScriptAlias '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin"
|
str_repl=" #ScriptAlias /cgi-bin/ $V_HOME/$user/domains/$domain/cgi-bin"
|
||||||
|
change_web_config
|
||||||
|
|
||||||
# Deleting cgi-bin support
|
# Defining params for Options
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
# Defining search phrase
|
|
||||||
search_phrase='Options '
|
search_phrase='Options '
|
||||||
|
|
||||||
# Defining replace string
|
|
||||||
str_repl=' Options +Includes -Indexes -ExecCGI'
|
str_repl=' Options +Includes -Indexes -ExecCGI'
|
||||||
|
change_web_config
|
||||||
# Deleting execscgi support
|
|
||||||
httpd_change_config
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ search_phrase='ErrorLog '
|
||||||
str_repl=" #ErrorLog /var/log/httpd/domains/$domain.error.log"
|
str_repl=" #ErrorLog /var/log/httpd/domains/$domain.error.log"
|
||||||
|
|
||||||
# Deleting errolog support
|
# Deleting errolog support
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Checking ssl
|
# Checking ssl
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
|
@ -76,7 +76,7 @@ if [ ! -z "$cert" ]; then
|
||||||
conf="$V_HOME/$user/conf/shttpd.conf"
|
conf="$V_HOME/$user/conf/shttpd.conf"
|
||||||
|
|
||||||
# Deleting errolog support
|
# Deleting errolog support
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ search_phrase='DocumentRoot '
|
||||||
str_repl=" Redirect / http://$url/"
|
str_repl=" Redirect / http://$url/"
|
||||||
|
|
||||||
# Suspending vhost
|
# Suspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Check ssl vhost
|
# Check ssl vhost
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
|
@ -75,7 +75,7 @@ if [ ! -z "$cert" ]; then
|
||||||
str_repl=" Redirect / http://$url/"
|
str_repl=" Redirect / http://$url/"
|
||||||
|
|
||||||
# Suspending vhost
|
# Suspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ for domain in $domains; do
|
||||||
str_repl=" Redirect / http://$url/"
|
str_repl=" Redirect / http://$url/"
|
||||||
|
|
||||||
# Suspending vhost
|
# Suspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Check ssl vhost
|
# Check ssl vhost
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
|
@ -82,7 +82,7 @@ for domain in $domains; do
|
||||||
str_repl=" Redirect / http://$url/"
|
str_repl=" Redirect / http://$url/"
|
||||||
|
|
||||||
# Suspending vhost
|
# Suspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding suspend in config
|
# Adding suspend in config
|
||||||
|
|
|
@ -57,7 +57,7 @@ search_phrase='Redirect / '
|
||||||
str_repl=" DocumentRoot $V_HOME/$user/domains/$domain/public_html"
|
str_repl=" DocumentRoot $V_HOME/$user/domains/$domain/public_html"
|
||||||
|
|
||||||
# Unsuspending vhost
|
# Unsuspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Check ssl vhost
|
# Check ssl vhost
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
|
@ -79,7 +79,7 @@ if [ ! -z "$cert" ]; then
|
||||||
str_repl=" DocumentRoot $docroot"
|
str_repl=" DocumentRoot $docroot"
|
||||||
|
|
||||||
# Unsuspending vhost
|
# Unsuspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ for domain in $domains; do
|
||||||
str_repl=" DocumentRoot $V_HOME/$user/domains/$domain/public_html"
|
str_repl=" DocumentRoot $V_HOME/$user/domains/$domain/public_html"
|
||||||
|
|
||||||
# Unsuspending vhost
|
# Unsuspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
|
|
||||||
# Check ssl vhost
|
# Check ssl vhost
|
||||||
cert=$(get_web_domain_value '$SSL_CERT')
|
cert=$(get_web_domain_value '$SSL_CERT')
|
||||||
|
@ -86,7 +86,7 @@ for domain in $domains; do
|
||||||
str_repl=" DocumentRoot $docroot"
|
str_repl=" DocumentRoot $docroot"
|
||||||
|
|
||||||
# Unsuspending vhost
|
# Unsuspending vhost
|
||||||
httpd_change_config
|
change_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding unsuspend in config
|
# Adding unsuspend in config
|
||||||
|
|
|
@ -243,28 +243,20 @@ add_web_config() {
|
||||||
>> $conf
|
>> $conf
|
||||||
}
|
}
|
||||||
|
|
||||||
httpd_change_config() {
|
change_web_config() {
|
||||||
# Get ServerName line
|
# Defining template borders
|
||||||
serv_line=$(grep -n 'ServerName %domain_idn%' "$tpl_file" | cut -f 1 -d :)
|
serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
|
||||||
|
|
||||||
# Get tpl_file last line
|
|
||||||
last_line=$(wc -l $tpl_file | cut -f 1 -d ' ')
|
last_line=$(wc -l $tpl_file | cut -f 1 -d ' ')
|
||||||
|
|
||||||
# Get before line
|
|
||||||
bfr_line=$((serv_line - 1))
|
bfr_line=$((serv_line - 1))
|
||||||
|
|
||||||
# Get after line
|
|
||||||
aftr_line=$((last_line - serv_line - 1))
|
aftr_line=$((last_line - serv_line - 1))
|
||||||
|
|
||||||
# Parsing httpd.conf
|
# Parsing config
|
||||||
vhost=$(grep -A $aftr_line -B $bfr_line -n "ServerName $domain_idn" $conf)
|
vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
|
||||||
|
|
||||||
# Searching prhase
|
|
||||||
str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
|
str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
|
||||||
|
|
||||||
# Checking parsing result
|
# Checking parsing result
|
||||||
if [ -z "$str" ] || [ -z "$serv_line" ] || [ -z "$aftr_line" ]; then
|
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"
|
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
|
||||||
exit $E_PARSE_ERROR
|
exit $E_PARSE_ERROR
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue