about summary refs log tree commit diff
path: root/bundles/lhost/files/lhost-prune
blob: 878894168e87e3467caed735686b4ed72153b243 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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