| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #!/bin/bash
- # info: list dns templates
- # options: [format]
- #
- # The function for obtaining the list of all DNS templates available.
- #----------------------------------------------------------#
- # 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
|