Skip to content

Commit e11a13c

Browse files
committed
moved web/proxy port values to global config
1 parent 19beced commit e11a13c

File tree

7 files changed

+29
-37
lines changed

7 files changed

+29
-37
lines changed

bin/v_add_web_domain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ else
8181
fi
8282

8383
# Defining vars for httpd_add_config function
84-
port=$(get_web_port)
84+
port=$(get_config_value '$WEB_PORT')
8585
group="$user"
8686
email="$user@$domain"
8787
docroot="$V_HOME/$user/domains/$domain/public_html"

bin/v_add_web_domain_ssl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ is_template_valid 'web'
6868
#----------------------------------------------------------#
6969

7070
# Defining variables for template replace
71-
port=$(get_web_port_ssl)
71+
port=$(get_config_value '$WEB_SSL_PORT')
7272
aliases=$(get_web_domain_value '$ALIAS')
7373
aliases_idn=$(idn -t --quiet -a "$aliases")
7474
email="$user@$domain"

bin/v_change_web_domain_tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fi
7373
# Defining variables for template replace
7474
ip=$(get_web_domain_value '$IP')
7575
aliases=$(get_web_domain_value '$ALIAS')
76-
port=$(get_web_port)
76+
port=$(get_config_value '$WEB_PORT')
7777
email="$user@$domain"
7878
docroot="$V_HOME/$user/domains/$domain/public_html"
7979
conf="$V_HOME/$user/conf/httpd.conf"
@@ -91,7 +91,7 @@ fi
9191
# Checking ssl
9292
if [ "$ssl" = 'yes' ]; then
9393
# Defining variables for ssl template replace
94-
port=$(get_web_port_ssl)
94+
port=$(get_config_value '$WEB_SSL_PORT')
9595
tpl_option=$(get_web_domain_value '$SSL_HOME')
9696
cert=$(get_web_domain_value '$SSL_CERT')
9797
ssl_cert="$V_HOME/$user/conf/$cert.crt"

bin/v_rebuild_web_domains

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ for domain in $domains; do
5858
template=$(get_web_domain_value '$TPL')
5959
tpl_file="$V_WEBTPL/apache_$template.tpl"
6060
ip=$(get_web_domain_value '$IP')
61-
port=$(get_web_port)
61+
port=$(get_config_value '$WEB_PORT')
6262
domain=$(get_web_domain_value '$DOMAIN')
6363
domain_idn=$(idn -t --quiet -a "$domain")
6464
group="$user"
@@ -89,6 +89,7 @@ for domain in $domains; do
8989
same) docroot="$V_HOME/$user/domains/$domain/public_html" ;;
9090
*) check_args '3' "$#" 'user domain certificate [sslhome]'
9191
esac
92+
port=$(get_config_value '$WEB_SSL_PORT')
9293

9394
# Adding domain to the httpd.conf
9495
conf="$V_HOME/$user/conf/tmp_shttpd.conf"

conf/vesta.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
WEB_SYSTEM='apache'
22
WEB_SSL='mod_ssl'
3+
WEB_PORT='8080'
4+
WEB_SSL_PORT='8443'
35
PROXY_SYSTEM='nginx'
6+
PROXY_PORT='80'
7+
PROXY_SSL_PORT='443'
48
FTP_SYSTEM='vsftpd'
59
MAIL_SYSTEM=''
610
DB_SYSTEM='mysql'

func/domain_func.sh

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -219,37 +219,6 @@ sort_dns_records() {
219219
mv -f $conf.tmp $conf
220220
}
221221

222-
get_web_port() {
223-
proxy_disabled='80'
224-
proxy_enabled='8080'
225-
226-
# Parsing conf
227-
proxy=$(grep 'PROXY_SYSTEM=' $V_CONF/vesta.conf|cut -f 2 -d \')
228-
229-
# Checking result
230-
if [ -z "$proxy" ] || [ "$proxy" = 'off' ]; then
231-
echo "$proxy_disabled"
232-
else
233-
echo "$proxy_enabled"
234-
fi
235-
}
236-
237-
get_web_port_ssl() {
238-
proxy_disabled='443'
239-
proxy_enabled='8443'
240-
241-
# Parsing conf
242-
proxy=$(grep 'PROXY_SYSTEM=' $V_CONF/vesta.conf|cut -f 2 -d \')
243-
244-
# Checking result
245-
if [ -z "$proxy" ] || [ "$proxy" = 'off' ]; then
246-
echo "$proxy_disabled"
247-
else
248-
echo "$proxy_enabled"
249-
fi
250-
}
251-
252-
253222
httpd_add_config() {
254223
# Adding template to config
255224
cat $tpl_file | \
@@ -266,6 +235,7 @@ httpd_add_config() {
266235
-e "s/%alias%/${aliases//,/ }/g" \
267236
-e "s/%ssl_cert%/${ssl_cert////\/}/g" \
268237
-e "s/%ssl_key%/${ssl_key////\/}/g" \
238+
-e "s/%extentions%/$extentions/g" \
269239
>> $conf
270240
}
271241

func/shared_func.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ is_template_valid() {
592592
proxy_template() {
593593
tpl="$V_WEBTPL/ngingx_vhost_$template.tpl"
594594
descr="$V_WEBTPL/ngingx_vhost_$template.descr"
595-
ssl="$V_WEBTPL/ngingx_vhost_$template.ssl.tpl"
595+
ssl="$V_WEBTPL/ngingx_vhost_$template.stpl"
596596

597597
if [ ! -e $tpl ] || [ ! -e $descr ] || [ ! -e $ssl ]; then
598598
echo "Error: template not found"
@@ -1334,3 +1334,20 @@ pkg_shell_list() {
13341334
i=$(($i + 1))
13351335
done
13361336
}
1337+
1338+
get_config_value() {
1339+
key="$1"
1340+
# Parsing config
1341+
string=$(cat $V_CONF/vesta.conf)
1342+
1343+
# Parsing key=value
1344+
for keys in $string; do
1345+
eval ${keys%%=*}=${keys#*=}
1346+
done
1347+
1348+
# Self reference
1349+
eval value="$key"
1350+
1351+
# Print value
1352+
echo "$value"
1353+
}

0 commit comments

Comments
 (0)