1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/bash
ADEI_PATH=${ADEI_PATH:-/srv/www/htdocs/adei}
ADEI_ADMIN=${ADEI_ADMIN:-0}
date=$(date -Iseconds)
# Keep the first entry for compatibility with obsolete (but stable) docker containers
[ -f /adei/env ] && . /adei/env
[ -f /tmp/adei.env ] && . /tmp/adei.env
if [ "$ADEI_ADMIN" -ne 1 -a -f "/adei/cfg/.debug" ]; then
echo "$date ADEI is under debug, skipping..."
exit
fi
script=$( cd $(dirname "$0") && pwd )/$( basename "$0" )
if [ -f /adei/sys/adei_clean.manual.sh -a "$script" != /adei/sys/adei_clean.manual.sh ]; then
/adei/sys/adei_clean.manual.sh
exit
fi
adei_path="$ADEI_PATH"
path="$adei_path/tmp/log/"
[ -d "$path" ] && find "$path" -type f -mtime +14 -delete;
# rsync seems faster way to delete huge (100k file+) directories
path="$adei_path/tmp/clients/"
mkdir -p /tmp/empty
[ -d "$path" ] && find "$path" -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -n 1 -P 4 -I '{}' sh -c 'echo {}; rsync -a --delete /tmp/empty/ {}/'
[ -d "$path" ] && find "$path" -type d -empty -delete
|