mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-03 04:00:20 -08:00
86 lines
1.8 KiB
Bash
Executable File
86 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: listing backend templates
|
|
# options: [FORMAT]
|
|
#
|
|
# The function for obtaining the list of available backend templates.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
format=${1-shell}
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
# JSON list function
|
|
json_list() {
|
|
i=1
|
|
objects=$(echo "$templates" |wc -w)
|
|
echo '['
|
|
for template in $templates; do
|
|
if [ "$i" -lt "$objects" ]; then
|
|
echo -e "\t\"$template\","
|
|
else
|
|
echo -e "\t\"$template\""
|
|
fi
|
|
(( ++i))
|
|
done
|
|
echo "]"
|
|
}
|
|
|
|
# SHELL list function
|
|
shell_list() {
|
|
echo "TEMPLATE"
|
|
echo "--------"
|
|
for template in $templates; do
|
|
echo "$template"
|
|
done
|
|
}
|
|
|
|
# PLAIN list function
|
|
plain_list() {
|
|
for template in $templates; do
|
|
echo "$template"
|
|
done
|
|
}
|
|
|
|
# CSV list function
|
|
csv_list() {
|
|
echo "TEMPLATE"
|
|
for template in $templates; do
|
|
echo "$template"
|
|
done
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Parsing backend templates
|
|
if [ ! -z "$WEB_BACKEND" ]; then
|
|
templates=$(ls -t $WEBTPL/$WEB_BACKEND |\
|
|
cut -f1 -d . |\
|
|
grep -v proxy_ip |\
|
|
sort -u )
|
|
fi
|
|
|
|
# Listing data
|
|
case $format in
|
|
json) json_list ;;
|
|
plain) plain_list ;;
|
|
csv) csv_list ;;
|
|
shell) shell_list ;;
|
|
esac
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit
|