about summary refs log tree commit diff
path: root/bundles/lhost/files/lhost-prune
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2025-09-07 17:32:13 +0200
committerRobert Günzler <r@gnzler.io>2025-09-07 17:42:42 +0200
commit38be6c13f76e893cf47636257071b440dec0c5b2 (patch)
treef7ded3235a7e3362cbd1ed3d91523968fe0faf90 /bundles/lhost/files/lhost-prune
initial commit
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bundles/lhost/files/lhost-prune')
-rwxr-xr-xbundles/lhost/files/lhost-prune20
1 files changed, 20 insertions, 0 deletions
diff --git a/bundles/lhost/files/lhost-prune b/bundles/lhost/files/lhost-prune
new file mode 100755
index 0000000..8788941
--- /dev/null
+++ b/bundles/lhost/files/lhost-prune
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -eu
+
+main() {
+	local dryrun=$(test -n "${DRYRUN:-}" && printf echo)
+	local root=${ROOT:-/var/www/lhost}
+	local maxage=${MAXAGE:-30}
+
+	find ${root} \
+		-type f \
+		-mtime ${maxage} \
+		-not \( \
+		-name 'Caddyfile' -or \
+		-name '.keep' -or \
+		-name "$(cat ${root}/.keep)" \
+		\) \
+		-exec ${dryrun} rm -rv {} +
+}
+
+main >/dev/null 2>&1