diff --git a/scripts/cloudron-support b/scripts/cloudron-support index 55b9a4d8d..c913a3d36 100755 --- a/scripts/cloudron-support +++ b/scripts/cloudron-support @@ -580,15 +580,39 @@ function troubleshoot() { check_unbound # this is less fatal after 8.0 } +function cleanup_disk_space() { + read -p "Truncate log files to reclaim space ? (y/N) " -n 1 -r choice + echo -e "\n" + if [[ $choice =~ ^[Yy]$ ]]; then + truncate -s0 /home/yellowtent/platformdata/logs/*/*.log + rm -f /home/yellowtent/platformdata/logs/*.log.* # delete the log.1, log.2 etc + fi + + read -p "Prune docker system resources to reclaim space ? (y/N) " -n 1 -r choice + echo -e "\n" + if [[ $choice =~ ^[Yy]$ ]]; then + docker images prune -fa || true + fi + + read -p "Prune docker volumes to reclaim space ? (y/N) " -n 1 -r choice + echo -e "\n" + if [[ $choice =~ ^[Yy]$ ]]; then + for container in $(docker ps --format "{{.ID}}"); do + docker exec "$container" find /tmp -type f -mtime +1 -delete || true + docker exec "$container" find /run -type f -mtime +1 -delete || true + done + fi +} + function check_disk_space() { # check if at least 10mb root partition space is available if [[ "`df --output="avail" / | sed -n 2p`" -lt "10240" ]]; then - echo "No more space left on /" - echo "This is likely the root case of the issue. Free up some space and also check other partitions below:" - echo "" - df -h - echo "" - echo "To recover from a full disk, follow the guide at https://docs.cloudron.io/troubleshooting/#recovery-after-disk-full" + echo "No more space left on / (see df -h output)" + cleanup_disk_space + fi + + if [[ "`df --output="avail" / | sed -n 2p`" -lt "10240" ]]; then + echo "Still no space despite cleaning up. If you have backups (/var/backups) on this disk, delete old backups to free some space" exit 1 fi