mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 10:37:42 -07:00
listing scripts refactoring + new format
This commit is contained in:
parent
b7e9f4b5b0
commit
6e0ef668bb
60 changed files with 3695 additions and 1991 deletions
|
@ -15,24 +15,71 @@ format=${1-shell}
|
|||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
# JSON list function
|
||||
json_list() {
|
||||
IFS=$'\n'
|
||||
i=1
|
||||
objects=$(grep IP $VESTA/data/firewall/banlist.conf |wc -l)
|
||||
echo "{"
|
||||
while read str; do
|
||||
eval $str
|
||||
echo -n ' "'$IP'": {
|
||||
"IP": "'$IP'",
|
||||
"CHAIN": "'$COMMENT'",
|
||||
"TIME": "'$TIME'",
|
||||
"DATE": "'$DATE'"
|
||||
}'
|
||||
if [ "$i" -lt "$objects" ]; then
|
||||
echo ','
|
||||
else
|
||||
echo
|
||||
fi
|
||||
((i++))
|
||||
done < <(cat $VESTA/data/firewall/banlist.conf)
|
||||
echo '}'
|
||||
}
|
||||
|
||||
# SHELL list function
|
||||
shell_list() {
|
||||
IFS=$'\n'
|
||||
echo "IP CHAIN TIME DATE"
|
||||
echo "-- ----- ---- ----"
|
||||
while read str; do
|
||||
eval $str
|
||||
echo "$IP $CHAIN $TIME $DATE"
|
||||
done < <(cat $VESTA/data/firewall/banlist.conf)
|
||||
}
|
||||
|
||||
# PLAIN list function
|
||||
plain_list() {
|
||||
IFS=$'\n'
|
||||
while read str; do
|
||||
eval $str
|
||||
echo -e "$IP\t$CHAIN\t$TIME\t$DATE"
|
||||
done < <(cat $VESTA/data/firewall/banlist.conf)
|
||||
}
|
||||
|
||||
# CSV list function
|
||||
csv_list() {
|
||||
IFS=$'\n'
|
||||
echo "IP,CHAIN,TIME,DATE"
|
||||
while read str; do
|
||||
eval $str
|
||||
echo "$IP,$CHAIN,$TIME,$DATE"
|
||||
done < <(cat $VESTA/data/firewall/banlist.conf)
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf=$VESTA/data/firewall/banlist.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields="\$IP:\$CHAIN \$TIME \$DATE"
|
||||
|
||||
# Listing domains
|
||||
# Listing data
|
||||
case $format in
|
||||
json) json_list ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) fields='$IP $CHAIN $TIME $DATE';
|
||||
shell_list | column -t ;;
|
||||
*) check_args '1' '0' 'USER [FORMAT]'
|
||||
plain) plain_list ;;
|
||||
csv) csv_list ;;
|
||||
shell) shell_list |column -t ;;
|
||||
esac
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue