diff --git a/misc/clean-worker.sh b/misc/clean-worker.sh new file mode 100644 index 0000000..72fffa4 --- /dev/null +++ b/misc/clean-worker.sh @@ -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 \ No newline at end of file