Skip to content

Commit

Permalink
properly end when unzip/untar fails
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfrantz committed May 23, 2024
1 parent 4753845 commit de4c50f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
54 changes: 34 additions & 20 deletions bash/force-level2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ function process_this_image(){
--exclude='LE07*B6_VCID_2.TIF' --exclude='LC08*B11.TIF' --exclude='LC08*B8.TIF' \
-C "$EXTRACT_IMAGE" &> /dev/null
if [ ! $? -eq 0 ]; then
UNPACK_STATUS="FAIL"
echo "tar.gz container is corrupt, connection stalled or similar." >> "$FILE_LOG"
exit 1
else
UNPACK_STATUS="SUCCESS"
echo "Unpacking tar.gz container successful" >> "$FILE_LOG"
fi

Expand All @@ -168,9 +169,10 @@ function process_this_image(){
--exclude='LE07*B6_VCID_2.TIF' --exclude='LC08*B11.TIF' --exclude='LC08*B8.TIF' \
-C "$EXTRACT_IMAGE" &> /dev/null
if [ ! $? -eq 0 ]; then
UNPACK_STATUS="FAIL"
echo "tar container is corrupt, connection stalled or similar." >> "$FILE_LOG"
exit 1
else
UNPACK_STATUS="SUCCESS"
echo "Unpacking tar container successful" >> "$FILE_LOG"
fi

Expand All @@ -184,48 +186,60 @@ function process_this_image(){

timeout -k "$TIMEOUT_ZIP" 10m unzip -qq -d "$DIR_TEMP" "$FILE_IMAGE" &>/dev/null
if [ ! $? -eq 0 ]; then
UNPACK_STATUS="FAIL"
echo "zip container is corrupt, connection stalled or similar." >> "$FILE_LOG"
exit 1
else
UNPACK_STATUS="SUCCESS"
echo "Unpacking zip container successful" >> "$FILE_LOG"
dir_not_found "$EXTRACT_IMAGE" &>>"$FILE_LOG"
fi

dir_not_found "$EXTRACT_IMAGE" &>>"$FILE_LOG"

# already unpacked
else

unpacked=false
UNPACK_STATUS="SUCCESS"
EXTRACT_IMAGE="$FILE_IMAGE"
dir_not_found "$FILE_IMAGE" &>>"$FILE_LOG"
echo "Image is already unpacked" >> "$FILE_LOG"

fi

debug "UNPACK_STATUS" "$UNPACK_STATUS"
debug "unpacked: $unpacked"
debug "EXTRACT_IMAGE: $EXTRACT_IMAGE"

if [ "$UNPACK_STATUS" == "SUCCESS" ]; then

{
echo ""
echo "Start core processing"
echo "-----------------------------------------------------------"
echo ""
} >> "$FILE_LOG"
{
echo ""
echo "Start core processing"
echo "-----------------------------------------------------------"
echo ""
} >> "$FILE_LOG"

# process
if $FORCE_L2PS_CORE_EXE "$EXTRACT_IMAGE" "$FILE_PRM" &>> "$FILE_LOG"; then
STATUS="DONE"
else
STATUS="FAIL"
fi

debug "STATUS: $STATUS"

{
echo ""
echo "-----------------------------------------------------------"
echo "Core processing signaled $STATUS"
} >> "$FILE_LOG"

else

# process
if $FORCE_L2PS_CORE_EXE "$EXTRACT_IMAGE" "$FILE_PRM" &>>"$FILE_LOG"; then
STATUS="DONE"
else
STATUS="FAIL"
fi

debug "STATUS: $STATUS"
fi

{
echo ""
echo "-----------------------------------------------------------"
echo "Core processing signaled $STATUS"
echo ""
echo "End of processing: $(date +"%Y-%m-%d %H:%M:%S")"
echo "May the FORCE be with you!"
Expand Down
2 changes: 1 addition & 1 deletion misc/force-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.12-dev:::2024-05-23_06:40:24
3.7.12-dev:::2024-05-23_07:24:52

0 comments on commit de4c50f

Please sign in to comment.