Don't run twice on same directory on same moment

* We can't run optimize script twice on same instant
This commit is contained in:
Camille Lafitte 2020-03-05 15:19:51 +01:00
parent 0fa994d9ec
commit 0ac427fdae

View File

@ -103,6 +103,18 @@ else
done
fi
##################################
# Prevent multi execution on same directory
##################################
lock=$(echo -n "$IMG_PATH" | md5sum)
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"