forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_list_dns_templates
More file actions
executable file
·80 lines (63 loc) · 1.99 KB
/
Copy pathv_list_dns_templates
File metadata and controls
executable file
·80 lines (63 loc) · 1.99 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
#!/bin/bash
# info: listing dns templates
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
format=${1-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
# Json function
json_list_dnstpl() {
# Print top bracket
echo '{'
# Count fields
for template in $(ls $V_DNSTPL/| grep '.descr'); do
# Closing bracket if there already was output
if [ -n "$data" ]; then
echo -e ' },'
fi
tpl_descr=$(cat $V_DNSTPL/$template |grep '#'|tr -d '\n')
tpl_name="${template//.descr/}"
echo -e "\t\"$tpl_name\": {"
echo -e "\t\t\"DESCR\": \"${tpl_descr//# /}\""
data=1
done
# Closing bracket if there was output
if [ -n "$data" ]; then
echo -e ' }'
fi
# Printing bottom bracket
echo -e '}'
}
# Shell function
shell_list_dnstpl() {
for template in $(ls $V_DNSTPL/| grep '.descr'); do
tpl_name="${template//.descr/}"
tpl_descr=$(cat $V_DNSTPL/$template |grep '#')
# Print result
if [ -z "$nohead" ] ; then
echo "----------"
fi
echo "TEMPLATE: $tpl_name"
echo "DESCRIPTION: ${tpl_descr//# /}"
if [ -z "$nohead" ] ; then
echo
fi
done
}
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Listing domains
case $format in
json) json_list_dnstpl;;
plain) nohead=1; shell_list_dnstpl ;;
shell) shell_list_dnstpl ;;
*) check_args '1' '0' '[format] [limit] [offset]';;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit