forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_list_web_templates
More file actions
executable file
·91 lines (70 loc) · 2.22 KB
/
v_list_web_templates
File metadata and controls
executable file
·91 lines (70 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# info: listing web templates
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
# Json function
json_list_wtpl() {
i='1' # iterator
echo '{'
# Listing files by mask
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
descr=$(cat $V_WEBTPL/apache_$template.descr | grep '#'|\
sed -e ':a;N;$!ba;s/\n/ /g')
# Checking !first line to print bracket
if [ $i -ne 1 ]; then
echo -e "\t},"
fi
# Print result
echo -e "\t\"$template\": {"
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
(( ++i))
done
# If there was any output
if [ -n "$template" ]; then
echo -e "\t}"
fi
echo '}'
}
# Shell function
shell_list_wtpl() {
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
tpl_descr=$(cat $V_WEBTPL/apache_$template.descr |grep '#')
if [ -z "$nohead" ]; then
echo "----------"
fi
echo "TEMPLATE: $template"
echo "DESCRIPTION: ${tpl_descr//# /}"
done
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get user package package
templates=$(get_user_value '$WEB_TPL')
# Listing domains
case $format in
json) json_list_wtpl ;;
plain) nohead=1; shell_list_wtpl ;;
shell) shell_list_wtpl ;;
*) check_args '1' '0' '[format]'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit