mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
New nginx template listing func + additional file verifications
This commit is contained in:
parent
558f4b719f
commit
c628f217e7
3 changed files with 113 additions and 17 deletions
|
@ -20,16 +20,18 @@ json_list_wtpl() {
|
||||||
|
|
||||||
# Listing files by mask
|
# Listing files by mask
|
||||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
||||||
descr=$(cat $V_WEBTPL/apache_$template.descr | grep '#'|\
|
if [ -e "$V_WEBTPL/apache_$template.descr" ]; then
|
||||||
sed -e ':a;N;$!ba;s/\n/ /g')
|
descr=$(cat $V_WEBTPL/apache_$template.descr | grep '#'|\
|
||||||
# Checking !first line to print bracket
|
sed -e ':a;N;$!ba;s/\n/ /g')
|
||||||
if [ $i -ne 1 ]; then
|
# Checking !first line to print bracket
|
||||||
echo -e "\t},"
|
if [ $i -ne 1 ]; then
|
||||||
|
echo -e "\t},"
|
||||||
|
fi
|
||||||
|
# Print result
|
||||||
|
echo -e "\t\"$template\": {"
|
||||||
|
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
|
||||||
|
(( ++i))
|
||||||
fi
|
fi
|
||||||
# Print result
|
|
||||||
echo -e "\t\"$template\": {"
|
|
||||||
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
|
|
||||||
(( ++i))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# If there was any output
|
# If there was any output
|
||||||
|
@ -42,14 +44,14 @@ json_list_wtpl() {
|
||||||
# Shell function
|
# Shell function
|
||||||
shell_list_wtpl() {
|
shell_list_wtpl() {
|
||||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
||||||
tpl_descr=$(cat $V_WEBTPL/apache_$template.descr |grep '#')
|
if [ -e "$V_WEBTPL/apache_$template.descr" ]; then
|
||||||
|
tpl_descr=$(cat $V_WEBTPL/apache_$template.descr |grep '#')
|
||||||
if [ -z "$nohead" ]; then
|
if [ -z "$nohead" ]; then
|
||||||
echo "----------"
|
echo "----------"
|
||||||
|
fi
|
||||||
|
echo "TEMPLATE: $template"
|
||||||
|
echo "DESCRIPTION: ${tpl_descr//# /}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "TEMPLATE: $template"
|
|
||||||
echo "DESCRIPTION: ${tpl_descr//# /}"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
93
bin/v_list_web_templates_nginx
Executable file
93
bin/v_list_web_templates_nginx
Executable file
|
@ -0,0 +1,93 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: listing nginx 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
|
||||||
|
if [ -e "$V_WEBTPL/ngingx_vhost_$template.descr" ]; then
|
||||||
|
descr=$(cat $V_WEBTPL/ngingx_vhost_$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))
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
if [ -e "$V_WEBTPL/ngingx_vhost_$template.descr" ]; then
|
||||||
|
tpl_descr=$(cat $V_WEBTPL/ngingx_vhost_$template.descr |grep '#')
|
||||||
|
if [ -z "$nohead" ]; then
|
||||||
|
echo "----------"
|
||||||
|
fi
|
||||||
|
echo "TEMPLATE: $template"
|
||||||
|
echo "DESCRIPTION: ${tpl_descr//# /}"
|
||||||
|
fi
|
||||||
|
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
|
|
@ -24,7 +24,8 @@ v_list_user_packages json
|
||||||
v_list_users json
|
v_list_users json
|
||||||
v_list_web_domains vesta json
|
v_list_web_domains vesta json
|
||||||
v_list_web_domain vesta default.vesta.domain json
|
v_list_web_domain vesta default.vesta.domain json
|
||||||
v_list_web_templates vesta json'
|
v_list_web_templates vesta json
|
||||||
|
v_list_web_templates_nginx vesta json'
|
||||||
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for cmd in $commands; do
|
for cmd in $commands; do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue