Skip to content

Commit 8919764

Browse files
committed
web domain editing
1 parent 2d12f47 commit 8919764

30 files changed

+978
-78
lines changed

bin/v_add_web_domain_nginx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ user=$1
1515
domain=$(idn -t --quiet -u "$2" )
1616
domain_idn=$(idn -t --quiet -a "$domain")
1717
template=${3-default}
18-
default_extentions="jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,\
19-
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm"
18+
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
19+
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
2020
extentions=${4-$default_extentions}
2121
restart="$5"
2222

bin/v_add_web_domain_stats_user

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ is_object_valid 'user' 'USER' "$user"
3737
is_object_unsuspended 'user' 'USER' "$user"
3838
is_object_valid 'web' 'DOMAIN' "$domain"
3939
is_object_unsuspended 'web' 'DOMAIN' "$domain"
40-
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
4140

4241

4342
#----------------------------------------------------------#

bin/v_change_dns_domain_ip

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ user=$1
1414
domain=$(idn -t --quiet -u "$2" )
1515
domain_idn=$(idn -t --quiet -a "$domain")
1616
ip=$3
17+
restart=$4
1718

1819
# Includes
1920
source $VESTA/conf/vesta.conf
@@ -53,7 +54,9 @@ update_domain_zone
5354
#----------------------------------------------------------#
5455

5556
# Restart named
56-
$BIN/v_restart_dns "$EVENT"
57+
if [ "$restart" != 'no' ]; then
58+
$BIN/v_restart_dns "$EVENT"
59+
fi
5760

5861
# Logging
5962
log_history "$EVENT"

bin/v_change_web_domain_ip

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: change web domain ip address
3-
# options: user domain ip
3+
# options: user domain ip [restart]
44
#
55
# The call is used for changing the site ip address. The ip change will be
66
# performed for a virtual apache host and for a configuration nginx file both.
@@ -15,6 +15,7 @@ user=$1
1515
domain=$(idn -t --quiet -u "$2" )
1616
domain_idn=$(idn -t --quiet -a "$domain")
1717
ip=$3
18+
restart=$4
1819

1920
# Includes
2021
source $VESTA/conf/vesta.conf
@@ -27,7 +28,7 @@ source $VESTA/func/ip.sh
2728
# Verifications #
2829
#----------------------------------------------------------#
2930

30-
check_args '3' "$#" 'user domain ip'
31+
check_args '3' "$#" 'user domain ip [restart]'
3132
validate_format 'user' 'domain' 'ip'
3233
is_system_enabled "$WEB_SYSTEM"
3334
is_object_valid 'user' 'USER' "$user"
@@ -84,7 +85,9 @@ decrease_ip_value "$old"
8485
update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip"
8586

8687
# Restart web server
87-
$BIN/v_restart_web "$EVENT"
88+
if [ "$restart" != 'no' ]; then
89+
$BIN/v_restart_web "$EVENT"
90+
fi
8891

8992
# Logging
9093
log_history "$EVENT"

bin/v_change_web_domain_nginx_tpl

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
# info: change web domain nginx template
3+
# options: user domain template [extentions] [restart]
4+
#
5+
# The function changes template of nginx.conf configuration file. The content
6+
# of webdomain directories remains untouched.
7+
8+
9+
#----------------------------------------------------------#
10+
# Variable&Function #
11+
#----------------------------------------------------------#
12+
13+
# Argument defenition
14+
user=$1
15+
domain=$(idn -t --quiet -u "$2" )
16+
domain_idn=$(idn -t --quiet -a "$domain")
17+
template=$3
18+
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
19+
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
20+
extentions=${4-$default_extentions}
21+
restart="$5"
22+
23+
24+
# Includes
25+
source $VESTA/conf/vesta.conf
26+
source $VESTA/func/main.sh
27+
source $VESTA/func/domain.sh
28+
29+
30+
#----------------------------------------------------------#
31+
# Verifications #
32+
#----------------------------------------------------------#
33+
34+
check_args '3' "$#" 'user domain template [extentions] [restart]'
35+
validate_format 'user' 'domain' 'template'
36+
is_system_enabled "$PROXY_SYSTEM"
37+
is_object_valid 'user' 'USER' "$user"
38+
is_object_unsuspended 'user' 'USER' "$user"
39+
is_object_valid 'web' 'DOMAIN' "$domain"
40+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
41+
is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
42+
is_nginx_template_valid
43+
44+
45+
#----------------------------------------------------------#
46+
# Action #
47+
#----------------------------------------------------------#
48+
49+
# Parsing domain values
50+
get_domain_values 'web'
51+
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
52+
conf="$HOMEDIR/$user/conf/web/nginx.conf"
53+
54+
# Delete old vhost
55+
del_web_config
56+
57+
# Checking ssl
58+
if [ "$SSL" = 'yes' ]; then
59+
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
60+
conf="$HOMEDIR/$user/conf/web/snginx.conf"
61+
del_web_config
62+
fi
63+
64+
# Add new vhost
65+
NGINX="$template"
66+
NGINX_EXT="$extentions"
67+
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
68+
conf="$HOMEDIR/$user/conf/web/nginx.conf"
69+
upd_web_domain_values
70+
add_web_config
71+
chown root:nginx $conf
72+
chmod 640 $conf
73+
74+
# Checking ssl
75+
if [ "$SSL" = 'yes' ]; then
76+
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
77+
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
78+
conf="$HOMEDIR/$user/conf/web/snginx.conf"
79+
add_web_config
80+
chown root:nginx $conf
81+
chmod 640 $conf
82+
fi
83+
84+
85+
#----------------------------------------------------------#
86+
# Vesta #
87+
#----------------------------------------------------------#
88+
89+
# Update config
90+
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
91+
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
92+
93+
# Restart web
94+
if [ "$restart" != 'no' ]; then
95+
$BIN/v_restart_web "$EVENT"
96+
fi
97+
98+
# Logging
99+
log_history "$EVENT"
100+
log_event "$OK" "$EVENT"
101+
102+
exit

bin/v_change_web_domain_stats

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
# info: change web domain statistics
3+
# options: user domain type
4+
#
5+
# The function of deleting site's system of statistics. Its type is
6+
# automatically chooses from client's configuration file.
7+
8+
9+
#----------------------------------------------------------#
10+
# Variable&Function #
11+
#----------------------------------------------------------#
12+
13+
# Argument defenition
14+
user=$1
15+
domain=$(idn -t --quiet -u "$2" )
16+
type=$3
17+
18+
# Includes
19+
source $VESTA/conf/vesta.conf
20+
source $VESTA/func/main.sh
21+
source $VESTA/func/domain.sh
22+
23+
24+
#----------------------------------------------------------#
25+
# Verifications #
26+
#----------------------------------------------------------#
27+
28+
check_args '3' "$#" 'user domain type'
29+
validate_format 'user' 'domain'
30+
is_system_enabled "$WEB_SYSTEM"
31+
is_type_valid "$STATS_SYSTEM" "$type"
32+
is_object_valid 'user' 'USER' "$user"
33+
is_object_unsuspended 'user' 'USER' "$user"
34+
is_object_valid 'web' 'DOMAIN' "$domain"
35+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
36+
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
37+
38+
39+
#----------------------------------------------------------#
40+
# Action #
41+
#----------------------------------------------------------#
42+
43+
# Defining statistic type
44+
get_domain_values 'web'
45+
46+
# Comparing stats types
47+
if [ "$STATS" == $type ]; then
48+
log_event "$OK" "$EVENT"
49+
exit 0
50+
fi
51+
52+
# Defining statistic dir
53+
stats_dir="$HOMEDIR/$user/web/$domain/stats"
54+
55+
# Deleting dir content
56+
rm -rf $stats_dir/*
57+
58+
# Deleting config
59+
rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
60+
61+
# Preparing domain values for the template substitution
62+
upd_web_domain_values
63+
64+
# Adding statistic config
65+
cat $WEBTPL/$type.tpl |\
66+
sed -e "s/%ip%/$ip/g" \
67+
-e "s/%web_port%/$WEB_PORT/g" \
68+
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
69+
-e "s/%proxy_port%/$PROXY_PORT/g" \
70+
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
71+
-e "s/%domain_idn%/$domain_idn/g" \
72+
-e "s/%domain%/$domain/g" \
73+
-e "s/%user%/$user/g" \
74+
-e "s/%home%/${HOMEDIR////\/}/g" \
75+
-e "s/%alias%/${aliases//,/ }/g" \
76+
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
77+
> $HOMEDIR/$user/conf/web/$type.$domain.conf
78+
79+
80+
#----------------------------------------------------------#
81+
# Vesta #
82+
#----------------------------------------------------------#
83+
84+
# Update config
85+
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
86+
87+
# Logging
88+
log_history "$EVENT"
89+
log_event "$OK" "$EVENT"
90+
91+
exit

bin/v_change_web_domain_tpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: change web domain template
3-
# options: user domain template
3+
# options: user domain template [restart]
44
#
55
# The function changes template of httpd.conf configuration file. The content
66
# of webdomain directories remains untouched.
@@ -15,6 +15,7 @@ user=$1
1515
domain=$(idn -t --quiet -u "$2" )
1616
domain_idn=$(idn -t --quiet -a "$domain")
1717
template=$3
18+
restart=$4
1819

1920
# Includes
2021
source $VESTA/conf/vesta.conf
@@ -26,7 +27,7 @@ source $VESTA/func/domain.sh
2627
# Verifications #
2728
#----------------------------------------------------------#
2829

29-
check_args '3' "$#" 'user domain template'
30+
check_args '3' "$#" 'user domain template [restart]'
3031
validate_format 'user' 'domain' 'template'
3132
is_system_enabled "$WEB_SYSTEM"
3233
is_object_valid 'user' 'USER' "$user"
@@ -170,7 +171,9 @@ for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do
170171
done
171172

172173
# Restart web
173-
$BIN/v_restart_web "$EVENT"
174+
if [ "$restart" != 'no' ]; then
175+
$BIN/v_restart_web "$EVENT"
176+
fi
174177

175178
# Logging
176179
log_history "$EVENT"

bin/v_delete_web_domain_alias

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: delete web domain alias
3-
# options: user domain alias
3+
# options: user domain alias [restart]
44
#
55
# The function of deleting the alias domain (parked domain). By this call
66
# default www aliase can be removed as well.
@@ -16,6 +16,7 @@ domain=$(idn -t --quiet -u "$2" )
1616
domain_idn=$(idn -t --quiet -a "$domain" )
1717
dom_alias=$(idn -t --quiet -u "$3" )
1818
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
19+
restart="$4"
1920

2021
# Includes
2122
source $VESTA/conf/vesta.conf
@@ -27,7 +28,7 @@ source $VESTA/func/domain.sh
2728
# Verifications #
2829
#----------------------------------------------------------#
2930

30-
check_args '3' "$#" 'user domain dom_alias'
31+
check_args '3' "$#" 'user domain dom_alias [restart]'
3132
validate_format 'user' 'domain' 'dom_alias'
3233
is_system_enabled 'WEB_SYSTEM'
3334
is_object_valid 'user' 'USER' "$user"
@@ -97,7 +98,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
9798
decrease_user_value "$user" '$U_WEB_ALIASES'
9899

99100
# Restart web server
100-
$BIN/v_restart_web "$EVENT"
101+
if [ "$restart" != 'no' ]; then
102+
$BIN/v_restart_web "$EVENT"
103+
fi
101104

102105
# Logging
103106
log_history "$EVENT"

bin/v_delete_web_domain_elog

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: delete web domain error loggin support
3-
# options: user domain
3+
# options: user domain [restart]
44
#
55
# The function of disabling error logging feature. It comments ErrorLog
66
# direcitve in apache or/and nginx configuration. The data already collected
@@ -15,6 +15,7 @@
1515
user=$1
1616
domain=$(idn -t --quiet -u "$2" )
1717
domain_idn=$(idn -t --quiet -a "$domain")
18+
restart=$3
1819

1920
# Includes
2021
source $VESTA/conf/vesta.conf
@@ -26,7 +27,7 @@ source $VESTA/func/domain.sh
2627
# Verifications #
2728
#----------------------------------------------------------#
2829

29-
check_args '2' "$#" 'user domain'
30+
check_args '2' "$#" 'user domain [restart]'
3031
validate_format 'user' 'domain'
3132
is_system_enabled "$WEB_SYSTEM"
3233
is_object_valid 'user' 'USER' "$user" "$user"
@@ -86,7 +87,9 @@ fi
8687
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no'
8788

8889
# Restart web server
89-
$BIN/v_restart_web "$EVENT"
90+
if [ "$restart" != 'no' ]; then
91+
$BIN/v_restart_web "$EVENT"
92+
fi
9093

9194
# Logging
9295
log_history "$EVENT"

bin/v_delete_web_domain_nginx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
user=$1
1414
domain=$(idn -t --quiet -u "$2" )
1515
domain_idn=$(idn -t --quiet -a "$domain")
16+
restart=$3
1617

1718
# Includes
1819
source $VESTA/conf/vesta.conf
@@ -75,7 +76,9 @@ if [ -z "$last_nginx" ]; then
7576
fi
7677

7778
# Restart web server
78-
$BIN/v_restart_web "$EVENT"
79+
if [ "$restart" != 'no' ]; then
80+
$BIN/v_restart_web "$EVENT"
81+
fi
7982

8083
# Logging
8184
log_history "$EVENT"

0 commit comments

Comments
 (0)