- local file="$1"
- local suffix="$2"
- local run="no"
- setfile $file
-
- # skip over this config if "when" option
- # is not set to the current time.
- getconf when "$defaultwhen"
- if [ "$processnow" == 1 ]; then
- info ">>>> starting action $file (because of --now)"
- run="yes"
- elif [ "$when" == "hourly" ]; then
- info ">>>> starting action $file (because 'when = hourly')"
- run="yes"
- else
- IFS=$'\t\n'
- for w in $when; do
- IFS=$' \t\n'
- isnow "$w"
- ret=$?
- IFS=$'\t\n'
- if [ $ret == 0 ]; then
- debug "skipping $file because it is not $w"
- else
- info ">>>> starting action $file (because it is $w)"
- run="yes"
- fi
- done
- IFS=$' \t\n'
- fi
- debug $run
- [ "$run" == "no" ] && return
-
- let "actions_run += 1"
-
- # call the handler:
- local bufferfile=`maketemp backupninja.buffer`
- echo "" > $bufferfile
- echo_debug_msg=1
- (
- . $scriptdirectory/$suffix $file
- ) 2>&1 | (
- while read a; do
- echo $a >> $bufferfile
- [ $debug ] && colorize "$a"
- done
- )
- retcode=$?
- # ^^^^^^^^ we have a problem! we can't grab the return code "$?". grrr.
- echo_debug_msg=0
-
- _warnings=`cat $bufferfile | grep "^Warning: " | wc -l`
- _errors=`cat $bufferfile | grep "^Error: " | wc -l`
- _fatals=`cat $bufferfile | grep "^Fatal: " | wc -l`
-
- ret=`grep "\(^Warning: \|^Error: \|^Fatal: \)" $bufferfile`
- rm $bufferfile
- if [ $_fatals != 0 ]; then
- msg "*failed* -- $file"
- errormsg="$errormsg\n== fatal errors from $file ==\n\n$ret\n"
- passthru "Fatal: <<<< finished action $file: FAILED"
- elif [ $_errors != 0 ]; then
- msg "*error* -- $file"
- errormsg="$errormsg\n== errors from $file ==\n\n$ret\n"
- error "<<<< finished action $file: ERROR"
- elif [ $_warnings != 0 ]; then
- msg "*warning* -- $file"
- errormsg="$errormsg\n== warnings from $file ==\n\n$ret\n"
- warning "<<<< finished action $file: WARNING"
- else
- msg "success -- $file"
- info "<<<< finished action $file: SUCCESS"
- fi
-
- let "fatals += _fatals"
- let "errors += _errors"
- let "warnings += _warnings"
+ local file="$1"
+ local suffix="$2"
+ local run="no"
+ setfile $file
+
+ # skip over this config if "when" option
+ # is not set to the current time.
+ getconf when "$defaultwhen"
+ if [ "$processnow" == 1 ]; then
+ info ">>>> starting action $file (because of --now)"
+ run="yes"
+ elif [ "$when" == "hourly" ]; then
+ info ">>>> starting action $file (because 'when = hourly')"
+ run="yes"
+ else
+ IFS=$'\t\n'
+ for w in $when; do
+ IFS=$' \t\n'
+ isnow "$w"
+ ret=$?
+ IFS=$'\t\n'
+ if [ $ret == 0 ]; then
+ debug "skipping $file because current time does not match $w"
+ else
+ info ">>>> starting action $file (because current time matches $w)"
+ run="yes"
+ fi
+ done
+ IFS=$' \t\n'
+ fi
+ debug $run
+ [ "$run" == "no" ] && return
+
+ let "actions_run += 1"
+
+ # call the handler:
+ local bufferfile=`maketemp backupninja.buffer`
+ echo "" > $bufferfile
+ echo_debug_msg=1
+ (
+ . $scriptdirectory/$suffix $file
+ ) 2>&1 | (
+ while read a; do
+ echo $a >> $bufferfile
+ [ $debug ] && colorize "$a"
+ done
+ )
+ retcode=$?
+ # ^^^^^^^^ we have a problem! we can't grab the return code "$?". grrr.
+ echo_debug_msg=0
+
+ _warnings=`cat $bufferfile | grep "^Warning: " | wc -l`
+ _errors=`cat $bufferfile | grep "^Error: " | wc -l`
+ _fatals=`cat $bufferfile | grep "^Fatal: " | wc -l`
+ _halts=`cat $bufferfile | grep "^Halt: " | wc -l`
+ _infos=`cat $bufferfile | grep "^Info: " | wc -l`
+
+ ret=`grep "\(^Info: \|^Warning: \|^Error: \|^Fatal: \|Halt: \)" $bufferfile`
+ rm $bufferfile
+ if [ $_halts != 0 ]; then
+ msg "*halt* -- $file"
+ errormsg="$errormsg\n== halt request from $file==\n\n$ret\n"
+ passthru "Halt: <<<< finished action $file: FAILED"
+ elif [ $_fatals != 0 ]; then
+ msg "*failed* -- $file"
+ errormsg="$errormsg\n== fatal errors from $file ==\n\n$ret\n"
+ passthru "Fatal: <<<< finished action $file: FAILED"
+ elif [ $_errors != 0 ]; then
+ msg "*error* -- $file"
+ errormsg="$errormsg\n== errors from $file ==\n\n$ret\n"
+ error "<<<< finished action $file: ERROR"
+ elif [ $_warnings != 0 ]; then
+ msg "*warning* -- $file"
+ errormsg="$errormsg\n== warnings from $file ==\n\n$ret\n"
+ warning "<<<< finished action $file: WARNING"
+ else
+ msg "success -- $file"
+ if [ $_infos != 0 -a "$reportinfo" == "yes" ]; then
+ errormsg="$errormsg\n== infos from $file ==\n\n$ret\n"
+ fi
+ info "<<<< finished action $file: SUCCESS"
+ fi
+
+ let "halts += _halts"
+ let "fatals += _fatals"
+ let "errors += _errors"
+ let "warnings += _warnings"