mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 18:49:21 -07:00
removed limit&offset function + faster listings
This commit is contained in:
parent
8a5d155fb4
commit
90da0f8881
35 changed files with 1378 additions and 1530 deletions
|
@ -6,15 +6,81 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
database="$2"
|
||||
format="${3-shell}"
|
||||
user=$1
|
||||
database=$2
|
||||
format=${3-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/db_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_db() {
|
||||
i=1
|
||||
|
||||
# Define words number
|
||||
last_word=$(echo "$fields" | wc -w)
|
||||
|
||||
# Reading file line by line
|
||||
line=$(grep "DB='$database'" $conf)
|
||||
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Parsing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Starting output loop
|
||||
for field in $fields; do
|
||||
|
||||
# Parsing key=value
|
||||
eval value=$field
|
||||
|
||||
# Checking first field
|
||||
if [ "$i" -eq 1 ]; then
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
if [ "$last_word" -eq "$i" ]; then
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
fi
|
||||
fi
|
||||
|
||||
# Updating iterator
|
||||
(( ++i))
|
||||
done
|
||||
|
||||
# If there was any output
|
||||
if [ -n "$value" ]; then
|
||||
echo -e "\t}"
|
||||
fi
|
||||
|
||||
# Printing bottom json bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell list for single database
|
||||
shell_list_db() {
|
||||
|
||||
# Reading file line by line
|
||||
line=$(grep "DB='$database'" $conf)
|
||||
|
||||
# Parsing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result line
|
||||
for field in $fields; do
|
||||
eval key="$field"
|
||||
echo "${field//$/}: $key "
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -38,16 +104,17 @@ is_db_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/db.conf"
|
||||
conf=$V_USERS/$user/db.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
||||
|
||||
# Listing database
|
||||
case $format in
|
||||
json) db_json_single_list ;;
|
||||
shell) db_shell_single_list | column -t ;;
|
||||
*) check_args '2' "0" 'user database [format]'
|
||||
json) json_list_db ;;
|
||||
plain) shell_list_db ;;
|
||||
shell) shell_list_db | column -t ;;
|
||||
*) check_args '2' '0' 'user database [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -58,4 +125,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -35,16 +33,17 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/db.conf"
|
||||
conf=$V_USERS/$user/db.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
||||
|
||||
# Listing databases
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) v_shell_list| column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) shell_list | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -55,4 +54,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,15 +6,79 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
type="$1"
|
||||
host="$2"
|
||||
format="${3-shell}"
|
||||
type=$1
|
||||
host=$2
|
||||
format=${3-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/db_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_dbhost() {
|
||||
# Definigng variables
|
||||
i=1
|
||||
|
||||
# Define words number
|
||||
fields_count=$(echo "$fields" | wc -w)
|
||||
|
||||
# Reading file line by line
|
||||
line=$(grep "HOST='$host'" $conf)
|
||||
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Assign key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Starting output loop
|
||||
for field in $fields; do
|
||||
|
||||
# Parsing key=value
|
||||
eval value=$field
|
||||
|
||||
# Checking first field
|
||||
if [ "$i" -eq 1 ]; then
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
if [ "$fields_count" -eq "$i" ]; then
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
fi
|
||||
fi
|
||||
(( ++i))
|
||||
done
|
||||
# If there was any output
|
||||
if [ -n "$value" ]; then
|
||||
echo -e "\t}"
|
||||
fi
|
||||
|
||||
# Printing bottom json bracket
|
||||
echo -e "}"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_dbhost() {
|
||||
|
||||
# Reading file line by line
|
||||
line=$(grep "HOST='$host'" $conf)
|
||||
|
||||
# Parsing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result line
|
||||
for field in $fields; do
|
||||
eval key="$field"
|
||||
echo "${field//$/}: $key"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -38,16 +102,17 @@ is_db_host_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config type
|
||||
conf="$V_DB/$type.conf"
|
||||
conf=$V_DB/$type.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
|
||||
|
||||
# Listing database
|
||||
case $format in
|
||||
json) dbhost_json_single_list ;;
|
||||
shell) dbhost_shell_single_list | column -t;;
|
||||
*) check_args '2' "0" 'type host [format]'
|
||||
json) json_list_dbhost ;;
|
||||
plain) nohead=1; shell_list_dbhost ;;
|
||||
shell) shell_list_dbhost | column -t;;
|
||||
*) check_args '2' '0' 'type host [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -58,4 +123,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
type="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
type=$1
|
||||
format=${2-shell}
|
||||
|
||||
|
||||
# Importing variables
|
||||
|
@ -36,17 +34,18 @@ is_type_valid 'db' "$type"
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config type
|
||||
conf="$V_DB/$type.conf"
|
||||
conf=$V_DB/$type.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
|
||||
|
||||
# Listing database
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) fields='$HOST $PORT $MAX_USERS $MAX_DB $U_DB_BASES $ACTIVE $DATE';
|
||||
v_shell_list | column -t ;;
|
||||
*) check_args '2' "0" 'type [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list;;
|
||||
shell) fields='$HOST $PORT $MAX_USERS $MAX_DB $U_DB_BASES $ACTIVE $DATE';
|
||||
shell_list | column -t ;;
|
||||
*) check_args '2' '0' 'type [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -57,4 +56,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,18 +6,95 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
format="${3-shell}"
|
||||
limit="${4-1000}"
|
||||
offset="${5-1}"
|
||||
user=$1
|
||||
domain=$2
|
||||
format=${3-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/domain_func.sh
|
||||
|
||||
# Json func
|
||||
json_list_dns() {
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Count fields
|
||||
fileds_count=$(echo $fields| wc -w )
|
||||
|
||||
# Reading file line by line
|
||||
while read line; do
|
||||
# New delimeter
|
||||
IFS=$'\n'
|
||||
|
||||
# Assing key=value pair
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Closing bracket if there already was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
IFS=' '
|
||||
for field in $fields; do
|
||||
eval value=\"$field\"
|
||||
value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
|
||||
|
||||
if [ $i -eq 1 ]; then
|
||||
# Printing parrent
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
# Printing child
|
||||
if [ $i -lt $fileds_count ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
data=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done < $conf
|
||||
|
||||
# Closing bracket if there was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_dns() {
|
||||
|
||||
if [ -z "$nohead" ] ; then
|
||||
# Print brief info
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "------ \c"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
# Reading file line by line
|
||||
while read line ; do
|
||||
# New delimeter
|
||||
IFS=$'\n'
|
||||
# Assing key=value pair
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result
|
||||
eval echo "$fields" | sed -e "s/%quote%/'/g"
|
||||
done < $conf
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -27,7 +104,7 @@ source $V_FUNC/domain_func.sh
|
|||
check_args '2' "$#" 'user domain [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'domain' 'limit' 'offset'
|
||||
format_validation 'user' 'domain'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -41,17 +118,18 @@ is_dns_domain_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/zones/$domain"
|
||||
conf=$V_USERS/$user/zones/$domain
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$ID $RECORD $TYPE $VALUE $SUSPEND $DATE'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) dns_json_list ;;
|
||||
shell) fields='$ID $RECORD $TYPE $VALUE';
|
||||
dns_shell_list | column -t ;;
|
||||
*) check_args '2' "0" 'user domain [format]'
|
||||
json) json_list_dns ;;
|
||||
plain) nohead=1; shell_list_dns ;;
|
||||
shell) fields='$ID $RECORD $TYPE $VALUE';
|
||||
shell_list_dns | column -t ;;
|
||||
*) check_args '2' '0' 'user domain [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -62,4 +140,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -35,7 +33,7 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/dns.conf"
|
||||
conf=$V_USERS/$user/dns.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $SUSPEND $DATE'
|
||||
|
@ -43,10 +41,11 @@ fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $SUSPEND $DATE'
|
|||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) fields='$DOMAIN $IP $TPL $TTL $EXP $SUSPEND';
|
||||
v_shell_list| column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) fields='$DOMAIN $IP $TPL $TTL $EXP $SUSPEND';
|
||||
shell_list| column -t ;;
|
||||
*) check_args '1' '0' 'user [format]';;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -57,4 +56,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
template="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
template=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -30,22 +28,103 @@ format_validation 'template'
|
|||
# Checking template
|
||||
is_template_valid 'dns'
|
||||
|
||||
# Json func
|
||||
json_list_dns() {
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Count fields
|
||||
fileds_count=$(echo $fields| wc -w )
|
||||
|
||||
# Reading file line by line
|
||||
while read line; do
|
||||
# New delimeter
|
||||
IFS=$'\n'
|
||||
|
||||
# Assing key=value pair
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Closing bracket if there already was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
IFS=' '
|
||||
for field in $fields; do
|
||||
eval value=\"$field\"
|
||||
value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
|
||||
|
||||
if [ $i -eq 1 ]; then
|
||||
# Printing parrent
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
# Printing child
|
||||
if [ $i -lt $fileds_count ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
data=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done < $conf
|
||||
|
||||
# Closing bracket if there was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_dns() {
|
||||
|
||||
if [ -z "$nohead" ] ; then
|
||||
# Print brief info
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "------ \c"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
# Reading file line by line
|
||||
while read line ; do
|
||||
# New delimeter
|
||||
IFS=$'\n'
|
||||
# Assing key=value pair
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result
|
||||
eval echo "$fields" | sed -e "s/%quote%/'/g"
|
||||
done < $conf
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_DNSTPL/$template.tpl"
|
||||
conf=$V_DNSTPL/$template.tpl
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$RECORD $TYPE $VALUE'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) dns_json_list ;;
|
||||
shell) dns_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'template [format]'
|
||||
json) json_list_dns ;;
|
||||
plain) nohead=1; shell_list_dns ;;
|
||||
shell) shell_list_dns | column -t ;;
|
||||
*) check_args '1' '0' 'template [format]';;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -56,4 +135,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,21 +6,59 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
format="${1-shell}"
|
||||
limit="${2-1000}"
|
||||
offset="${3-1}"
|
||||
format=${1-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/domain_func.sh
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
# 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
|
||||
}
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'limit' 'offset'
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
|
@ -28,9 +66,10 @@ format_validation 'limit' 'offset'
|
|||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) dnstpl_json_list ;;
|
||||
shell) dnstpl_shell_list ;;
|
||||
*) check_args '1' "0" '[format] [limit] [offset]'
|
||||
json) json_list_dnstpl;;
|
||||
plain) nohead=1; shell_list_dnstpl ;;
|
||||
shell) shell_list_dnstpl ;;
|
||||
*) check_args '1' '0' '[format] [limit] [offset]';;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -41,4 +80,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,15 +6,51 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/cert_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_cert() {
|
||||
# Print top bracket
|
||||
echo '['
|
||||
|
||||
# Checking certificates number
|
||||
certificates=$(ls $V_USERS/$user/cert/ |grep '.crt' )
|
||||
certificates_count=$(echo "$certificates" | wc -l)
|
||||
i=1
|
||||
|
||||
# Listing files by mask
|
||||
for cert in $certificates; do
|
||||
if [ $i -eq $certificates_count ]; then
|
||||
echo -e "\t\"${cert//.crt/}\""
|
||||
else
|
||||
echo -e "\t\"${cert//.crt/}\","
|
||||
fi
|
||||
(( ++i))
|
||||
done
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e "]"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_cert() {
|
||||
if [ -z "$nohead" ] ; then
|
||||
# Print brief info
|
||||
echo "Certificate"
|
||||
echo "----------"
|
||||
fi
|
||||
|
||||
# Listing files by mask
|
||||
for cert in $(ls $V_USERS/$user/cert/ | grep '.crt'); do
|
||||
# Print result
|
||||
echo "${cert//.crt/}"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -25,7 +61,7 @@ source $V_FUNC/cert_func.sh
|
|||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -36,9 +72,10 @@ is_user_valid
|
|||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) cert_json_list ;;
|
||||
shell) cert_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list_cert ;;
|
||||
plain) nohead=1; shell_list_cert ;;
|
||||
shell) shell_list_cert | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]' ;;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -49,4 +86,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -1,37 +1,23 @@
|
|||
#!/bin/bash
|
||||
# info: listing system ip
|
||||
# info: listing system config
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
format="${1-shell}"
|
||||
format=${1-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining functions
|
||||
conf_shell_list() {
|
||||
for str in $(cat $V_CONF/vesta.conf);do
|
||||
key=${str%%=*}
|
||||
value=${str#*=}
|
||||
echo "$key ${value//\'/}"
|
||||
done
|
||||
}
|
||||
|
||||
conf_json_list() {
|
||||
lines=$(wc -l $V_CONF/vesta.conf|cut -f 1 -d ' ')
|
||||
# Json function
|
||||
json_list_conf() {
|
||||
lines=$(wc -l $V_CONF/vesta.conf | cut -f 1 -d ' ')
|
||||
i='0'
|
||||
echo -e "{\n\t\"config\": {"
|
||||
for str in $(cat $V_CONF/vesta.conf); do
|
||||
i=$((i + 1))
|
||||
(( ++i))
|
||||
key=${str%%=*}
|
||||
value=${str#*=}
|
||||
|
||||
|
@ -44,12 +30,26 @@ conf_json_list() {
|
|||
echo -e "\t}\n}"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_conf() {
|
||||
for str in $(cat $V_CONF/vesta.conf); do
|
||||
key=${str%%=*}
|
||||
value=${str#*=}
|
||||
echo "$key: ${value//\'/}"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Listing system config
|
||||
case $format in
|
||||
json) conf_json_list ;;
|
||||
shell) conf_shell_list | column -t ;;
|
||||
*) check_args '1' "0" '[format]'
|
||||
json) json_list_conf ;;
|
||||
plain) shell_list_conf ;;
|
||||
shell) shell_list_conf | column -t ;;
|
||||
*) check_args '1' '0' '[format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -57,7 +57,4 @@ esac
|
|||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,15 +6,92 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/cron_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_cron() {
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Count fields
|
||||
fileds_count=$(echo $fields| wc -w )
|
||||
|
||||
# Reading file line by line
|
||||
while read line; do
|
||||
# New delimeter
|
||||
IFS=$'\n'
|
||||
|
||||
# Assing key=value pair
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Closing bracket if there already was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
IFS=' '
|
||||
for field in $fields; do
|
||||
eval value=\"$field\"
|
||||
value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
|
||||
|
||||
if [ $i -eq 1 ]; then
|
||||
# Printing parrent
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
# Printing child
|
||||
if [ $i -lt $fileds_count ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
data=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done < $conf
|
||||
|
||||
# Closing bracket if there was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_cron() {
|
||||
|
||||
if [ -z "$nohead" ] ; then
|
||||
# Print brief info
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "------ \c"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
# Reading file line by line
|
||||
while read line ; do
|
||||
# New delimeter
|
||||
IFS=$'\n'
|
||||
# Assing key=value pair
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result
|
||||
eval echo "$fields" | sed -e "s/%quote%/'/g"
|
||||
done < $conf
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -22,10 +99,10 @@ source $V_FUNC/cron_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -36,18 +113,21 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/cron.conf"
|
||||
conf=$V_USERS/$user/cron.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPEND $DATE'
|
||||
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) crn_json_list ;;
|
||||
shell) fields='$JOB~$SUSPEND~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD';
|
||||
crn_shell_list |column -t -s '~';;
|
||||
*) check_args '1' '0' 'user [format] [limit] [offset]' ;;
|
||||
json) json_list_cron ;;
|
||||
plain) nohead=1;
|
||||
fields="\"\$JOB\" \"\$SUSPEND\" \"\$MIN\" \"\$HOUR\" \"\$DAY\""
|
||||
fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\"";
|
||||
shell_list_cron ;;
|
||||
shell) fields='$JOB~$SUSPEND~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD';
|
||||
shell_list_cron |column -t -s '~';;
|
||||
*) check_args '1' '0' 'user [format]' ;;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -58,4 +138,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,22 +6,43 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
format="${1-shell}"
|
||||
limit="${2-1000}"
|
||||
offset="${3-1}"
|
||||
format=${1-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/ip_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_iface() {
|
||||
interfaces=$(cat /proc/net/dev | grep : | cut -f 1 -d : | tr -d ' ')
|
||||
int_counter=$(echo "$interfaces" | wc -l)
|
||||
i=1
|
||||
echo '['
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
# Listing ifaces
|
||||
for interface in $interfaces; do
|
||||
if [ "$i" -lt "$int_counter" ]; then
|
||||
echo -e "\t\"$interface\","
|
||||
else
|
||||
echo -e "\t\"$interface\""
|
||||
fi
|
||||
(( ++i))
|
||||
done
|
||||
echo "]"
|
||||
}
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'limit' 'offset'
|
||||
# Shell function
|
||||
shell_list_iface() {
|
||||
interfaces=$(cat /proc/net/dev | grep : | cut -f 1 -d : | tr -d ' ')
|
||||
if [ -z "$nohead" ]; then
|
||||
echo "INTERFACES"
|
||||
echo "----------"
|
||||
fi
|
||||
|
||||
for interface in $interfaces; do
|
||||
echo "$interface"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -30,9 +51,10 @@ format_validation 'limit' 'offset'
|
|||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) ipint_json_list ;;
|
||||
shell) ipint_shell_list ;;
|
||||
*) check_args '1' '0' '[format] [limit] [offset]'
|
||||
json) json_list_iface ;;
|
||||
plain) nohead=1; shell_list_iface ;;
|
||||
shell) shell_list_iface ;;
|
||||
*) check_args '1' '0' '[format]' ;;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -43,4 +65,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,14 +6,70 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
ip="$1"
|
||||
format="${2-shell}"
|
||||
ip=$1
|
||||
IP=$ip
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/ip_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_ip() {
|
||||
i=1
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
ip_data=$(cat $V_IPS/$IP)
|
||||
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Assign key=value
|
||||
for key in $ip_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
for field in $fields; do
|
||||
eval value=$field
|
||||
|
||||
# Checking first field
|
||||
if [ $i -eq 1 ]; then
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
if [ $fileds_count -eq $i ]; then
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
fi
|
||||
fi
|
||||
(( ++i))
|
||||
done
|
||||
|
||||
# If there was any output
|
||||
if [ -n "$value" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom json bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_ip() {
|
||||
line=$(cat $V_IPS/$IP)
|
||||
|
||||
# Assing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result line
|
||||
for field in $fields; do
|
||||
eval key="$field"
|
||||
echo "${field//$/}: $key "
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -31,16 +87,18 @@ is_sys_ip_valid
|
|||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
conf=$V_IPS/$IP
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS
|
||||
$INTERFACE $NETMASK $DATE'
|
||||
$INTERFACE $NETMASK $DATE'
|
||||
|
||||
# Listing ip
|
||||
case $format in
|
||||
json) ip_json_single_list ;;
|
||||
shell) ip_shell_single_list | column -t ;;
|
||||
*) check_args '1' "0" 'ip [format]'
|
||||
json) json_list_ip ;;
|
||||
plain) shell_list_ip ;;
|
||||
shell) shell_list_ip | column -t ;;
|
||||
*) check_args '1' '0' 'ip [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -51,4 +109,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -1,43 +1,114 @@
|
|||
#!/bin/bash
|
||||
# info: listing system users
|
||||
# info: listing system ips
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
format="${1-shell}"
|
||||
limit="${2-1000}"
|
||||
offset="${3-1}"
|
||||
format=${1-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/ip_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_ips() {
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
# Definining ip list
|
||||
ip_list=$(ls $V_IPS/)
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'limit' 'offset'
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
|
||||
# Starting main loop
|
||||
for IP in $ip_list; do
|
||||
# Assing key=value
|
||||
ip_data=$(cat $V_IPS/$IP)
|
||||
for key in $ip_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Closing bracket if there already was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
for field in $fields; do
|
||||
eval value=$field
|
||||
|
||||
if [ $i -eq 1 ]; then
|
||||
# Printing parrent
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
# Printing child
|
||||
if [ $i -lt $fileds_count ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
data=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Closing bracket if there was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_ips() {
|
||||
ip_list=$(ls $V_IPS/)
|
||||
|
||||
if [ -z "$nohead" ]; then
|
||||
# Print brief info
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "--------- \c"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
# Starting main loop
|
||||
for IP in $ip_list; do
|
||||
# Reading user data
|
||||
ip_data=$(cat $V_IPS/$IP)
|
||||
|
||||
# Assign key/value config
|
||||
for key in $ip_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result line
|
||||
eval echo "$fields"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
conf=$V_IPS/*
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS
|
||||
$INTERFACE $NETMASK $DATE'
|
||||
fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS"
|
||||
field=s"$fields \$INTERFACE \$NETMASK \$DATE"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) ip_json_list ;;
|
||||
shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS';
|
||||
ip_shell_list | column -t ;;
|
||||
*) check_args '1' '0' '[format] [limit] [offset]'
|
||||
json) json_list_ips ;;
|
||||
plain) nohead=1; shell_list_ips ;;
|
||||
shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS';
|
||||
shell_list_ips | column -t ;;
|
||||
*) check_args '1' '0' '[format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -48,4 +119,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,13 +6,71 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
user=$1
|
||||
USER="$user"
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_user() {
|
||||
i=1
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
line=$(cat $V_USERS/$USER/user.conf)
|
||||
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Assing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Starting output loop
|
||||
for field in $fields; do
|
||||
# Parsing key=value
|
||||
eval value=$field
|
||||
|
||||
# Checking first field
|
||||
if [ "$i" -eq 1 ]; then
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
if [ "$fileds_count" -eq "$i" ]; then
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
fi
|
||||
fi
|
||||
# Updating iterator
|
||||
(( ++i))
|
||||
done
|
||||
|
||||
# If there was any output
|
||||
if [ -n "$value" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
# Printing bottom json bracket
|
||||
echo -e "}"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_user() {
|
||||
line=$(cat $V_USERS/$USER/user.conf)
|
||||
|
||||
# Parsing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result line
|
||||
for field in $fields; do
|
||||
eval key="$field"
|
||||
echo "${field//$/}: $key "
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -33,7 +91,7 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/user.conf"
|
||||
conf=$V_USERS/$user/user.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES
|
||||
|
@ -44,9 +102,10 @@ fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES
|
|||
|
||||
# Listing user
|
||||
case $format in
|
||||
json) usr_json_single_list ;;
|
||||
shell) usr_shell_single_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format]'
|
||||
json) json_list_user ;;
|
||||
plain) nohead=1; shell_list_user ;;
|
||||
shell) shell_list_user | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]' ;;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -57,4 +116,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,25 +6,112 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/ip_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_user_ips() {
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
owned_ips=$(grep -l "OWNER='$user'" $V_IPS/*)
|
||||
shared_ips=$(grep -A5 "OWNER='vesta'" $V_IPS/* |\
|
||||
grep "STATUS='shared'"|\
|
||||
cut -f 1 -d - )
|
||||
|
||||
ip_list="$owned_ips $shared_ips"
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
|
||||
# Starting main loop
|
||||
for IP in $ip_list; do
|
||||
IP=$(basename $IP)
|
||||
ip_data=$(cat $V_IPS/$IP)
|
||||
|
||||
# Assing key=value
|
||||
for key in $ip_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Closing bracket if there already was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
for field in $fields; do
|
||||
eval value=$field
|
||||
|
||||
if [ $i -eq 1 ]; then
|
||||
# Printing parrent
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
# Printing child
|
||||
if [ $i -lt $fileds_count ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
data=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Closing bracket if there was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_user_ips() {
|
||||
owned_ips=$(grep -l "OWNER='$user'" $V_IPS/*)
|
||||
shared_ips=$(grep -A5 "OWNER='vesta'" $V_IPS/* |\
|
||||
grep "STATUS='shared'"|\
|
||||
cut -f 1 -d - )
|
||||
|
||||
ip_list="$owned_ips $shared_ips"
|
||||
if [ -z "$nohead" ]; then
|
||||
# Print brief info
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "--------- \c"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
# Starting main loop
|
||||
for IP in $ip_list; do
|
||||
IP=$(basename $IP)
|
||||
ip_data=$(cat $V_IPS/$IP)
|
||||
|
||||
# Assign key/value config
|
||||
for key in $ip_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result line
|
||||
eval echo "$fields"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Checking arg number
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -37,11 +124,12 @@ is_user_valid
|
|||
# Defining fileds to select
|
||||
fields='$IP $OWNER $STATUS $NAME'
|
||||
|
||||
# Listing domains
|
||||
# Listing ips
|
||||
case $format in
|
||||
json) ip_user_json_list ;;
|
||||
shell) ip_user_shell_list | column -t ;;
|
||||
*) check_args '1' '0' 'user [format] [limit] [offset]'
|
||||
json) json_list_user_ips ;;
|
||||
plain) nohead=1; shell_list_user_ips ;;
|
||||
shell) shell_list_user_ips | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]' ;;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -52,4 +140,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,13 +6,47 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_ns() {
|
||||
ns=$(grep "^NS='" $V_USERS/$user/user.conf |cut -f 2 -d \')
|
||||
# Print top bracket
|
||||
echo '['
|
||||
i=1
|
||||
nslistc=$(echo -e "${ns//,/\n}"|wc -l)
|
||||
# Listing servers
|
||||
for nameserver in ${ns//,/ };do
|
||||
if [ "$i" -ne "$nslistc" ]; then
|
||||
echo -e "\t\"$nameserver\","
|
||||
else
|
||||
echo -e "\t\"$nameserver\""
|
||||
fi
|
||||
(( ++i))
|
||||
done
|
||||
|
||||
echo "]"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_ns() {
|
||||
ns=$(grep "^NS='" $V_USERS/$user/user.conf |cut -f 2 -d \')
|
||||
if [ -z "$nohead" ]; then
|
||||
# Print result
|
||||
echo "NAMESERVER"
|
||||
echo "----------"
|
||||
fi
|
||||
|
||||
for nameserver in ${ns//,/ };do
|
||||
echo "$nameserver"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -34,9 +68,10 @@ is_user_valid
|
|||
|
||||
# Listing nameservers
|
||||
case $format in
|
||||
json) usrns_json_list ;;
|
||||
shell) usrns_shell_list ;;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
json) json_list_ns ;;
|
||||
plain) nohead=1; shell_list_ns ;;
|
||||
shell) shell_list_ns ;;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -47,4 +82,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,21 +6,86 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
format="${1-shell}"
|
||||
limit="${2-1000}"
|
||||
offset="${3-1}"
|
||||
format=${1-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_pkgs() {
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
|
||||
# Starting main loop
|
||||
for package in $(ls $V_DATA/packages); do
|
||||
PACKAGE=${package/.pkg/}
|
||||
# Assing key=value
|
||||
pkg_data=$(cat $V_DATA/packages/$package)
|
||||
for key in $pkg_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Closing bracket if there already was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
for field in $fields; do
|
||||
eval value=$field
|
||||
|
||||
if [ $i -eq 1 ]; then
|
||||
# Printing parrent
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
# Printing child
|
||||
if [ $i -lt $fileds_count ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
data=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Closing bracket if there was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell fnction
|
||||
shell_list_pkgs() {
|
||||
# Listing pkg files
|
||||
for package in $(ls $V_DATA/packages); do
|
||||
PACKAGE=${package/.pkg/}
|
||||
# Assign key=value
|
||||
pkg_descr=$(cat $V_DATA/packages/$package)
|
||||
for key in $pkg_descr; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
|
||||
if [ -z "$nohead" ]; then
|
||||
echo '----------'
|
||||
fi
|
||||
|
||||
for field in $fields; do
|
||||
eval value=$field
|
||||
echo -e "${field//$/}: $value"
|
||||
done
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'limit' 'offset'
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -29,14 +94,15 @@ format_validation 'limit' 'offset'
|
|||
|
||||
# Defining fields
|
||||
fields='$PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES $DATABASES $MAIL_DOMAINS
|
||||
$MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS $DISK_QUOTA $BANDWIDTH $NS1 $NS2
|
||||
$MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS $DISK_QUOTA $BANDWIDTH $NS
|
||||
$SHELL $BACKUPS $WEB_TPL'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) pkg_json_list ;;
|
||||
shell) pkg_shell_list | column -t ;;
|
||||
*) check_args '1' "0" '[format] [limit] [offset]'
|
||||
json) json_list_pkgs ;;
|
||||
plain) nohead=1; shell_list_pkgs ;;
|
||||
shell) shell_list_pkgs | column -t ;;
|
||||
*) check_args '1' '0' '[format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -47,4 +113,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,39 +6,104 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
format="${1-shell}"
|
||||
limit="${2-1000}"
|
||||
offset="${3-1}"
|
||||
format=${1-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_users() {
|
||||
echo '{'
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
# Starting main loop
|
||||
for USER in $(ls $V_USERS/); do
|
||||
# Reading user data
|
||||
user_data=$(cat $V_USERS/$USER/user.conf)
|
||||
|
||||
# Assign key/value config
|
||||
for key in $user_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Closing bracket if there already was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
for field in $fields; do
|
||||
eval value=$field
|
||||
|
||||
if [ $i -eq 1 ]; then
|
||||
# Printing parrent
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
# Printing child
|
||||
if [ $i -lt $fileds_count ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
data=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
# Closing bracket if there was output
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
|
||||
# Printing bottom bracket
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_users() {
|
||||
if [ -z "$nohead" ]; then
|
||||
# Print brief info
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "--------- \c"
|
||||
done
|
||||
echo # new line
|
||||
fi
|
||||
|
||||
# Starting main loop
|
||||
for USER in $(ls $V_USERS/); do
|
||||
user_data=$(cat $V_USERS/$USER/user.conf)
|
||||
|
||||
# Assign key/value config
|
||||
for key in $user_data; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
eval echo "$fields"
|
||||
done
|
||||
}
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'limit' 'offset'
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES
|
||||
$DATABASES $MAIL_DOMAINS $MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS
|
||||
$DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $WEB_TPL $SUSPENDED $IP_OWNED
|
||||
$U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_DNS_DOMAINS $U_DATABASES
|
||||
$U_MAIL_DOMAINS $CONTACT $DATE'
|
||||
fields="\$USER \$FNAME \$LNAME \$PACKAGE \$WEB_DOMAINS \$WEB_SSL \$WEB_ALIASES"
|
||||
fields="$fields \$DATABASES \$MAIL_DOMAINS \$MAIL_BOXES \$MAIL_FORWARDERS"
|
||||
fields="$fields \$DNS_DOMAINS \$DISK_QUOTA \$BANDWIDTH \$NS \$SHELL \$BACKUPS"
|
||||
fields="$fields \$WEB_TPL \$SUSPENDED \$IP_OWNED \$U_DISK \$U_BANDWIDTH"
|
||||
fields="$fields \$U_WEB_DOMAINS \$U_WEB_SSL \$U_DNS_DOMAINS \$U_DATABASES"
|
||||
fields="$fields \$U_MAIL_DOMAINS \$CONTACT \$DATE"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) usr_json_list ;;
|
||||
shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE';
|
||||
usr_shell_list | column -t ;;
|
||||
*) check_args '1' '0' '[format] [limit] [offset]'
|
||||
json) json_list_users ;;
|
||||
plain) nohead=1; shell_list_users ;;
|
||||
shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE';
|
||||
shell_list_users | column -t ;;
|
||||
*) check_args '1' '0' '[format]' ;;
|
||||
esac
|
||||
|
||||
|
||||
|
@ -49,4 +114,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,16 +6,72 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
format="${3-shell}"
|
||||
user=$1
|
||||
domain=$2
|
||||
format=${3-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/domain_func.sh
|
||||
|
||||
# Json function
|
||||
json_list_domain() {
|
||||
i=1
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
line=$(grep "DOMAIN='$domain'" $conf)
|
||||
|
||||
# Print top bracket
|
||||
echo '{'
|
||||
|
||||
# Assing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Starting output loop
|
||||
for field in $fields; do
|
||||
# Parsing key=value
|
||||
eval value=$field
|
||||
|
||||
# Checking first field
|
||||
if [ "$i" -eq 1 ]; then
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
if [ "$fileds_count" -eq "$i" ]; then
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||
else
|
||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||
fi
|
||||
fi
|
||||
# Updating iterator
|
||||
(( ++i))
|
||||
done
|
||||
|
||||
# If there was any output
|
||||
if [ -n "$value" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
# Printing bottom json bracket
|
||||
echo -e "}"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_domain() {
|
||||
line=$(cat $V_USERS/$user/web.conf)
|
||||
|
||||
# Parsing key=value
|
||||
for key in $line; do
|
||||
eval ${key%%=*}=${key#*=}
|
||||
done
|
||||
|
||||
# Print result line
|
||||
for field in $fields; do
|
||||
eval key="$field"
|
||||
echo "${field//$/}: $key "
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
|
@ -36,7 +92,7 @@ is_web_domain_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/web.conf"
|
||||
conf=$V_USERS/$user/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG $STATS
|
||||
|
@ -44,9 +100,10 @@ fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG $STATS
|
|||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) dom_json_single_list ;;
|
||||
shell) dom_shell_single_list | column -t ;;
|
||||
*) check_args '2' "0" 'user domain [format]'
|
||||
json) json_list_domain ;;
|
||||
plain) nohead=1; shell_list_domain ;;
|
||||
shell) shell_list_domain | column -t ;;
|
||||
*) check_args '2' '0' 'user domain [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -57,4 +114,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -35,19 +33,20 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/web.conf"
|
||||
conf=$V_USERS/$user/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG $STATS
|
||||
$STATS_AUTH $SSL_HOME $SSL_CERT $NGINX $NGINX_EXT $SUSPEND $DATE'
|
||||
|
||||
fields="\$DOMAIN \$IP \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$PHP \$CGI \$ELOG"
|
||||
fields="$fields \$STATS \$STATS_AUTH \$SSL_HOME \$SSL_CERT \$NGINX \$NGINX_EXT"
|
||||
fields="$fields \$SUSPEND \$DATE"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE';
|
||||
v_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE';
|
||||
shell_list | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -58,4 +57,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -35,16 +33,17 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/web.conf"
|
||||
conf=$V_USERS/$user/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $ALIAS'
|
||||
fields="\$DOMAIN \$ALIAS"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) v_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) shell_list | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -55,4 +54,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -35,16 +33,17 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/web.conf"
|
||||
conf=$V_USERS/$user/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $ELOG'
|
||||
fields="\$DOMAIN \$ELOG"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) v_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) shell_list | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -55,4 +54,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -35,16 +33,17 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/web.conf"
|
||||
conf=$V_USERS/$user/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $NGINX'
|
||||
fields="\$DOMAIN \$NGINX \$NGINX_EXT"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) v_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) shell_list | column -t ;;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -55,4 +54,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -38,13 +36,14 @@ is_user_valid
|
|||
conf="$V_USERS/$user/web.conf"
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $SSL_HOME $SSL_CERT'
|
||||
fields="\$DOMAIN \$SSL_HOME \$SSL_CERT"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) v_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -55,4 +54,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking args
|
||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||
check_args '1' "$#" 'user [format]'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
@ -35,16 +33,17 @@ is_user_valid
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf="$V_USERS/$user/web.conf"
|
||||
conf=$V_USERS/$user/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $STATS $STATS_AUTH'
|
||||
fields="\$DOMAIN \$STATS \$STATS_AUTH"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) v_json_list ;;
|
||||
shell) v_shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) shell_list | column -t ;;
|
||||
*) check_args '1' "0" 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -55,4 +54,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -6,15 +6,12 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user="$1"
|
||||
format="${2-shell}"
|
||||
limit="${3-1000}"
|
||||
offset="${4-1}"
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Importing variables
|
||||
source $VESTA/conf/vars.conf
|
||||
source $V_FUNC/shared_func.sh
|
||||
source $V_FUNC/domain_func.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -25,11 +22,51 @@ source $V_FUNC/domain_func.sh
|
|||
check_args '1' "$#" 'user'
|
||||
|
||||
# Checking argument format
|
||||
format_validation 'user' 'limit' 'offset'
|
||||
format_validation 'user'
|
||||
|
||||
# Checking user
|
||||
is_user_valid
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
|
@ -40,9 +77,10 @@ templates=$(get_user_value '$WEB_TPL')
|
|||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) webtpl_json_list ;;
|
||||
shell) webtpl_shell_list ;;
|
||||
*) check_args '1' "0" '[format] [limit] [offset]'
|
||||
json) json_list_wtpl ;;
|
||||
plain) nohead=1; shell_list_wtpl ;;
|
||||
shell) shell_list_wtpl ;;
|
||||
*) check_args '1' '0' '[format]'
|
||||
esac
|
||||
|
||||
|
||||
|
@ -53,4 +91,4 @@ esac
|
|||
# Logging
|
||||
log_event 'system' "$V_EVENT"
|
||||
|
||||
exit $OK
|
||||
exit
|
||||
|
|
|
@ -28,7 +28,8 @@ fi
|
|||
# Parsing db hosts
|
||||
conf="$V_DB/mysql.conf"
|
||||
fields='$HOST'
|
||||
hosts=$(v_clear_list)
|
||||
nohead=1
|
||||
hosts=$(shel_list)
|
||||
check_row=$(echo "$hosts" |wc -l)
|
||||
if [ 0 -eq "$check_row" ]; then
|
||||
exit
|
||||
|
|
|
@ -28,7 +28,8 @@ fi
|
|||
# Parsing db hosts
|
||||
conf="$V_DB/pgsql.conf"
|
||||
fields='$HOST'
|
||||
hosts=$(v_clear_list)
|
||||
nohead=1
|
||||
hosts=$(shell_list)
|
||||
check_row=$(echo "$hosts" |wc -l)
|
||||
if [ 0 -eq "$check_row" ]; then
|
||||
exit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue