feat: add cleanup-worker script

This commit is contained in:
wpetit 2022-10-20 21:22:17 +02:00
parent 1ddb5691ca
commit 77de05e856
1 changed files with 26 additions and 0 deletions

26
misc/clean-worker.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
cleanup_docker() {
RUNNING_CONTAINERS=$(docker ps -q)
if [ ! -z "$RUNNING_CONTAINERS" ]; then
docker stop $RUNNING_CONTAINERS
fi
docker system prune -f -a --volumes
docker network prune -f
service docker restart
}
cleanup_old_workspaces() {
# Suppression des workspaces dont la dernière date
# de modification est supérieure à 7 jours.
find /workspace -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
}
main() {
cleanup_docker
cleanup_old_workspaces
}
main