Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions bin/fai-do-scripts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ savemaxstatus() {
exitcode=$1 # set global variable
# save the highest exit status
[ $1 -gt $maxstatus ] && maxstatus=$1

if [ "$exitcode" -gt 0 ] && [ $((100 + exitcode)) -gt "${STOP_ON_ERROR:-700}" ]; then
printf '%-20s FAILED with exit code %s; STOP_ON_ERROR=%s exceeded, aborting.\n' \
"${2:-script}" "$exitcode" "${STOP_ON_ERROR:-700}" \
| tee -a "$LOGDIR/status.log"
exit $((100 + maxstatus))
fi
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fc_check_status() {
Expand Down Expand Up @@ -130,14 +137,14 @@ do_script() {
vecho "Executing $shelldebug shell: $file"
echo "===== shell: $file =====" >> $slog 2>&1
$shelldebug ./$file >> $slog 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $slog
;;
*)
vecho "Executing: $file"
echo "===== $filetype $file =====" >> $slog 2>&1
./$file >> $slog 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $slog
;;
esac
Expand All @@ -150,55 +157,55 @@ do_script() {
vecho "Executing $shelldebug shell: $file"
echo "===== shell: $file =====" >> $LOGDIR/shell.log 2>&1
$shelldebug ./$file >> $LOGDIR/shell.log 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $LOGDIR/shell.log
;;

*"cf-agent"*)
vecho "Executing cf-agent: $file"
echo "===== cf-agent: $file =====" >> $LOGDIR/cfagent.log 2>&1
./$file $cfagentdebug -KI -D${cfclasses} >> $LOGDIR/cfagent.log 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $LOGDIR/cfagent.log
;;

*[Pp]erl*script*)
vecho "Executing perl: $file"
echo "===== perl: $file =====" >> $LOGDIR/perl.log 2>&1
./$file >> $LOGDIR/perl.log 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $LOGDIR/perl.log
;;

*"expect script"*)
vecho "Executing expect: $file"
echo "===== expect: $file =====" >> $LOGDIR/expect.log 2>&1
./$file >> $LOGDIR/expect.log 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $LOGDIR/expect.log
;;

*[Pp]ython*script*)
vecho "Executing python: $file"
echo "===== python: $file =====" >> $LOGDIR/python.log 2>&1
./$file >> $LOGDIR/python.log 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $LOGDIR/python.log
;;

*[Rr]uby*script*)
vecho "Executing ruby: $file"
echo "===== ruby: $file =====" >> $LOGDIR/ruby.log 2>&1
./$file >> $LOGDIR/ruby.log 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $LOGDIR/ruby.log
;;

*)
vecho "Executing: $file"
echo "===== $filetype $file =====" >> $LOGDIR/scripts.log 2>&1
./$file >> $LOGDIR/scripts.log 2>&1
savemaxstatus $?
savemaxstatus $? "$file"
fc_check_status $file $exitcode | tee -a $LOGDIR/scripts.log
;;
esac
Expand Down