moved web/proxy port values to global config

This commit is contained in:
Serghey Rodin 2011-06-26 14:16:59 +03:00
commit e11a13c16c
7 changed files with 29 additions and 37 deletions

View file

@ -81,7 +81,7 @@ else
fi
# Defining vars for httpd_add_config function
port=$(get_web_port)
port=$(get_config_value '$WEB_PORT')
group="$user"
email="$user@$domain"
docroot="$V_HOME/$user/domains/$domain/public_html"

View file

@ -68,7 +68,7 @@ is_template_valid 'web'
#----------------------------------------------------------#
# Defining variables for template replace
port=$(get_web_port_ssl)
port=$(get_config_value '$WEB_SSL_PORT')
aliases=$(get_web_domain_value '$ALIAS')
aliases_idn=$(idn -t --quiet -a "$aliases")
email="$user@$domain"

View file

@ -73,7 +73,7 @@ fi
# Defining variables for template replace
ip=$(get_web_domain_value '$IP')
aliases=$(get_web_domain_value '$ALIAS')
port=$(get_web_port)
port=$(get_config_value '$WEB_PORT')
email="$user@$domain"
docroot="$V_HOME/$user/domains/$domain/public_html"
conf="$V_HOME/$user/conf/httpd.conf"
@ -91,7 +91,7 @@ fi
# Checking ssl
if [ "$ssl" = 'yes' ]; then
# Defining variables for ssl template replace
port=$(get_web_port_ssl)
port=$(get_config_value '$WEB_SSL_PORT')
tpl_option=$(get_web_domain_value '$SSL_HOME')
cert=$(get_web_domain_value '$SSL_CERT')
ssl_cert="$V_HOME/$user/conf/$cert.crt"

View file

@ -58,7 +58,7 @@ for domain in $domains; do
template=$(get_web_domain_value '$TPL')
tpl_file="$V_WEBTPL/apache_$template.tpl"
ip=$(get_web_domain_value '$IP')
port=$(get_web_port)
port=$(get_config_value '$WEB_PORT')
domain=$(get_web_domain_value '$DOMAIN')
domain_idn=$(idn -t --quiet -a "$domain")
group="$user"
@ -89,6 +89,7 @@ for domain in $domains; do
same) docroot="$V_HOME/$user/domains/$domain/public_html" ;;
*) check_args '3' "$#" 'user domain certificate [sslhome]'
esac
port=$(get_config_value '$WEB_SSL_PORT')
# Adding domain to the httpd.conf
conf="$V_HOME/$user/conf/tmp_shttpd.conf"

View file

@ -1,6 +1,10 @@
WEB_SYSTEM='apache'
WEB_SSL='mod_ssl'
WEB_PORT='8080'
WEB_SSL_PORT='8443'
PROXY_SYSTEM='nginx'
PROXY_PORT='80'
PROXY_SSL_PORT='443'
FTP_SYSTEM='vsftpd'
MAIL_SYSTEM=''
DB_SYSTEM='mysql'

View file

@ -219,37 +219,6 @@ sort_dns_records() {
mv -f $conf.tmp $conf
}
get_web_port() {
proxy_disabled='80'
proxy_enabled='8080'
# Parsing conf
proxy=$(grep 'PROXY_SYSTEM=' $V_CONF/vesta.conf|cut -f 2 -d \')
# Checking result
if [ -z "$proxy" ] || [ "$proxy" = 'off' ]; then
echo "$proxy_disabled"
else
echo "$proxy_enabled"
fi
}
get_web_port_ssl() {
proxy_disabled='443'
proxy_enabled='8443'
# Parsing conf
proxy=$(grep 'PROXY_SYSTEM=' $V_CONF/vesta.conf|cut -f 2 -d \')
# Checking result
if [ -z "$proxy" ] || [ "$proxy" = 'off' ]; then
echo "$proxy_disabled"
else
echo "$proxy_enabled"
fi
}
httpd_add_config() {
# Adding template to config
cat $tpl_file | \
@ -266,6 +235,7 @@ httpd_add_config() {
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%ssl_cert%/${ssl_cert////\/}/g" \
-e "s/%ssl_key%/${ssl_key////\/}/g" \
-e "s/%extentions%/$extentions/g" \
>> $conf
}

View file

@ -592,7 +592,7 @@ is_template_valid() {
proxy_template() {
tpl="$V_WEBTPL/ngingx_vhost_$template.tpl"
descr="$V_WEBTPL/ngingx_vhost_$template.descr"
ssl="$V_WEBTPL/ngingx_vhost_$template.ssl.tpl"
ssl="$V_WEBTPL/ngingx_vhost_$template.stpl"
if [ ! -e $tpl ] || [ ! -e $descr ] || [ ! -e $ssl ]; then
echo "Error: template not found"
@ -1334,3 +1334,20 @@ pkg_shell_list() {
i=$(($i + 1))
done
}
get_config_value() {
key="$1"
# Parsing config
string=$(cat $V_CONF/vesta.conf)
# Parsing key=value
for keys in $string; do
eval ${keys%%=*}=${keys#*=}
done
# Self reference
eval value="$key"
# Print value
echo "$value"
}