mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -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
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
database="$2"
|
database=$2
|
||||||
format="${3-shell}"
|
format=${3-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/db_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 #
|
# Verifications #
|
||||||
|
@ -38,16 +104,17 @@ is_db_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/db.conf"
|
conf=$V_USERS/$user/db.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
||||||
|
|
||||||
# Listing database
|
# Listing database
|
||||||
case $format in
|
case $format in
|
||||||
json) db_json_single_list ;;
|
json) json_list_db ;;
|
||||||
shell) db_shell_single_list | column -t ;;
|
plain) shell_list_db ;;
|
||||||
*) check_args '2' "0" 'user database [format]'
|
shell) shell_list_db | column -t ;;
|
||||||
|
*) check_args '2' '0' 'user database [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,4 +125,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -35,16 +33,17 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/db.conf"
|
conf=$V_USERS/$user/db.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
|
||||||
|
|
||||||
# Listing databases
|
# Listing databases
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
shell) v_shell_list| column -t ;;
|
plain) nohead=1; shell_list ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
shell) shell_list | column -t ;;
|
||||||
|
*) check_args '1' '0' 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,4 +54,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,15 +6,79 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
type="$1"
|
type=$1
|
||||||
host="$2"
|
host=$2
|
||||||
format="${3-shell}"
|
format=${3-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/db_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 #
|
# Verifications #
|
||||||
|
@ -38,16 +102,17 @@ is_db_host_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config type
|
# Defining config type
|
||||||
conf="$V_DB/$type.conf"
|
conf=$V_DB/$type.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
|
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
|
||||||
|
|
||||||
# Listing database
|
# Listing database
|
||||||
case $format in
|
case $format in
|
||||||
json) dbhost_json_single_list ;;
|
json) json_list_dbhost ;;
|
||||||
shell) dbhost_shell_single_list | column -t;;
|
plain) nohead=1; shell_list_dbhost ;;
|
||||||
*) check_args '2' "0" 'type host [format]'
|
shell) shell_list_dbhost | column -t;;
|
||||||
|
*) check_args '2' '0' 'type host [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,4 +123,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
type="$1"
|
type=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
|
@ -36,17 +34,18 @@ is_type_valid 'db' "$type"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config type
|
# Defining config type
|
||||||
conf="$V_DB/$type.conf"
|
conf=$V_DB/$type.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
|
fields='$HOST $PORT $MAX_USERS $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'
|
||||||
|
|
||||||
# Listing database
|
# Listing database
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
|
plain) nohead=1; shell_list;;
|
||||||
shell) fields='$HOST $PORT $MAX_USERS $MAX_DB $U_DB_BASES $ACTIVE $DATE';
|
shell) fields='$HOST $PORT $MAX_USERS $MAX_DB $U_DB_BASES $ACTIVE $DATE';
|
||||||
v_shell_list | column -t ;;
|
shell_list | column -t ;;
|
||||||
*) check_args '2' "0" 'type [format] [limit] [offset]'
|
*) check_args '2' '0' 'type [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,4 +56,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,18 +6,95 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$2
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
format=${3-shell}
|
||||||
format="${3-shell}"
|
|
||||||
limit="${4-1000}"
|
|
||||||
offset="${5-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/domain_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 #
|
# Verifications #
|
||||||
|
@ -27,7 +104,7 @@ source $V_FUNC/domain_func.sh
|
||||||
check_args '2' "$#" 'user domain [format]'
|
check_args '2' "$#" 'user domain [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'domain' 'limit' 'offset'
|
format_validation 'user' 'domain'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -41,17 +118,18 @@ is_dns_domain_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/zones/$domain"
|
conf=$V_USERS/$user/zones/$domain
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$ID $RECORD $TYPE $VALUE $SUSPEND $DATE'
|
fields='$ID $RECORD $TYPE $VALUE $SUSPEND $DATE'
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) dns_json_list ;;
|
json) json_list_dns ;;
|
||||||
|
plain) nohead=1; shell_list_dns ;;
|
||||||
shell) fields='$ID $RECORD $TYPE $VALUE';
|
shell) fields='$ID $RECORD $TYPE $VALUE';
|
||||||
dns_shell_list | column -t ;;
|
shell_list_dns | column -t ;;
|
||||||
*) check_args '2' "0" 'user domain [format]'
|
*) check_args '2' '0' 'user domain [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,4 +140,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -35,7 +33,7 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/dns.conf"
|
conf=$V_USERS/$user/dns.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $SUSPEND $DATE'
|
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $SUSPEND $DATE'
|
||||||
|
@ -43,10 +41,11 @@ fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $SUSPEND $DATE'
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
|
plain) nohead=1; shell_list ;;
|
||||||
shell) fields='$DOMAIN $IP $TPL $TTL $EXP $SUSPEND';
|
shell) fields='$DOMAIN $IP $TPL $TTL $EXP $SUSPEND';
|
||||||
v_shell_list| column -t ;;
|
shell_list| column -t ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
*) check_args '1' '0' 'user [format]';;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,4 +56,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
template="$1"
|
template=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -30,22 +28,103 @@ format_validation 'template'
|
||||||
# Checking template
|
# Checking template
|
||||||
is_template_valid 'dns'
|
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 #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_DNSTPL/$template.tpl"
|
conf=$V_DNSTPL/$template.tpl
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$RECORD $TYPE $VALUE'
|
fields='$RECORD $TYPE $VALUE'
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) dns_json_list ;;
|
json) json_list_dns ;;
|
||||||
shell) dns_shell_list | column -t ;;
|
plain) nohead=1; shell_list_dns ;;
|
||||||
*) check_args '1' "0" 'template [format]'
|
shell) shell_list_dns | column -t ;;
|
||||||
|
*) check_args '1' '0' 'template [format]';;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,4 +135,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,21 +6,59 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format="${1-shell}"
|
format=${1-shell}
|
||||||
limit="${2-1000}"
|
|
||||||
offset="${3-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/domain_func.sh
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
# Json function
|
||||||
# Verifications #
|
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 #
|
# Action #
|
||||||
|
@ -28,9 +66,10 @@ format_validation 'limit' 'offset'
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) dnstpl_json_list ;;
|
json) json_list_dnstpl;;
|
||||||
shell) dnstpl_shell_list ;;
|
plain) nohead=1; shell_list_dnstpl ;;
|
||||||
*) check_args '1' "0" '[format] [limit] [offset]'
|
shell) shell_list_dnstpl ;;
|
||||||
|
*) check_args '1' '0' '[format] [limit] [offset]';;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,4 +80,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,15 +6,51 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
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]'
|
check_args '1' "$#" 'user [format] [limit] [offset]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -36,9 +72,10 @@ is_user_valid
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) cert_json_list ;;
|
json) json_list_cert ;;
|
||||||
shell) cert_shell_list | column -t ;;
|
plain) nohead=1; shell_list_cert ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
shell) shell_list_cert | column -t ;;
|
||||||
|
*) check_args '1' '0' 'user [format]' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,4 +86,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -1,37 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: listing system ip
|
# info: listing system config
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format="${1-shell}"
|
format=${1-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
|
||||||
|
|
||||||
|
# Json function
|
||||||
#----------------------------------------------------------#
|
json_list_conf() {
|
||||||
# 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 ' ')
|
lines=$(wc -l $V_CONF/vesta.conf | cut -f 1 -d ' ')
|
||||||
i='0'
|
i='0'
|
||||||
echo -e "{\n\t\"config\": {"
|
echo -e "{\n\t\"config\": {"
|
||||||
for str in $(cat $V_CONF/vesta.conf); do
|
for str in $(cat $V_CONF/vesta.conf); do
|
||||||
i=$((i + 1))
|
(( ++i))
|
||||||
key=${str%%=*}
|
key=${str%%=*}
|
||||||
value=${str#*=}
|
value=${str#*=}
|
||||||
|
|
||||||
|
@ -44,12 +30,26 @@ conf_json_list() {
|
||||||
echo -e "\t}\n}"
|
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
|
# Listing system config
|
||||||
case $format in
|
case $format in
|
||||||
json) conf_json_list ;;
|
json) json_list_conf ;;
|
||||||
shell) conf_shell_list | column -t ;;
|
plain) shell_list_conf ;;
|
||||||
*) check_args '1' "0" '[format]'
|
shell) shell_list_conf | column -t ;;
|
||||||
|
*) check_args '1' '0' '[format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,4 @@ esac
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Logging
|
exit
|
||||||
log_event 'system' "$V_EVENT"
|
|
||||||
|
|
||||||
exit $OK
|
|
||||||
|
|
|
@ -6,15 +6,92 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
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
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -36,18 +113,21 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/cron.conf"
|
conf=$V_USERS/$user/cron.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPEND $DATE'
|
fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPEND $DATE'
|
||||||
|
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) crn_json_list ;;
|
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) fields='$JOB~$SUSPEND~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD';
|
||||||
crn_shell_list |column -t -s '~';;
|
shell_list_cron |column -t -s '~';;
|
||||||
*) check_args '1' '0' 'user [format] [limit] [offset]' ;;
|
*) check_args '1' '0' 'user [format]' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,4 +138,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,22 +6,43 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format="${1-shell}"
|
format=${1-shell}
|
||||||
limit="${2-1000}"
|
|
||||||
offset="${3-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
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 '['
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
# Listing ifaces
|
||||||
# Verifications #
|
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
|
# Shell function
|
||||||
format_validation 'limit' 'offset'
|
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
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) ipint_json_list ;;
|
json) json_list_iface ;;
|
||||||
shell) ipint_shell_list ;;
|
plain) nohead=1; shell_list_iface ;;
|
||||||
*) check_args '1' '0' '[format] [limit] [offset]'
|
shell) shell_list_iface ;;
|
||||||
|
*) check_args '1' '0' '[format]' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,4 +65,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,14 +6,70 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
ip="$1"
|
ip=$1
|
||||||
format="${2-shell}"
|
IP=$ip
|
||||||
|
format=${2-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/ip_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 #
|
# Verifications #
|
||||||
|
@ -31,6 +87,7 @@ is_sys_ip_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
conf=$V_IPS/$IP
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS
|
fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS
|
||||||
|
@ -38,9 +95,10 @@ fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS
|
||||||
|
|
||||||
# Listing ip
|
# Listing ip
|
||||||
case $format in
|
case $format in
|
||||||
json) ip_json_single_list ;;
|
json) json_list_ip ;;
|
||||||
shell) ip_shell_single_list | column -t ;;
|
plain) shell_list_ip ;;
|
||||||
*) check_args '1' "0" 'ip [format]'
|
shell) shell_list_ip | column -t ;;
|
||||||
|
*) check_args '1' '0' 'ip [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,4 +109,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -1,43 +1,114 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: listing system users
|
# info: listing system ips
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format="${1-shell}"
|
format=${1-shell}
|
||||||
limit="${2-1000}"
|
|
||||||
offset="${3-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/ip_func.sh
|
|
||||||
|
|
||||||
|
# Json function
|
||||||
|
json_list_ips() {
|
||||||
|
# Print top bracket
|
||||||
|
echo '{'
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
# Definining ip list
|
||||||
# Verifications #
|
ip_list=$(ls $V_IPS/)
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Checking argument format
|
fileds_count=$(echo "$fields" | wc -w)
|
||||||
format_validation 'limit' 'offset'
|
|
||||||
|
# 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 #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
conf=$V_IPS/*
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS
|
fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS"
|
||||||
$INTERFACE $NETMASK $DATE'
|
field=s"$fields \$INTERFACE \$NETMASK \$DATE"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) ip_json_list ;;
|
json) json_list_ips ;;
|
||||||
|
plain) nohead=1; shell_list_ips ;;
|
||||||
shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS';
|
shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS';
|
||||||
ip_shell_list | column -t ;;
|
shell_list_ips | column -t ;;
|
||||||
*) check_args '1' '0' '[format] [limit] [offset]'
|
*) check_args '1' '0' '[format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,4 +119,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,13 +6,71 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
USER="$user"
|
||||||
|
format=${2-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
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 #
|
# Verifications #
|
||||||
|
@ -33,7 +91,7 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/user.conf"
|
conf=$V_USERS/$user/user.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES
|
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
|
# Listing user
|
||||||
case $format in
|
case $format in
|
||||||
json) usr_json_single_list ;;
|
json) json_list_user ;;
|
||||||
shell) usr_shell_single_list | column -t ;;
|
plain) nohead=1; shell_list_user ;;
|
||||||
*) check_args '1' "0" 'user [format]'
|
shell) shell_list_user | column -t ;;
|
||||||
|
*) check_args '1' '0' 'user [format]' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,4 +116,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,25 +6,112 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
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 #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
# Checking arg number
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -37,11 +124,12 @@ is_user_valid
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$IP $OWNER $STATUS $NAME'
|
fields='$IP $OWNER $STATUS $NAME'
|
||||||
|
|
||||||
# Listing domains
|
# Listing ips
|
||||||
case $format in
|
case $format in
|
||||||
json) ip_user_json_list ;;
|
json) json_list_user_ips ;;
|
||||||
shell) ip_user_shell_list | column -t ;;
|
plain) nohead=1; shell_list_user_ips ;;
|
||||||
*) check_args '1' '0' 'user [format] [limit] [offset]'
|
shell) shell_list_user_ips | column -t ;;
|
||||||
|
*) check_args '1' '0' 'user [format]' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,4 +140,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,13 +6,47 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
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 #
|
# Verifications #
|
||||||
|
@ -34,8 +68,9 @@ is_user_valid
|
||||||
|
|
||||||
# Listing nameservers
|
# Listing nameservers
|
||||||
case $format in
|
case $format in
|
||||||
json) usrns_json_list ;;
|
json) json_list_ns ;;
|
||||||
shell) usrns_shell_list ;;
|
plain) nohead=1; shell_list_ns ;;
|
||||||
|
shell) shell_list_ns ;;
|
||||||
*) check_args '1' '0' 'user [format]'
|
*) check_args '1' '0' 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -47,4 +82,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,21 +6,86 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format="${1-shell}"
|
format=${1-shell}
|
||||||
limit="${2-1000}"
|
|
||||||
offset="${3-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
|
|
||||||
|
# Json function
|
||||||
|
json_list_pkgs() {
|
||||||
|
# Print top bracket
|
||||||
|
echo '{'
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
fileds_count=$(echo "$fields" | wc -w)
|
||||||
# Verifications #
|
|
||||||
#----------------------------------------------------------#
|
# 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
|
# Defining fields
|
||||||
fields='$PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES $DATABASES $MAIL_DOMAINS
|
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'
|
$SHELL $BACKUPS $WEB_TPL'
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) pkg_json_list ;;
|
json) json_list_pkgs ;;
|
||||||
shell) pkg_shell_list | column -t ;;
|
plain) nohead=1; shell_list_pkgs ;;
|
||||||
*) check_args '1' "0" '[format] [limit] [offset]'
|
shell) shell_list_pkgs | column -t ;;
|
||||||
|
*) check_args '1' '0' '[format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,4 +113,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,39 +6,104 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format="${1-shell}"
|
format=${1-shell}
|
||||||
limit="${2-1000}"
|
|
||||||
offset="${3-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
|
|
||||||
|
# Json function
|
||||||
|
json_list_users() {
|
||||||
|
echo '{'
|
||||||
|
fileds_count=$(echo "$fields" | wc -w)
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
# Starting main loop
|
||||||
# Verifications #
|
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 #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES
|
fields="\$USER \$FNAME \$LNAME \$PACKAGE \$WEB_DOMAINS \$WEB_SSL \$WEB_ALIASES"
|
||||||
$DATABASES $MAIL_DOMAINS $MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS
|
fields="$fields \$DATABASES \$MAIL_DOMAINS \$MAIL_BOXES \$MAIL_FORWARDERS"
|
||||||
$DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $WEB_TPL $SUSPENDED $IP_OWNED
|
fields="$fields \$DNS_DOMAINS \$DISK_QUOTA \$BANDWIDTH \$NS \$SHELL \$BACKUPS"
|
||||||
$U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_DNS_DOMAINS $U_DATABASES
|
fields="$fields \$WEB_TPL \$SUSPENDED \$IP_OWNED \$U_DISK \$U_BANDWIDTH"
|
||||||
$U_MAIL_DOMAINS $CONTACT $DATE'
|
fields="$fields \$U_WEB_DOMAINS \$U_WEB_SSL \$U_DNS_DOMAINS \$U_DATABASES"
|
||||||
|
fields="$fields \$U_MAIL_DOMAINS \$CONTACT \$DATE"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) usr_json_list ;;
|
json) json_list_users ;;
|
||||||
|
plain) nohead=1; shell_list_users ;;
|
||||||
shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE';
|
shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE';
|
||||||
usr_shell_list | column -t ;;
|
shell_list_users | column -t ;;
|
||||||
*) check_args '1' '0' '[format] [limit] [offset]'
|
*) check_args '1' '0' '[format]' ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,4 +114,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,16 +6,72 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$2
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
format=${3-shell}
|
||||||
format="${3-shell}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
source $V_FUNC/shared_func.sh
|
||||||
source $V_FUNC/domain_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 #
|
# Verifications #
|
||||||
|
@ -36,7 +92,7 @@ is_web_domain_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/web.conf"
|
conf=$V_USERS/$user/web.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG $STATS
|
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
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) dom_json_single_list ;;
|
json) json_list_domain ;;
|
||||||
shell) dom_shell_single_list | column -t ;;
|
plain) nohead=1; shell_list_domain ;;
|
||||||
*) check_args '2' "0" 'user domain [format]'
|
shell) shell_list_domain | column -t ;;
|
||||||
|
*) check_args '2' '0' 'user domain [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,4 +114,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -35,19 +33,20 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/web.conf"
|
conf=$V_USERS/$user/web.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG $STATS
|
fields="\$DOMAIN \$IP \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$PHP \$CGI \$ELOG"
|
||||||
$STATS_AUTH $SSL_HOME $SSL_CERT $NGINX $NGINX_EXT $SUSPEND $DATE'
|
fields="$fields \$STATS \$STATS_AUTH \$SSL_HOME \$SSL_CERT \$NGINX \$NGINX_EXT"
|
||||||
|
fields="$fields \$SUSPEND \$DATE"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
|
plain) nohead=1; shell_list ;;
|
||||||
shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE';
|
shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE';
|
||||||
v_shell_list | column -t ;;
|
shell_list | column -t ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
*) check_args '1' '0' 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,4 +57,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -35,16 +33,17 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/web.conf"
|
conf=$V_USERS/$user/web.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $ALIAS'
|
fields="\$DOMAIN \$ALIAS"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
shell) v_shell_list | column -t ;;
|
plain) nohead=1; shell_list ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
shell) shell_list | column -t ;;
|
||||||
|
*) check_args '1' '0' 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,4 +54,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -35,16 +33,17 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/web.conf"
|
conf=$V_USERS/$user/web.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $ELOG'
|
fields="\$DOMAIN \$ELOG"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
shell) v_shell_list | column -t ;;
|
plain) nohead=1; shell_list ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
shell) shell_list | column -t ;;
|
||||||
|
*) check_args '1' '0' 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,4 +54,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -35,16 +33,17 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/web.conf"
|
conf=$V_USERS/$user/web.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $NGINX'
|
fields="\$DOMAIN \$NGINX \$NGINX_EXT"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
shell) v_shell_list | column -t ;;
|
plain) nohead=1; shell_list ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
shell) shell_list | column -t ;;
|
||||||
|
*) check_args '1' '0' 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,4 +54,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -38,13 +36,14 @@ is_user_valid
|
||||||
conf="$V_USERS/$user/web.conf"
|
conf="$V_USERS/$user/web.conf"
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $SSL_HOME $SSL_CERT'
|
fields="\$DOMAIN \$SSL_HOME \$SSL_CERT"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
shell) v_shell_list | column -t ;;
|
plain) nohead=1; shell_list ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
shell) shell_list | column -t ;;
|
||||||
|
*) check_args '1' "0" 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,4 +54,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
|
@ -21,10 +19,10 @@ source $V_FUNC/shared_func.sh
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
# Checking args
|
||||||
check_args '1' "$#" 'user [format] [limit] [offset]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
is_user_valid
|
||||||
|
@ -35,16 +33,17 @@ is_user_valid
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
# Defining config
|
||||||
conf="$V_USERS/$user/web.conf"
|
conf=$V_USERS/$user/web.conf
|
||||||
|
|
||||||
# Defining fileds to select
|
# Defining fileds to select
|
||||||
fields='$DOMAIN $STATS $STATS_AUTH'
|
fields="\$DOMAIN \$STATS \$STATS_AUTH"
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) v_json_list ;;
|
json) json_list ;;
|
||||||
shell) v_shell_list | column -t ;;
|
plain) nohead=1; shell_list ;;
|
||||||
*) check_args '1' "0" 'user [format] [limit] [offset]'
|
shell) shell_list | column -t ;;
|
||||||
|
*) check_args '1' "0" 'user [format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,4 +54,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -6,15 +6,12 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user="$1"
|
user=$1
|
||||||
format="${2-shell}"
|
format=${2-shell}
|
||||||
limit="${3-1000}"
|
|
||||||
offset="${4-1}"
|
|
||||||
|
|
||||||
# Importing variables
|
# Importing variables
|
||||||
source $VESTA/conf/vars.conf
|
source $VESTA/conf/vars.conf
|
||||||
source $V_FUNC/shared_func.sh
|
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'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
# Checking argument format
|
||||||
format_validation 'user' 'limit' 'offset'
|
format_validation 'user'
|
||||||
|
|
||||||
# Checking user
|
# Checking user
|
||||||
is_user_valid
|
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 #
|
# Action #
|
||||||
|
@ -40,9 +77,10 @@ templates=$(get_user_value '$WEB_TPL')
|
||||||
|
|
||||||
# Listing domains
|
# Listing domains
|
||||||
case $format in
|
case $format in
|
||||||
json) webtpl_json_list ;;
|
json) json_list_wtpl ;;
|
||||||
shell) webtpl_shell_list ;;
|
plain) nohead=1; shell_list_wtpl ;;
|
||||||
*) check_args '1' "0" '[format] [limit] [offset]'
|
shell) shell_list_wtpl ;;
|
||||||
|
*) check_args '1' '0' '[format]'
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,4 +91,4 @@ esac
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
exit $OK
|
exit
|
||||||
|
|
|
@ -28,7 +28,8 @@ fi
|
||||||
# Parsing db hosts
|
# Parsing db hosts
|
||||||
conf="$V_DB/mysql.conf"
|
conf="$V_DB/mysql.conf"
|
||||||
fields='$HOST'
|
fields='$HOST'
|
||||||
hosts=$(v_clear_list)
|
nohead=1
|
||||||
|
hosts=$(shel_list)
|
||||||
check_row=$(echo "$hosts" |wc -l)
|
check_row=$(echo "$hosts" |wc -l)
|
||||||
if [ 0 -eq "$check_row" ]; then
|
if [ 0 -eq "$check_row" ]; then
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -28,7 +28,8 @@ fi
|
||||||
# Parsing db hosts
|
# Parsing db hosts
|
||||||
conf="$V_DB/pgsql.conf"
|
conf="$V_DB/pgsql.conf"
|
||||||
fields='$HOST'
|
fields='$HOST'
|
||||||
hosts=$(v_clear_list)
|
nohead=1
|
||||||
|
hosts=$(shell_list)
|
||||||
check_row=$(echo "$hosts" |wc -l)
|
check_row=$(echo "$hosts" |wc -l)
|
||||||
if [ 0 -eq "$check_row" ]; then
|
if [ 0 -eq "$check_row" ]; then
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -74,55 +74,3 @@ is_cert_used() {
|
||||||
exit $E_CERT_USED
|
exit $E_CERT_USED
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cert_json_list() {
|
|
||||||
|
|
||||||
# Definigng variables
|
|
||||||
i='1' # iterator
|
|
||||||
j='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '['
|
|
||||||
|
|
||||||
# Checking certificates number
|
|
||||||
last=$(ls $V_USERS/$user/cert/|grep '.crt' | wc -l)
|
|
||||||
|
|
||||||
# Listing files by mask
|
|
||||||
for cert in $(ls $V_USERS/$user/cert/|grep '.crt'); do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
if [ "$i" -ne "$last" ] && [ "$j" -ne "$limit" ]; then
|
|
||||||
echo -e "\t\"${cert//.crt/}\","
|
|
||||||
else
|
|
||||||
echo -e "\t\"${cert//.crt/}\""
|
|
||||||
fi
|
|
||||||
j=$(($j + 1))
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# Printing bottom bracket
|
|
||||||
echo -e "]"
|
|
||||||
}
|
|
||||||
|
|
||||||
cert_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print brief info
|
|
||||||
echo "Certificate"
|
|
||||||
echo "----------"
|
|
||||||
|
|
||||||
# Listing files by mask
|
|
||||||
for cert in $(ls $V_USERS/$user/cert/|grep '.crt'); do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Print result
|
|
||||||
echo "${cert//.crt/}"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
|
@ -72,94 +72,6 @@ del_cron_job() {
|
||||||
sed -i "$str d" $V_USERS/$user/cron.conf
|
sed -i "$str d" $V_USERS/$user/cron.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
crn_json_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
while read line ; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Defining new delimeter
|
|
||||||
IFS=$'\n'
|
|
||||||
# Parsing key=value
|
|
||||||
for key in $(echo $line|sed -e "s/' /'\n/g"); do
|
|
||||||
eval ${key%%=*}="${key#*=}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Checking !first line to print bracket
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
j=1 # local loop iterator
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Restoring old delimeter
|
|
||||||
IFS=' '
|
|
||||||
# Print data
|
|
||||||
for field in $fields; do
|
|
||||||
eval value=\"$field\"
|
|
||||||
value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
|
|
||||||
|
|
||||||
# Checking parrent key
|
|
||||||
if [ "$j" -eq 1 ]; then
|
|
||||||
echo -e "\t\"$value\": {"
|
|
||||||
else
|
|
||||||
if [ "$j" -eq "$last_word" ]; then
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
|
||||||
else
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
j=$(($j + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done < $conf
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo -e "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
crn_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print brief info
|
|
||||||
echo "${fields//$/}"
|
|
||||||
for a in $(echo ${fields//\~/ /}); do
|
|
||||||
echo -e "-----~\c"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
while read line ; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Defining new delimeter
|
|
||||||
IFS=$'\n'
|
|
||||||
# Parsing key=value
|
|
||||||
for key in $(echo $line|sed -e "s/' /'\n/g"); do
|
|
||||||
eval ${key%%=*}="${key#*=}"
|
|
||||||
done
|
|
||||||
# Print result line
|
|
||||||
eval echo "\"$fields\""|sed -e "s/%quote%/'/g"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done < $conf
|
|
||||||
}
|
|
||||||
|
|
||||||
is_job_suspended() {
|
is_job_suspended() {
|
||||||
# Parsing jobs
|
# Parsing jobs
|
||||||
|
|
132
func/db_func.sh
132
func/db_func.sh
|
@ -22,138 +22,6 @@ is_db_new() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shell list for single database
|
|
||||||
db_shell_single_list() {
|
|
||||||
|
|
||||||
# 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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Json single list
|
|
||||||
db_json_single_list() {
|
|
||||||
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=$(( i + 1))
|
|
||||||
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 host
|
|
||||||
dbhost_shell_single_list() {
|
|
||||||
|
|
||||||
# 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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Json list for single db host
|
|
||||||
dbhost_json_single_list() {
|
|
||||||
|
|
||||||
# Definigng variables
|
|
||||||
i=1 # iterator
|
|
||||||
|
|
||||||
# Define words number
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
line=$(grep "HOST='$host'" $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=$(( i + 1))
|
|
||||||
done
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo -e "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Checking database host existance
|
# Checking database host existance
|
||||||
is_db_host_valid() {
|
is_db_host_valid() {
|
||||||
|
|
|
@ -498,276 +498,6 @@ del_web_domain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dns_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print brief info
|
|
||||||
echo "${fields//$/}"
|
|
||||||
for a in $fields; do
|
|
||||||
echo -e "------ \c"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
while read line ; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Defining new delimeter
|
|
||||||
IFS=$'\n'
|
|
||||||
# Parsing key=value
|
|
||||||
for key in $(echo $line|sed -e "s/' /'\n/g"); do
|
|
||||||
eval ${key%%=*}="${key#*=}"
|
|
||||||
done
|
|
||||||
# Print result line
|
|
||||||
eval echo "\"$fields\""|sed -e "s/%quote%/'/g"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done < $conf
|
|
||||||
}
|
|
||||||
|
|
||||||
dns_json_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
while read line ; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Defining new delimeter
|
|
||||||
IFS=$'\n'
|
|
||||||
# Parsing key=value
|
|
||||||
for key in $(echo $line|sed -e "s/' /'\n/g"); do
|
|
||||||
eval ${key%%=*}="${key#*=}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Checking !first line to print bracket
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
j=1 # local loop iterator
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Restoring old delimeter
|
|
||||||
IFS=' '
|
|
||||||
# Print data
|
|
||||||
for field in $fields; do
|
|
||||||
eval value=\"$field\"
|
|
||||||
value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
|
|
||||||
|
|
||||||
# Checking parrent key
|
|
||||||
if [ "$j" -eq 1 ]; then
|
|
||||||
echo -e "\t\"$value\": {"
|
|
||||||
else
|
|
||||||
if [ "$j" -eq "$last_word" ]; then
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
|
||||||
else
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
j=$(($j + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done < $conf
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo -e "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Shell list for dns domain templates
|
|
||||||
dnstpl_shell_list() {
|
|
||||||
# Definigng variables
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Listing files by mask
|
|
||||||
for template in $(ls $V_DNSTPL/| grep '.descr'); do
|
|
||||||
|
|
||||||
# Defining template name
|
|
||||||
tpl_name="${template//.descr/}"
|
|
||||||
|
|
||||||
# Defining template description
|
|
||||||
tpl_descr=$(cat $V_DNSTPL/$template |grep '#')
|
|
||||||
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Print result
|
|
||||||
echo "----------"
|
|
||||||
echo "TEMPLATE: $tpl_name"
|
|
||||||
echo "${tpl_descr//# /}"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Json list for dns domain templates
|
|
||||||
dnstpl_json_list() {
|
|
||||||
i=1 # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Listing files by mask
|
|
||||||
for template in $(ls $V_DNSTPL/| grep '.descr'); do
|
|
||||||
|
|
||||||
# Defining template description
|
|
||||||
descr=$(cat $V_DNSTPL/$template |grep '#'|sed -e ':a;N;$!ba;s/\n/ /g')
|
|
||||||
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Checking !first line to print bracket
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Defining template name
|
|
||||||
tpl_name="${template//.descr/}"
|
|
||||||
|
|
||||||
# Print result
|
|
||||||
echo -e "\t\"$tpl_name\": {"
|
|
||||||
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$tpl_name" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
dom_json_single_list() {
|
|
||||||
i=1 # iterator
|
|
||||||
|
|
||||||
# Define words number
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
line=$(grep "DOMAIN='$domain'" $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=$(( i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo -e "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
dom_shell_single_list() {
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
line=$(grep "DOMAIN='$domain'" $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
|
|
||||||
}
|
|
||||||
|
|
||||||
webtpl_json_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Listing files by mask
|
|
||||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
|
||||||
# Defining template description
|
|
||||||
descr=$(cat $V_WEBTPL/apache_$template.descr|grep '#'|\
|
|
||||||
sed -e ':a;N;$!ba;s/\n/ /g')
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Checking !first line to print bracket
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print result
|
|
||||||
echo -e "\t\"$template\": {"
|
|
||||||
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$template" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
echo "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
webtpl_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Listing files by mask
|
|
||||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
|
||||||
# Defining template description
|
|
||||||
tpl_descr=$(cat $V_WEBTPL/apache_$template.descr |grep '#')
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Print result
|
|
||||||
echo "----------"
|
|
||||||
echo "TEMPLATE: $template"
|
|
||||||
echo "${tpl_descr//# /}"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
dom_clear_search(){
|
dom_clear_search(){
|
||||||
# Defining delimeter
|
# Defining delimeter
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|
294
func/ip_func.sh
294
func/ip_func.sh
|
@ -276,272 +276,6 @@ get_current_interface() {
|
||||||
echo "$i"
|
echo "$i"
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_json_single_list() {
|
|
||||||
# Definigng variables
|
|
||||||
IP="$ip" # ip
|
|
||||||
i=1 # iterator
|
|
||||||
|
|
||||||
# Define words number
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
line=$(cat $V_IPS/$IP)
|
|
||||||
|
|
||||||
# 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=$(( i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo -e "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_shell_single_list() {
|
|
||||||
# Definigng variables
|
|
||||||
IP="$ip" # ip
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
line=$(cat $V_IPS/$IP)
|
|
||||||
|
|
||||||
# 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
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_json_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Definining user list
|
|
||||||
ip_list=$(ls $V_IPS/)
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for IP in $ip_list; do
|
|
||||||
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Reading user data
|
|
||||||
ip_data=$(cat $V_IPS/$IP)
|
|
||||||
|
|
||||||
# Parsing key/value config
|
|
||||||
for key in $ip_data; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Checking !first line to print bracket with coma
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Defining local iterator and words count
|
|
||||||
j='1'
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Print data
|
|
||||||
for field in $fields; do
|
|
||||||
eval value=$field
|
|
||||||
# Checking parrent key
|
|
||||||
if [ "$j" -eq 1 ]; then
|
|
||||||
echo -e "\t\"$value\": {"
|
|
||||||
else
|
|
||||||
if [ "$j" -eq "$last_word" ]; then
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
|
||||||
else
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
j=$(($j + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo '}'
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Definining ip list
|
|
||||||
ip_list=$(ls $V_IPS/)
|
|
||||||
|
|
||||||
# Print brief info
|
|
||||||
echo "${fields//$/}"
|
|
||||||
for a in $fields; do
|
|
||||||
echo -e "--------- \c"
|
|
||||||
done
|
|
||||||
echo # new line
|
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for IP in $ip_list; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Reading user data
|
|
||||||
ip_data=$(cat $V_IPS/$IP)
|
|
||||||
|
|
||||||
# Parsing key/value config
|
|
||||||
for key in $ip_data; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Print result line
|
|
||||||
eval echo "$fields"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_user_json_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
user_ip=$(grep -l "OWNER='$user'" $V_IPS/*)
|
|
||||||
owner_ip=$(grep -l -A2 "OWNER='vesta'" $V_IPS/*|grep "STATUS='shared'"|\
|
|
||||||
cut -f 1 -d -)
|
|
||||||
|
|
||||||
# Definining ip list
|
|
||||||
ip_list=$(echo -e "$user_ip\n$owner_ip"|sort|uniq)
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for IP in ${ip_list//$V_IPS\//}; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Reading user data
|
|
||||||
ip_data=$(cat $V_IPS/$IP)
|
|
||||||
|
|
||||||
# Parsing key/value config
|
|
||||||
for key in $ip_data; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Checking !first line to print bracket with coma
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Defining local iterator and words count
|
|
||||||
j='1'
|
|
||||||
last_word=$(echo "$fields"| wc -w)
|
|
||||||
|
|
||||||
# Print data
|
|
||||||
for field in $fields; do
|
|
||||||
eval value=$field
|
|
||||||
|
|
||||||
# There is outpup
|
|
||||||
if [ ! -z "$value" ]; then
|
|
||||||
tpt='yes'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking parrent key
|
|
||||||
if [ "$j" -eq 1 ]; then
|
|
||||||
echo -e "\t\"$value\": {"
|
|
||||||
else
|
|
||||||
if [ "$j" -eq "$last_word" ]; then
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
|
||||||
else
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
j=$(($j + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$tpt" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo '}'
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_user_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
user_ip=$(grep -l "OWNER='$user'" $V_IPS/*)
|
|
||||||
owner_ip=$(grep -A2 "OWNER='vesta'" $V_IPS/* |grep "STATUS='shared'" |\
|
|
||||||
cut -f 1 -d -)
|
|
||||||
|
|
||||||
# Definining ip list
|
|
||||||
ip_list=$(echo -e "$user_ip\n$owner_ip"|sort|uniq)
|
|
||||||
|
|
||||||
# Print brief info
|
|
||||||
echo "${fields//$/}"
|
|
||||||
for a in $fields; do
|
|
||||||
echo -e "--------- \c"
|
|
||||||
done
|
|
||||||
echo # new line
|
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for IP in ${ip_list//$V_IPS\//}; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Reading user data
|
|
||||||
ip_data=$(cat $V_IPS/$IP)
|
|
||||||
|
|
||||||
# Parsing key/value config
|
|
||||||
for key in $ip_data; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Print result line
|
|
||||||
eval echo "$fields"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_add_vesta() {
|
ip_add_vesta() {
|
||||||
# Filling ip values
|
# Filling ip values
|
||||||
ip_data="OWNER='$user'"
|
ip_data="OWNER='$user'"
|
||||||
|
@ -569,34 +303,6 @@ ip_add_startup() {
|
||||||
echo -e "$ip_data" >$iconf-$iface
|
echo -e "$ip_data" >$iconf-$iface
|
||||||
}
|
}
|
||||||
|
|
||||||
ipint_json_list() {
|
|
||||||
interfaces=$(cat /proc/net/dev|grep :|cut -f 1 -d :|sed -e "s/ //g")
|
|
||||||
int_counter=$(echo "$interfaces"|wc -l)
|
|
||||||
i=1
|
|
||||||
# Print top bracket
|
|
||||||
echo '['
|
|
||||||
# Listing servers
|
|
||||||
for interface in $interfaces; do
|
|
||||||
if [ "$i" -lt "$int_counter" ]; then
|
|
||||||
echo -e "\t\"$interface\","
|
|
||||||
else
|
|
||||||
echo -e "\t\"$interface\""
|
|
||||||
fi
|
|
||||||
i=$((i + 1))
|
|
||||||
done
|
|
||||||
echo "]"
|
|
||||||
}
|
|
||||||
|
|
||||||
ipint_shell_list() {
|
|
||||||
interfaces=$(cat /proc/net/dev|grep :|cut -f 1 -d :|sed -e "s/ //g")
|
|
||||||
# Print result
|
|
||||||
echo "INTERFACES"
|
|
||||||
echo "----------"
|
|
||||||
for interface in $interfaces; do
|
|
||||||
echo "$interface"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
ip_owner_search(){
|
ip_owner_search(){
|
||||||
for ip in $(ls $V_IPS/); do
|
for ip in $(ls $V_IPS/); do
|
||||||
check_owner=$(grep "OWNER='$user'" $V_IPS/$ip)
|
check_owner=$(grep "OWNER='$user'" $V_IPS/$ip)
|
||||||
|
|
|
@ -355,9 +355,7 @@ format_validation() {
|
||||||
mask) format_ip "$v" ;;
|
mask) format_ip "$v" ;;
|
||||||
max_usr) format_int "$v" ;;
|
max_usr) format_int "$v" ;;
|
||||||
max_db) format_int "$v" ;;
|
max_db) format_int "$v" ;;
|
||||||
limit) format_int "$v" ;;
|
|
||||||
lname) format_usr "$v" ;;
|
lname) format_usr "$v" ;;
|
||||||
offset) format_int "$v" ;;
|
|
||||||
owner) format_usr "$v" ;;
|
owner) format_usr "$v" ;;
|
||||||
package) format_usr "$v" ;;
|
package) format_usr "$v" ;;
|
||||||
password) format_pwd "$v" ;;
|
password) format_pwd "$v" ;;
|
||||||
|
@ -375,7 +373,6 @@ format_validation() {
|
||||||
|
|
||||||
# Sub system checker
|
# Sub system checker
|
||||||
is_system_enabled() {
|
is_system_enabled() {
|
||||||
|
|
||||||
stype="$1"
|
stype="$1"
|
||||||
|
|
||||||
web_function() {
|
web_function() {
|
||||||
|
@ -936,302 +933,83 @@ decrease_user_value() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Json listing function
|
|
||||||
v_json_list() {
|
|
||||||
# Definigng variables
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
value='' # clean start value
|
|
||||||
|
|
||||||
|
# Json listing function
|
||||||
|
json_list() {
|
||||||
# Print top bracket
|
# Print top bracket
|
||||||
echo '{'
|
echo '{'
|
||||||
|
|
||||||
|
# Count fields
|
||||||
|
fileds_count=$(echo $fields| wc -w )
|
||||||
|
|
||||||
# Reading file line by line
|
# Reading file line by line
|
||||||
while read line; do
|
while read line; do
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
# Assing key=value pair
|
||||||
then
|
|
||||||
# Parsing key=value
|
|
||||||
for key in $line; do
|
for key in $line; do
|
||||||
eval ${key%%=*}=${key#*=}
|
eval ${key%%=*}=${key#*=}
|
||||||
done
|
done
|
||||||
|
|
||||||
# Checking !first line to print bracket
|
# Closing bracket if there already was output
|
||||||
if [ "$i" -ne "$offset" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e "\t},"
|
echo -e ' },'
|
||||||
fi
|
fi
|
||||||
|
i=1
|
||||||
j=1 # local loop iterator
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Print data
|
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
eval value=$field
|
eval value=$field
|
||||||
|
|
||||||
# Checking if value exists
|
if [ $i -eq 1 ]; then
|
||||||
if [ ! -z "$value" ]; then
|
# Printing parrent
|
||||||
tpt=yes
|
(( ++i))
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking parrent key
|
|
||||||
if [ "$j" -eq 1 ]; then
|
|
||||||
echo -e "\t\"$value\": {"
|
echo -e "\t\"$value\": {"
|
||||||
else
|
else
|
||||||
if [ "$j" -eq "$last_word" ]; then
|
# Printing child
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
if [ $i -lt $fileds_count ]; then
|
||||||
else
|
(( ++i))
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||||
|
else
|
||||||
|
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
||||||
|
data=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
j=$(($j + 1))
|
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done < $conf
|
done < $conf
|
||||||
|
|
||||||
# If there was any output
|
# Closing bracket if there was output
|
||||||
if [ -n "$tpt" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e "\t}"
|
echo -e ' }'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Printing bottom json bracket
|
# Printing bottom bracket
|
||||||
echo -e "}"
|
echo -e '}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shell listing function
|
|
||||||
v_shell_list() {
|
|
||||||
|
|
||||||
# Definigng variables
|
# Shell listing function
|
||||||
i='1' # iterator
|
shell_list() {
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
if [ -z "$nohead" ] ; then
|
||||||
# Print brief info
|
# Print brief info
|
||||||
echo "${fields//$/}"
|
echo "${fields//$/}"
|
||||||
for a in $fields; do
|
for a in $fields; do
|
||||||
echo -e "------ \c"
|
echo -e "------ \c"
|
||||||
done
|
done
|
||||||
echo # new line
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
# Reading file line by line
|
# Reading file line by line
|
||||||
while read line ; do
|
while read line ; do
|
||||||
# Checking offset and limit
|
# Assing key=value pair
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Parsing key=value
|
|
||||||
for key in $line; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
# Print result line
|
|
||||||
eval echo "$fields"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done < $conf
|
|
||||||
}
|
|
||||||
|
|
||||||
# Clear listing function
|
|
||||||
v_clear_list() {
|
|
||||||
# Reading file line by line
|
|
||||||
while read line ; do
|
|
||||||
|
|
||||||
# Parsing key=value
|
|
||||||
for key in $line; do
|
for key in $line; do
|
||||||
eval ${key%%=*}=${key#*=}
|
eval ${key%%=*}=${key#*=}
|
||||||
done
|
done
|
||||||
|
|
||||||
# Print result line
|
|
||||||
eval echo "$fields"
|
|
||||||
|
|
||||||
done < $conf
|
|
||||||
}
|
|
||||||
|
|
||||||
usr_json_single_list() {
|
|
||||||
# Definigng variables
|
|
||||||
USER="$user" # user
|
|
||||||
i=1 # iterator
|
|
||||||
|
|
||||||
# Define words number
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
line=$(cat $V_USERS/$USER/user.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=$(( i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo -e "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
usr_shell_single_list() {
|
|
||||||
# Definigng variables
|
|
||||||
USER="$user" # user
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
usr_json_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Definining user list
|
|
||||||
#user_list=$(find $V_USERS/ -maxdepth 1 -mindepth 1 -type d -printf %P\\n )
|
|
||||||
user_list=$(ls $V_USERS/)
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for USER in $user_list; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Reading user data
|
|
||||||
user_data=$(cat $V_USERS/$USER/user.conf)
|
|
||||||
|
|
||||||
# Parsing key/value config
|
|
||||||
for key in $user_data; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Checking !first line to print bracket with coma
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Defining local iterator and words count
|
|
||||||
j='1'
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Print data
|
|
||||||
for field in $fields; do
|
|
||||||
eval value=$field
|
|
||||||
# Checking parrent key
|
|
||||||
if [ "$j" -eq 1 ]; then
|
|
||||||
echo -e "\t\"$value\": {"
|
|
||||||
else
|
|
||||||
if [ "$j" -eq "$last_word" ]; then
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
|
||||||
else
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
j=$(($j + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo '}'
|
|
||||||
}
|
|
||||||
|
|
||||||
usr_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Definining user list
|
|
||||||
#user_list=$(find $V_USERS/ -maxdepth 1 -mindepth 1 -type d -printf %P\\n )
|
|
||||||
user_list=$(ls $V_USERS/)
|
|
||||||
|
|
||||||
# Print brief info
|
|
||||||
echo "${fields//$/}"
|
|
||||||
for a in $fields; do
|
|
||||||
echo -e "--------- \c"
|
|
||||||
done
|
|
||||||
echo # new line
|
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for USER in $user_list; do
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Reading user data
|
|
||||||
user_data=$(cat $V_USERS/$USER/user.conf)
|
|
||||||
|
|
||||||
# Parsing key/value config
|
|
||||||
for key in $user_data; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
# Print result line
|
|
||||||
eval echo "$fields"
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
usrns_json_list() {
|
|
||||||
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=$((i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "]"
|
|
||||||
}
|
|
||||||
|
|
||||||
usrns_shell_list() {
|
|
||||||
ns=$(grep "^NS='" $V_USERS/$user/user.conf |cut -f 2 -d \')
|
|
||||||
# Print result
|
# Print result
|
||||||
echo "NAMESERVER"
|
eval echo "$fields"
|
||||||
echo "----------"
|
done < $conf
|
||||||
for nameserver in ${ns//,/ };do
|
|
||||||
echo "$nameserver"
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
get_usr_disk() {
|
get_usr_disk() {
|
||||||
size='0'
|
size='0'
|
||||||
|
|
||||||
|
@ -1290,94 +1068,6 @@ get_usr_traff() {
|
||||||
echo "$size"
|
echo "$size"
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_json_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for package in $(ls $V_DATA/packages); do
|
|
||||||
PACKAGE=${package/.pkg/}
|
|
||||||
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Parsing key/value config
|
|
||||||
pkg_descr=$(cat $V_DATA/packages/$package)
|
|
||||||
for key in $pkg_descr; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Checking !first line to print bracket with coma
|
|
||||||
if [ "$i" -ne "$offset" ]; then
|
|
||||||
echo -e "\t},"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Defining local iterator and words count
|
|
||||||
j='1'
|
|
||||||
last_word=$(echo "$fields" | wc -w)
|
|
||||||
|
|
||||||
# Print data
|
|
||||||
for field in $fields; do
|
|
||||||
eval value=$field
|
|
||||||
# Checking parrent key
|
|
||||||
if [ "$j" -eq 1 ]; then
|
|
||||||
echo -e "\t\"$value\": {"
|
|
||||||
else
|
|
||||||
if [ "$j" -eq "$last_word" ]; then
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
|
|
||||||
else
|
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
j=$(($j + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# If there was any output
|
|
||||||
if [ -n "$value" ]; then
|
|
||||||
echo -e "\t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Printing bottom json bracket
|
|
||||||
echo '}'
|
|
||||||
}
|
|
||||||
|
|
||||||
pkg_shell_list() {
|
|
||||||
i='1' # iterator
|
|
||||||
end=$(($limit + $offset)) # last string
|
|
||||||
|
|
||||||
# Listing pkg files
|
|
||||||
for package in $(ls $V_DATA/packages); do
|
|
||||||
PACKAGE=${package/.pkg/}
|
|
||||||
|
|
||||||
# Checking offset and limit
|
|
||||||
if [ "$i" -ge "$offset" ] && [ "$i" -lt "$end" ] && [ "$offset" -gt 0 ]
|
|
||||||
then
|
|
||||||
# Parsing key=value
|
|
||||||
pkg_descr=$(cat $V_DATA/packages/$package)
|
|
||||||
for key in $pkg_descr; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "----------"
|
|
||||||
|
|
||||||
# Starting output loop
|
|
||||||
for field in $fields; do
|
|
||||||
# Parsing key=value
|
|
||||||
eval value=$field
|
|
||||||
# Checking first field
|
|
||||||
echo -e "${field//$/}: $value"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
i=$(($i + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
get_config_value() {
|
get_config_value() {
|
||||||
key="$1"
|
key="$1"
|
||||||
# Parsing config
|
# Parsing config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue