Skip to content

Commit 0fb633a

Browse files
committed
Refactoring stage IV (web)
1 parent 3371762 commit 0fb633a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+448
-975
lines changed

bin/v_add_cron_job

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ sync_cron_jobs
7070
increase_user_value $user '$U_CRON_JOBS'
7171

7272
# Restart crond
73-
$BIN/v_restart_cron
73+
$BIN/v_restart_cron "$EVENT"
7474

7575
# Logging
7676
log_history "$EVENT"

bin/v_add_cron_report

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sync_cron_jobs
4545
#----------------------------------------------------------#
4646

4747
# Restart crond
48-
$BIN/v_restart_cron
48+
$BIN/v_restart_cron "$EVENT"
4949

5050
# Logging
5151
log_history "$EVENT"

bin/v_add_dns_domain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ increase_user_value "$user" '$U_DNS_DOMAINS'
109109
increase_user_value "$user" '$U_DNS_RECORDS' "$records"
110110

111111
# Restart named
112-
$BIN/v_restart_dns
112+
$BIN/v_restart_web "$EVENT"
113113

114114
# Logging
115115
log_history "$EVENT"

bin/v_add_dns_domain_record

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
7979
increase_user_value "$user" '$U_DNS_RECORDS'
8080

8181
# Restart named
82-
$BIN/v_restart_dns
82+
$BIN/v_restart_dns "$EVENT"
8383

8484
# Logging
8585
log_history "$EVENT"

bin/v_add_sys_ip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fi
106106

107107
# Adding task to the vesta pipe
108108
if [ "$web_restart" = 'yes' ]; then
109-
$BIN/v_restart_web
109+
$BIN/v_restart_web "$EVENT"
110110
fi
111111

112112
# Logging

bin/v_add_web_domain

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
2222
ip=$3
2323
template=${4-default}
2424

25-
# Importing variables
25+
# Includes
2626
source $VESTA/conf/vesta.conf
2727
source $VESTA/func/shared.sh
2828
source $VESTA/func/domain.sh
@@ -33,32 +33,15 @@ source $VESTA/func/ip.sh
3333
# Verifications #
3434
#----------------------------------------------------------#
3535

36-
# Checking arg number
3736
check_args '3' "$#" 'user domain ip [template]'
38-
39-
# Checking argument format
4037
validate_format 'user' 'domain' 'ip' 'template'
41-
42-
# Checking web system is enabled
43-
is_system_enabled 'WEB_SYSTEM'
44-
45-
# Checking user
38+
is_system_enabled "$WEB_SYSTEM"
4639
is_object_valid 'user' 'USER' "$user"
47-
48-
# Checking user is active
4940
is_object_unsuspended 'user' 'USER' "$user"
50-
51-
# Checking domain
52-
is_domain_new 'dns'
53-
54-
# Checking ip
41+
is_domain_new 'web'
42+
is_ip_valid
5543
is_ip_avalable
56-
57-
# Checking package
5844
is_package_full 'WEB_DOMAINS'
59-
60-
# Checking template
61-
templates=$(get_user_value '$WEB_TPL')
6245
is_apache_template_valid
6346

6447

@@ -89,7 +72,6 @@ group="$user"
8972
email="$user@$domain"
9073
docroot="$HOMEDIR/$user/web/$domain/public_html"
9174
docroot_string="DocumentRoot $docroot"
92-
9375
conf="$HOMEDIR/$user/conf/web/httpd.conf"
9476
tpl_file="$WEBTPL/apache_$template.tpl"
9577

@@ -192,34 +174,26 @@ fi
192174
# Vesta #
193175
#----------------------------------------------------------#
194176

195-
# Increasing ip value
177+
# Increasing counters
196178
increase_ip_value "$ip"
197-
198-
# Increasing domain value
199179
increase_user_value "$user" '$U_WEB_DOMAINS'
200180
increase_user_value "$user" '$U_WEB_ALIASES'
201181

202182
# Defining domain variables
203-
v_str="DOMAIN='$domain'"
204-
v_str="$v_str IP='$ip' IP6=''"
205-
v_str="$v_str U_DISK='0'"
206-
v_str="$v_str U_BANDWIDTH='0'"
207-
v_str="$v_str TPL='$template'"
208-
v_str="$v_str ALIAS='$aliases'"
209-
v_str="$v_str $template_data" # Inserting PHP, CGI and ELOG keys
210-
v_str="$v_str STATS='' STATS_AUTH=''"
211-
v_str="$v_str SSL='no' SSL_HOME='single'"
212-
v_str="$v_str NGINX='' NGINX_EXT='' SUSPENDED='no' DATE='$DATE'"
183+
str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'"
184+
str="$str $template_data SSL='no' SSL_HOME='single' NGINX='' NGINX_EXT=''"
185+
str="$str STATS='' STATS_USER='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
186+
str="$str TIME='$TIME' DATE='$DATE'"
213187

214188
# Registering domain
215-
echo "$v_str" >> $USER_DATA/web.conf
189+
echo "$str" >> $USER_DATA/web.conf
216190
chmod 660 $USER_DATA/web.conf
217191

218-
# Adding task to the vesta pipe
219-
$BIN/v_restart_web
192+
# Restart web server
193+
$BIN/v_restart_web "$EVENT"
220194

221195
# Logging
222-
log_history "$EVENT" "v_delete_web_domain $user $domain"
196+
log_history "$EVENT"
223197
log_event "$OK" "$EVENT"
224198

225199
exit

bin/v_add_web_domain_alias

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dom_alias=$(idn -t --quiet -u "$3" )
1919
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
2020
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
2121

22-
# Importing variables
22+
# Includes
2323
source $VESTA/conf/vesta.conf
2424
source $VESTA/func/shared.sh
2525
source $VESTA/func/domain.sh
@@ -29,31 +29,14 @@ source $VESTA/func/domain.sh
2929
# Verifications #
3030
#----------------------------------------------------------#
3131

32-
# Checking arg number
3332
check_args '3' "$#" 'user domain dom_alias'
34-
35-
# Checking argument format
3633
validate_format 'user' 'domain' 'dom_alias'
37-
38-
# Checking web system is enabled
39-
is_system_enabled 'WEB_SYSTEM'
40-
41-
# Checking user
34+
is_system_enabled "$WEB_SYSTEM"
4235
is_object_valid 'user' 'USER' "$user"
43-
44-
# Checking user is active
4536
is_object_unsuspended 'user' 'USER' "$user"
46-
47-
# Checking domain exist
48-
is_domain_valid 'web'
49-
50-
# Checking domain is not suspened
51-
is_domain_suspended 'web'
52-
53-
# Checking alias on the server
37+
is_object_valid 'web' 'DOMAIN' "$domain"
38+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
5439
is_domain_new 'web' "$dom_alias"
55-
56-
# Checking package
5740
is_package_full 'WEB_ALIASES'
5841

5942

@@ -109,15 +92,15 @@ fi
10992
#----------------------------------------------------------#
11093

11194
# Adding new alias
112-
update_domain_value 'web' '$ALIAS' "$ALIAS"
95+
update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
11396

11497
# Update counters
11598
increase_user_value "$user" '$U_WEB_ALIASES'
11699

117100
# Adding task to the vesta pipe
118-
$BIN/v_restart_web
101+
$BIN/v_restart_web "$EVENT"
119102

120-
log_history "$EVENT" "v_delete_web_domain_alias $user $domain $dom_alias"
103+
log_history "$EVENT"
121104
log_event "$OK" "$EVENT"
122105

123106
exit

bin/v_add_web_domain_cgi

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,14 @@ source $VESTA/func/domain.sh
2727
# Verifications #
2828
#----------------------------------------------------------#
2929

30-
# Checking arg number
3130
check_args '2' "$#" 'user domain'
32-
33-
# Checking argument format
3431
validate_format 'user' 'domain'
35-
36-
# Checking web system is enabled
37-
is_system_enabled 'WEB_SYSTEM'
38-
39-
# Checking user
32+
is_system_enabled "$WEB_SYSTEM"
4033
is_object_valid 'user' 'USER' "$user"
41-
42-
# Checking user is active
4334
is_object_unsuspended 'user' 'USER' "$user"
44-
45-
# Checking domain exist
46-
is_domain_valid 'web'
47-
48-
# Checking domain is not suspened
49-
is_domain_suspended 'web'
50-
51-
# Checking cgi is not added
52-
is_domain_key_empty 'web' '$CGI'
35+
is_object_valid 'web' 'DOMAIN' "$domain"
36+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
37+
is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI'
5338

5439

5540
#----------------------------------------------------------#
@@ -82,14 +67,14 @@ fi
8267
# Vesta #
8368
#----------------------------------------------------------#
8469

85-
# Adding elog in config
86-
update_domain_value 'web' '$CGI' 'yes'
70+
# Update config value
71+
update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes'
8772

8873
# Adding task to the vesta pipe
89-
$BIN/v_restart_web
74+
$BIN/v_restart_web "$EVENT"
9075

9176
# Logging
92-
log_history "$EVENT" "v_delete_web_domain_cgi $user $domain"
77+
log_history "$EVENT"
9378
log_event "$OK" "$EVENT"
9479

9580
exit

bin/v_add_web_domain_elog

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ user=$1
1515
domain=$(idn -t --quiet -u "$2" )
1616
domain_idn=$(idn -t --quiet -a "$domain")
1717

18-
# Importing variables
18+
# Includes
1919
source $VESTA/conf/vesta.conf
2020
source $VESTA/func/shared.sh
2121
source $VESTA/func/domain.sh
@@ -25,29 +25,14 @@ source $VESTA/func/domain.sh
2525
# Verifications #
2626
#----------------------------------------------------------#
2727

28-
# Checking arg number
2928
check_args '2' "$#" 'user domain'
30-
31-
# Checking argument format
3229
validate_format 'user' 'domain'
33-
34-
# Checking web system is enabled
35-
is_system_enabled 'WEB_SYSTEM'
36-
37-
# Checking user
30+
is_system_enabled "$WEB_SYSTEM"
3831
is_object_valid 'user' 'USER' "$user"
39-
40-
# Checking user is active
4132
is_object_unsuspended 'user' 'USER' "$user"
42-
43-
# Checking domain exist
44-
is_domain_valid 'web'
45-
46-
# Checking domain is not suspened
47-
is_domain_suspended 'web'
48-
49-
# Checking errorlog is not added
50-
is_domain_key_empty 'web' '$ELOG'
33+
is_object_valid 'web' 'DOMAIN' "$domain"
34+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
35+
is_object_value_empty 'web' 'DOMAIN' "$domain" '$ELOG'
5136

5237

5338
#----------------------------------------------------------#
@@ -96,14 +81,14 @@ fi
9681
# Vesta #
9782
#----------------------------------------------------------#
9883

99-
# Adding elog in config
100-
update_domain_value 'web' '$ELOG' 'yes'
84+
# Update config
85+
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes'
10186

10287
# Adding task to the vesta pipe
103-
$BIN/v_restart_web
88+
$BIN/v_restart_web "$EVENT"
10489

10590
# Logging
106-
log_history "$EVENT" "v_delete_web_domain_elog $user $domain"
91+
log_history "$EVENT"
10792
log_event "$OK" "$EVENT"
10893

10994
exit

bin/v_add_web_domain_nginx

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,14 @@ source $VESTA/func/domain.sh
2929
# Verifications #
3030
#----------------------------------------------------------#
3131

32-
# Checking arg number
3332
check_args '2' "$#" 'user domain [template] [extentions]'
34-
35-
# Checking argument format
3633
validate_format 'user' 'domain' 'template' 'extentions'
37-
38-
# Checking proxy system is enabled
39-
is_system_enabled 'proxy'
40-
41-
# Checking user
34+
is_system_enabled "$PROXY_SYSTEM"
4235
is_object_valid 'user' 'USER' "$user"
43-
44-
# Checking user is active
4536
is_object_unsuspended 'user' 'USER' "$user"
46-
47-
# Checking domain exist
48-
is_domain_valid 'web'
49-
50-
# Checking domain is not suspened
51-
is_domain_suspended 'web'
52-
53-
# Check nginx is not added
54-
is_domain_key_empty 'web' '$NGINX'
55-
56-
# Checking template
37+
is_object_valid 'web' 'DOMAIN' "$domain"
38+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
39+
is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX'
5740
is_nginx_template_valid
5841

5942

@@ -106,14 +89,14 @@ fi
10689
# Vesta #
10790
#----------------------------------------------------------#
10891

109-
# Adding nginx params to config
110-
update_domain_value 'web' '$NGINX' "$NGINX"
111-
update_domain_value 'web' '$NGINX_EXT' "$extentions"
92+
# Update config
93+
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
94+
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
11295

11396
# Adding task to the vesta pipe
114-
$BIN/v_restart_web
97+
$BIN/v_restart_web "$EVENT"
11598

116-
log_history "$EVENT" "v_delete_web_domain_nginx $user $domain"
99+
log_history "$EVENT"
117100
log_event "$OK" "$EVENT"
118101

119102
exit

0 commit comments

Comments
 (0)