Skip to content

Commit 3dcc180

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

21 files changed

+102
-329
lines changed

bin/v_list_web_domain

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,18 @@ user=$1
1515
domain=$2
1616
format=${3-shell}
1717

18-
# Importing variables
18+
# Includes
1919
source $VESTA/func/shared.sh
2020

2121
# Json function
2222
json_list_domain() {
2323
i=1
2424
fileds_count=$(echo "$fields" | wc -w)
2525
line=$(grep "DOMAIN='$domain'" $conf)
26-
27-
# Print top bracket
2826
echo '{'
29-
30-
# Assing key=value
3127
eval $line
32-
33-
# Starting output loop
3428
for field in $fields; do
35-
# Parsing key=value
3629
eval value=$field
37-
38-
# Checking first field
3930
if [ "$i" -eq 1 ]; then
4031
echo -e "\t\"$value\": {"
4132
else
@@ -45,28 +36,23 @@ json_list_domain() {
4536
echo -e "\t\t\"${field//$/}\": \"$value\""
4637
fi
4738
fi
48-
# Updating iterator
4939
(( ++i))
5040
done
51-
52-
# If there was any output
5341
if [ -n "$value" ]; then
5442
echo -e ' }'
5543
fi
56-
# Printing bottom json bracket
5744
echo -e "}"
5845
}
5946

6047
# Shell function
6148
shell_list_domain() {
6249
line=$(grep "DOMAIN='$domain'" $conf)
63-
64-
# Parsing key=value
6550
eval $line
66-
67-
# Print result line
6851
for field in $fields; do
6952
eval key="$field"
53+
if [ -z "$key" ]; then
54+
key='NULL'
55+
fi
7056
echo "${field//$/}: $key "
7157
done
7258
}
@@ -76,14 +62,9 @@ shell_list_domain() {
7662
# Verifications #
7763
#----------------------------------------------------------#
7864

79-
# Checking args
8065
check_args '2' "$#" 'user domain [format]'
81-
82-
# Checking user
8366
is_object_valid 'user' 'USER' "$user"
84-
85-
# Checking domain exist
86-
is_domain_valid 'web'
67+
is_object_valid 'web' 'DOMAIN' "$domain"
8768

8869

8970
#----------------------------------------------------------#
@@ -101,7 +82,7 @@ fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG
10182
case $format in
10283
json) json_list_domain ;;
10384
plain) nohead=1; shell_list_domain ;;
104-
shell) shell_list_domain ;;
85+
shell) shell_list_domain |column -t;;
10586
*) check_args '2' '0' 'user domain [format]'
10687
esac
10788

bin/v_list_web_domain_ssl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ user=$1
1414
domain=$2
1515
format=${3-shell}
1616

17-
# Importing variables
17+
# Includes
1818
source $VESTA/func/shared.sh
1919

2020
# Json function
@@ -35,7 +35,6 @@ shell_list_ssl() {
3535
fi
3636
if [ ! -z "$key" ]; then
3737
echo -e "\n$key"
38-
3938
fi
4039
if [ ! -z "$ca" ]; then
4140
echo -e "\n$ca"
@@ -47,15 +46,9 @@ shell_list_ssl() {
4746
# Verifications #
4847
#----------------------------------------------------------#
4948

50-
# Checking args
5149
check_args '2' "$#" 'user domain [format]'
52-
53-
# Checking user
5450
is_object_valid 'user' 'USER' "$user"
55-
56-
# Checking domain exist
57-
is_domain_valid 'web'
58-
51+
is_object_valid 'web' 'DOMAIN' "$domain"
5952

6053
#----------------------------------------------------------#
6154
# Action #

bin/v_list_web_domains

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,16 @@
1313
user=$1
1414
format=${2-shell}
1515

16-
# Importing variables
16+
# Includes
1717
source $VESTA/func/shared.sh
1818

1919

2020
#----------------------------------------------------------#
2121
# Verifications #
2222
#----------------------------------------------------------#
2323

24-
# Checking args
2524
check_args '1' "$#" 'user [format]'
26-
27-
# Checking argument format
2825
validate_format 'user'
29-
30-
# Checking user
3126
is_object_valid 'user' 'USER' "$user"
3227

3328

bin/v_list_web_domains_alias

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,16 @@
1515
user=$1
1616
format=${2-shell}
1717

18-
# Importing variables
18+
# Includes
1919
source $VESTA/func/shared.sh
2020

2121

2222
#----------------------------------------------------------#
2323
# Verifications #
2424
#----------------------------------------------------------#
2525

26-
# Checking args
2726
check_args '1' "$#" 'user [format]'
28-
29-
# Checking argument format
3027
validate_format 'user'
31-
32-
# Checking user
3328
is_object_valid 'user' 'USER' "$user"
3429

3530

bin/v_list_web_domains_elog

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,16 @@
1515
user=$1
1616
format=${2-shell}
1717

18-
# Importing variables
18+
# Includes
1919
source $VESTA/func/shared.sh
2020

2121

2222
#----------------------------------------------------------#
2323
# Verifications #
2424
#----------------------------------------------------------#
2525

26-
# Checking args
2726
check_args '1' "$#" 'user [format]'
28-
29-
# Checking argument format
3027
validate_format 'user'
31-
32-
# Checking user
3328
is_object_valid 'user' 'USER' "$user"
3429

3530

@@ -41,7 +36,7 @@ is_object_valid 'user' 'USER' "$user"
4136
conf=$USER_DATA/web.conf
4237

4338
# Defining fileds to select
44-
fields="\$DOMAIN \$ELOG"
39+
fields="\$DOMAIN \$ELOG \$SUSPENDED \$TIME \$DATE"
4540

4641
# Listing domains
4742
case $format in

bin/v_list_web_domains_nginx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,16 @@
1515
user=$1
1616
format=${2-shell}
1717

18-
# Importing variables
18+
# Includes
1919
source $VESTA/func/shared.sh
2020

2121

2222
#----------------------------------------------------------#
2323
# Verifications #
2424
#----------------------------------------------------------#
2525

26-
# Checking args
2726
check_args '1' "$#" 'user [format]'
28-
29-
# Checking argument format
3027
validate_format 'user'
31-
32-
# Checking user
3328
is_object_valid 'user' 'USER' "$user"
3429

3530

bin/v_list_web_domains_ssl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,16 @@
1515
user=$1
1616
format=${2-shell}
1717

18-
# Importing variables
18+
# Includes
1919
source $VESTA/func/shared.sh
2020

2121

2222
#----------------------------------------------------------#
2323
# Verifications #
2424
#----------------------------------------------------------#
2525

26-
# Checking args
2726
check_args '1' "$#" 'user [format]'
28-
29-
# Checking argument format
3027
validate_format 'user'
31-
32-
# Checking user
3328
is_object_valid 'user' 'USER' "$user"
3429

3530

@@ -41,7 +36,7 @@ is_object_valid 'user' 'USER' "$user"
4136
conf="$USER_DATA/web.conf"
4237

4338
# Defining fileds to select
44-
fields="\$DOMAIN \$IP \$TPL \$SSL \$SSL_HOME"
39+
fields="\$DOMAIN \$IP \$TPL \$SSL \$SSL_HOME \$SUSPENDED"
4540

4641
# Listing domains
4742
case $format in

bin/v_list_web_domains_stats

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@
1616
user=$1
1717
format=${2-shell}
1818

19-
# Importing variables
19+
# Includes
2020
source $VESTA/func/shared.sh
2121

2222

2323
#----------------------------------------------------------#
2424
# Verifications #
2525
#----------------------------------------------------------#
2626

27-
# Checking args
2827
check_args '1' "$#" 'user [format]'
29-
30-
# Checking argument format
3128
validate_format 'user'
32-
33-
# Checking user
3429
is_object_valid 'user' 'USER' "$user"
3530

3631

@@ -42,7 +37,7 @@ is_object_valid 'user' 'USER' "$user"
4237
conf=$USER_DATA/web.conf
4338

4439
# Defining fileds to select
45-
fields="\$DOMAIN \$STATS \$STATS_AUTH"
40+
fields="\$DOMAIN \$STATS \$STATS_AUTH \$SUSPENDED \$TIME \$DATE"
4641

4742
# Listing domains
4843
case $format in

bin/v_list_web_templates

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,25 @@
1313
user=$1
1414
format=${2-shell}
1515

16-
# Importing variables
16+
# Includes
1717
source $VESTA/func/shared.sh
1818

1919
# Json function
2020
json_list_wtpl() {
21-
i='1' # iterator
21+
i=1
2222
echo '{'
23-
24-
# Listing files by mask
2523
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
2624
if [ -e "$WEBTPL/apache_$template.descr" ]; then
2725
descr=$(cat $WEBTPL/apache_$template.descr | grep '#'|\
2826
sed -e ':a;N;$!ba;s/\n/ /g')
29-
# Checking !first line to print bracket
3027
if [ $i -ne 1 ]; then
3128
echo -e "\t},"
3229
fi
33-
# Print result
3430
echo -e "\t\"$template\": {"
3531
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
3632
(( ++i))
3733
fi
3834
done
39-
40-
# If there was any output
4135
if [ -n "$template" ]; then
4236
echo -e "\t}"
4337
fi
@@ -63,13 +57,8 @@ shell_list_wtpl() {
6357
# Verifications #
6458
#----------------------------------------------------------#
6559

66-
# Checking arg number
6760
check_args '1' "$#" 'user'
68-
69-
# Checking argument format
7061
validate_format 'user'
71-
72-
# Checking user
7362
is_object_valid 'user' 'USER' "$user"
7463

7564

bin/v_list_web_templates_nginx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,26 @@
1313
user=$1
1414
format=${2-shell}
1515

16-
# Importing variables
16+
# Includes
1717
source $VESTA/func/shared.sh
1818

1919
# Json function
2020
json_list_wtpl() {
2121
i='1' # iterator
2222
echo '{'
23-
24-
# Listing files by mask
2523
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
2624
if [ -e "$WEBTPL/ngingx_vhost_$template.descr" ]; then
2725
descr=$(cat $WEBTPL/ngingx_vhost_$template.descr | grep '#'|\
2826
sed -e ':a;N;$!ba;s/\n/ /g')
29-
# Checking !first line to print bracket
3027
if [ $i -ne 1 ]; then
3128
echo -e "\t},"
3229
fi
33-
# Print result
3430
echo -e "\t\"$template\": {"
3531
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
3632
(( ++i))
3733
fi
3834
done
3935

40-
# If there was any output
4136
if [ -n "$template" ]; then
4237
echo -e "\t}"
4338
fi
@@ -63,13 +58,8 @@ shell_list_wtpl() {
6358
# Verifications #
6459
#----------------------------------------------------------#
6560

66-
# Checking arg number
6761
check_args '1' "$#" 'user'
68-
69-
# Checking argument format
7062
validate_format 'user'
71-
72-
# Checking user
7363
is_object_valid 'user' 'USER' "$user"
7464

7565

0 commit comments

Comments
 (0)