mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
add clean_images.sh, fixes #4
This commit is contained in:
parent
a1eaaa3de3
commit
230444f866
24
clean_images.sh
Executable file
24
clean_images.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/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
|
||||||
Loading…
x
Reference in New Issue
Block a user