Save log file to a temporary location
This commit is contained in:
parent
384148c019
commit
ebd13a9e9e
1 changed files with 7 additions and 6 deletions
13
Dockerfile
13
Dockerfile
|
@ -80,11 +80,12 @@ RUN \
|
|||
install_keil() { \
|
||||
echo "Starting ARM Keil installation"; \
|
||||
try="$1"; \
|
||||
logFile="$(mktemp)"; \
|
||||
# Run installer asynchronously
|
||||
{ \
|
||||
{ 2>&1 WINEDEBUG=+all,trace-all,warn-all /usr/bin/entrypoint wine MDK537.exe --batch-install || echo "exit $?"; } \
|
||||
# Write output to `log.txt`
|
||||
| { [ "$DEBUG" -eq 1 ] && tee log.txt || cat; } \
|
||||
| { [ "$DEBUG" -eq 1 ] && tee "$logFile" || cat; } \
|
||||
# Pipe stdout and stderr to `handle_output` function
|
||||
| handle_output & \
|
||||
}; \
|
||||
|
@ -105,19 +106,19 @@ RUN \
|
|||
sleep 1; \
|
||||
done; \
|
||||
# Kill installer after timeout indicated by `maxCount`
|
||||
[ "$x" -eq "$maxCount" ] && { pkill -9 MDK537.exe; mv log.txt "logs/timeout-try$try.log"; }; \
|
||||
[ "$x" -eq "$maxCount" ] && { pkill -9 MDK537.exe; mv "$logFile" "logs/timeout-try$try.log"; }; \
|
||||
} & \
|
||||
}; \
|
||||
wait $pid; \
|
||||
exitCode=$?; \
|
||||
# Rename log file according to the state of the installer
|
||||
[ $DEBUG -eq 1 ] \
|
||||
&& [ -f log.txt ] \
|
||||
&& [ -f "$logFile" ] \
|
||||
&& { \
|
||||
# Move logs to location based on exit code
|
||||
[ "$exitCode" -eq 0 ] && mv log.txt "logs/success-try$try.log"; \
|
||||
[ "$exitCode" -eq 42 ] && mv log.txt "logs/timeout-handled-try$try.log"; \
|
||||
[ "$exitCode" -ne 0 ] && mv log.txt "logs/fail-try$try.log"; \
|
||||
[ "$exitCode" -eq 0 ] && mv "$logFile" "logs/success-try$try.log"; \
|
||||
[ "$exitCode" -eq 42 ] && mv "$logFile" "logs/timeout-handled-try$try.log"; \
|
||||
[ "$exitCode" -ne 0 ] && mv "$logFile" "logs/fail-try$try.log"; \
|
||||
}; \
|
||||
[ "$exitCode" -ne 0 ] && { \
|
||||
[ "$exitCode" -eq 42 ] && echo "The installation got stuck" || \
|
||||
|
|
Loading…
Reference in a new issue