Store log paths in variables

This commit is contained in:
Manuel Thalmann 2023-03-25 21:33:23 +01:00
parent 938a613afe
commit 9eb3f4ccfa

View file

@ -36,6 +36,8 @@ RUN \
imagemagick; \ imagemagick; \
rm -rf /var/lib/apt/lists; \ rm -rf /var/lib/apt/lists; \
TIV="$(mktemp)"; \ TIV="$(mktemp)"; \
logDir="logs"; \
screenDir="$logDir/screens"; \
git clone https://github.com/stefanhaustein/TerminalImageViewer.git && \ git clone https://github.com/stefanhaustein/TerminalImageViewer.git && \
cd TerminalImageViewer/src/main/cpp && \ cd TerminalImageViewer/src/main/cpp && \
make && \ make && \
@ -44,8 +46,8 @@ RUN \
mv tiv "$TIV" && \ mv tiv "$TIV" && \
cd - && \ cd - && \
rm -rf TerminalImageViewer; \ rm -rf TerminalImageViewer; \
mkdir -p logs; \ mkdir -p "$logDir"; \
mkdir -p screens; \ mkdir -p "$screenDir"; \
} || true; \ } || true; \
printHeading() { \ printHeading() { \
local heading; \ local heading; \
@ -112,7 +114,7 @@ RUN \
maxCount=120; \ maxCount=120; \
while ps -p "$pid" > /dev/null && [ "$x" -ne "$maxCount" ]; do \ while ps -p "$pid" > /dev/null && [ "$x" -ne "$maxCount" ]; do \
# Create screenshot and print it to the console # Create screenshot and print it to the console
fileName="screens/install-try$try-$x.png"; \ fileName="$screenDir/install-try$try-$x.png"; \
import -window root "$fileName"; \ import -window root "$fileName"; \
"$TIV" -w 10000 -h 10000 "$fileName"; \ "$TIV" -w 10000 -h 10000 "$fileName"; \
x="$(expr "$x" + 1)"; \ x="$(expr "$x" + 1)"; \
@ -120,7 +122,7 @@ RUN \
sleep 1; \ sleep 1; \
done; \ done; \
# Kill installer after timeout indicated by `maxCount` # Kill installer after timeout indicated by `maxCount`
[ "$x" -eq "$maxCount" ] && { pkill -9 MDK537.exe; mv "$logFile" "logs/timeout-try$try.log"; }; \ [ "$x" -eq "$maxCount" ] && { pkill -9 MDK537.exe; mv "$logFile" "$logDir/timeout-try$try.log"; }; \
} & \ } & \
}; \ }; \
wait "$pid"; \ wait "$pid"; \
@ -130,9 +132,9 @@ RUN \
&& [ -f "$logFile" ] \ && [ -f "$logFile" ] \
&& { \ && { \
# Move logs to location based on exit code # Move logs to location based on exit code
[ "$exitCode" -eq 0 ] && mv "$logFile" "logs/success-try$try.log"; \ [ "$exitCode" -eq 0 ] && mv "$logFile" "$logDir/success-try$try.log"; \
[ "$exitCode" -eq 42 ] && mv "$logFile" "logs/timeout-handled-try$try.log"; \ [ "$exitCode" -eq 42 ] && mv "$logFile" "$logDir/timeout-handled-try$try.log"; \
[ "$exitCode" -ne 0 ] && mv "$logFile" "logs/fail-try$try.log"; \ [ "$exitCode" -ne 0 ] && mv "$logFile" "$logDir/fail-try$try.log"; \
}; \ }; \
{ \ { \
[ "$exitCode" -ne 0 ] && { \ [ "$exitCode" -ne 0 ] && { \