mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 02:28:03 -07:00
replaced underscore with dash in api syscalls
This commit is contained in:
parent
7ed705cee7
commit
b6b7eacadb
283 changed files with 438 additions and 412 deletions
94
bin/v-list-sys-ips
Executable file
94
bin/v-list-sys-ips
Executable file
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# info: list system ips
|
||||
# options: [format]
|
||||
#
|
||||
# The function for obtaining the list of system ip's.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
format=${1-shell}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
# Json function
|
||||
json_list_ips() {
|
||||
echo '{'
|
||||
ip_list=$(ls $VESTA/data/ips/)
|
||||
fileds_count=$(echo "$fields" | wc -w)
|
||||
for IP in $ip_list; do
|
||||
ip_data=$(cat $VESTA/data/ips/$IP)
|
||||
eval $ip_data
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
fi
|
||||
i=1
|
||||
for field in $fields; do
|
||||
eval value=$field
|
||||
if [ $i -eq 1 ]; then
|
||||
(( ++i))
|
||||
echo -e "\t\"$value\": {"
|
||||
else
|
||||
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
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_ips() {
|
||||
ip_list=$(ls $VESTA/data/ips/)
|
||||
if [ -z "$nohead" ]; then
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "--------- \c"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
for IP in $ip_list; do
|
||||
ip_data=$(cat $VESTA/data/ips/$IP)
|
||||
eval $ip_data
|
||||
eval echo "$fields"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining fileds to select
|
||||
conf=$VESTA/data/ips/*
|
||||
fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS"
|
||||
fields="$fields \$INTERFACE \$NETMASK \$TIME \$DATE"
|
||||
|
||||
# Listing ip addresses
|
||||
case $format in
|
||||
json) json_list_ips ;;
|
||||
plain) nohead=1; shell_list_ips ;;
|
||||
shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS';
|
||||
shell_list_ips | column -t ;;
|
||||
*) check_args '1' '0' '[format]'
|
||||
esac
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue