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>2026-02-23 14:26:55 +0100
committerRobert Günzler <r@gnzler.io>2026-02-23 14:27:10 +0100
commitfe77c8fb1e8edfd802485dba0c1ffdc8e2005ea5 (patch)
tree44b39a1c5e7f7b9dcf3ddd30e7802a8b65e5c742 /bundles/lhost/files/lhost-prune
parent36fc6edc20b4f3f204f136de33a276934203929c (diff)
lhost: fix prune script
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '')
-rwxr-xr-xbundles/lhost/files/lhost-prune12
1 files changed, 7 insertions, 5 deletions
diff --git a/bundles/lhost/files/lhost-prune b/bundles/lhost/files/lhost-prune
index 8788941..bf1a56a 100755
--- a/bundles/lhost/files/lhost-prune
+++ b/bundles/lhost/files/lhost-prune
@@ -1,10 +1,11 @@
 #!/bin/sh
 set -eu
+[ -n "${DEBUG:-}" ] && set -x
 
 main() {
-	local dryrun=$(test -n "${DRYRUN:-}" && printf echo)
+	local dryrun=$([ -n "${DRYRUN:-}" ] && printf echo)
 	local root=${ROOT:-/var/www/lhost}
-	local maxage=${MAXAGE:-30}
+	local maxage=${MAXAGE:-"+30"}
 
 	find ${root} \
 		-type f \
@@ -12,9 +13,10 @@ main() {
 		-not \( \
 		-name 'Caddyfile' -or \
 		-name '.keep' -or \
-		-name "$(cat ${root}/.keep)" \
 		\) \
-		-exec ${dryrun} rm -rv {} +
+		-print |
+		grep -v "$(cat "${root}/.keep")" |
+		xargs -I% ${dryrun} rm -rv '%'
 }
 
-main >/dev/null 2>&1
+main