mirror of
https://github.com/myvesta/vesta
synced 2025-07-16 10:03:23 -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
88
bin/v-list-user-log
Executable file
88
bin/v-list-user-log
Executable file
|
@ -0,0 +1,88 @@
|
|||
#!/bin/bash
|
||||
# info: list user log
|
||||
# options: user [format]
|
||||
#
|
||||
# The function of obtaining the list of 100 last users commands.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
# Json func
|
||||
json_list_history() {
|
||||
echo '{'
|
||||
fileds_count=$(echo $fields| wc -w )
|
||||
while read line; do
|
||||
IFS=$'\n'
|
||||
eval $line
|
||||
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
|
||||
(( ++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 < $conf
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
echo -e '}'
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'user [format]'
|
||||
validate_format 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf=$USER_DATA/history.log
|
||||
|
||||
# Defining fileds to select
|
||||
fields="\$ID \$DATE \$TIME \$CMD \$UNDO"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) json_list_history ;;
|
||||
plain) nohead=1; shell_list ;;
|
||||
shell) fields='$ID~$DATE~$TIME~$CMD';
|
||||
shell_list |column -t -s '~';;
|
||||
*) check_args '1' '0' 'user [format]'
|
||||
esac
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue