refactoring: log_event(), is_format_valid()

This commit is contained in:
Serghey Rodin 2016-06-09 16:31:56 +03:00
commit e05dca61a6
211 changed files with 756 additions and 1091 deletions

View file

@ -30,7 +30,7 @@ source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
check_args '7' "$#" 'USER JOB MIN HOUR DAY MONTH WDAY COMMAND'
validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_format_valid 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
@ -42,10 +42,15 @@ is_object_unsuspended 'cron' 'JOB' "$job"
# Action #
#----------------------------------------------------------#
# Generating timestamp
time_n_date=$(date +'%T %F')
time=$(echo "$time_n_date" |cut -f 1 -d \ )
date=$(echo "$time_n_date" |cut -f 2 -d \ )
# Concatenating cron string
command=$(echo $command | sed -e "s/'/%quote%/g")
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"
str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
str="$str CMD='$command' SUSPENDED='no' TIME='$time' DATE='$date'"
# Deleting old job
sed -i "/JOB='$job' /d" $USER_DATA/cron.conf
@ -70,6 +75,6 @@ check_result $? "Cron restart failed" >/dev/null
# Logging
log_history "changed cron job $job"
log_event "$OK" "$EVENT"
log_event "$OK" "$ARGUMENTS"
exit