Merge pull request #12 from Webelys/enable-lock

Don't run twice on same directory on same moment
This commit is contained in:
VirtuBox 2020-11-11 12:30:01 +01:00 committed by GitHub
commit 55dbd153a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,6 +103,18 @@ else
done
fi
##################################
# Prevent multi execution on same directory
##################################
lock=$(echo -n "$IMG_PATH" | md5sum| cut -d" " -f1)
if [ -f "/tmp/$lock" ]; then
echo "$IMG_PATH yet in progress"
exit 1
else
touch "/tmp/$lock"
fi
##################################
# Welcome
##################################
@ -220,3 +232,6 @@ fi
echo ""
echo -e " ${CGREEN}Image optimization performed successfully !${CEND}"
echo ""
# Free ressource
rm "/tmp/$lock"