crafatar/clean_images.sh
jomo 332330f68e replacing all single quotes with double quotes
Until now it was a big mess with some strings using single quotes and some others double quotes
We were using way more double quotes, so I chose to use them globally
2014-11-30 00:07:05 +01:00

24 lines
676 B
Bash
Executable File

#!/bin/bash
# deletes old images on heroku
# heroku provides only 300 MB available disk space
# number of files to delete (2 files ~ 400B)
amount="50000" # about 20MB
# max free MB (on /) to trigger deletion
trigger="50"
available=`df -m / | awk "NR==2 { print $4 }"` # MB available on /
if [ "$available" -le "$trigger" ]; then
echo "Deleting old images"
for file in `ls -1tr "/app/skins/faces" | head -n $amount`; do
rm -rf "/app/skins/faces/$file"
done
for file in `ls -1tr "/app/skins/helms" | head -n $amount`; do
rm -rf "/app/skins/helms/$file"
done
echo "done."
else
echo "More than $trigger MB are available ($available MB), not deleting!"
fi