mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -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
106
bin/v-list-cron-jobs
Executable file
106
bin/v-list-cron-jobs
Executable file
|
@ -0,0 +1,106 @@
|
|||
#!/bin/bash
|
||||
# info: list user cron jobs
|
||||
# options: user [format]
|
||||
#
|
||||
# The function for obtaining the list of all users cron jobs.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
# Json list function
|
||||
json_list_cron() {
|
||||
echo '{'
|
||||
fileds_count=$(echo $fields| wc -w )
|
||||
while read line; do
|
||||
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 '}'
|
||||
}
|
||||
|
||||
# Shell list function
|
||||
shell_list_cron() {
|
||||
if [ -z "$nohead" ] ; then
|
||||
echo "${fields//$/}"
|
||||
for a in $fields; do
|
||||
echo -e "------ \c"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
while read line ; do
|
||||
eval $line
|
||||
eval echo "$fields" | sed -e "s/%quote%/'/g"
|
||||
done < $conf
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'user [format]'
|
||||
validate_format 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining config
|
||||
conf=$USER_DATA/cron.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $JOB $SUSPENDED $TIME $DATE'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) json_list_cron ;;
|
||||
plain) nohead=1;
|
||||
fields="\"\$JOB\" \"\$SUSPENDED\" \"\$MIN\" \"\$HOUR\" \"\$DAY\""
|
||||
fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\" ";
|
||||
fields="$fields \"\$TIME\" \"\$DATE\""
|
||||
shell_list_cron ;;
|
||||
shell) fields='$JOB~$SUSPENDED~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD';
|
||||
shell_list_cron |column -t -s '~';;
|
||||
*) check_args '1' '0' 'user [format]' ;;
|
||||
esac
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue