diff --git a/manyfold/cli/manyfold.sh b/manyfold/cli/manyfold.sh
index 95f1f46..4fa7fa7 100755
--- a/manyfold/cli/manyfold.sh
+++ b/manyfold/cli/manyfold.sh
@@ -38,7 +38,22 @@ overlayfs(){
test -d /manyfold || return 0; # nothing to override
echocolor "[$APPNAME]" "applying filesystem overlay"
cd /manyfold
- rsync -ravuzi * /.
+ rsync -rvzi * /.
+}
+
+# cron-like function using sleep (./manifold.sh infinite 3600 zip -r /backup.zip /)
+infinite(){
+ trap 'echocolor "/bin/infinite $*: process ended..infinite does not care.."; sleep 2s' INT
+ interval=$1
+ shift
+ loop(){
+ echocolor "[/bin/infinite $*]" "$(date) started"
+ while sleep ${interval}; do
+ echocolor "[/bin/infinite $*]" "$(date) executing"
+ "$@"
+ done;
+ }
+ loop "$@"
}
db(){
@@ -111,6 +126,28 @@ rename_app(){
sed -i 's|powered_by_html:.*|powered_by_html: Powered by XR Forge, Manyfold, XR Fragments and NIX|g' /usr/src/app/config/locales/*.yml
}
+cleanup_big_files(){
+ local DIR=$1
+ local MAX_DAYS=$2
+ local MAX_MB=$3
+ test -n "$MAX_DAYS" && test -n "$MAX_MB" && {
+ find "$DIR" -type f -mtime +"$MAX_DAYS" -size +$(( $MAX_MB * 1024 ))k | while read file; do
+ echo "deleting: $file"
+ rm "$file"
+ done
+ }
+}
+
+delete_big_files(){
+ #./manyfold infinite 86400 cleanup_big_files /mnt/models 5 5 & # 5 days for files over 5MB (5 in 2025, 6 in 2026 e.g. ?)
+ # check every day to delete files older than 5 days and >5mb (5mb in 2025, 6mb in 2026 e.g.)
+ test -z "$NO_DELETEBIGFILES" && {
+ intervalSec=86400 # = 1 day
+ maxMB=$(( $(date +%Y) - 2020 ))
+ $0 infinite 5 cleanup_big_files /mnt/models $intervalSec $maxMB &
+ }
+}
+
# The new entrypoint of the docker
boot(){
echocolor "[$APPNAME]" "booting..."
@@ -121,6 +158,8 @@ boot(){
set_modelpath
rclone_mount
set_upload_path
+ delete_big_files
+
exec "$@" # exec prevents error 's6-overlay-suexec: fatal: can only run as pid 1'
}