/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
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
32
33
34
35
36
37
38
39
40
41
#!/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.cron.sh -a "$script" != /adei/sys/adei_clean.cron.sh ]; then
    /adei/sys/adei_clean.cron.sh
    exit
fi

# This comes first as it is faster
adei_path="$ADEI_PATH"
path="$adei_path/tmp/log/"
find  $path -type f -mtime +14 -exec rm -f '{}' \;


path="$adei_path/tmp/clients/"
# Increasing it even 1 day will lead to a considerable slow down as more rummaging trough pack of files will be needed,
# ADEI currently doesn't reuse files. So, short is good.
# * Second variant for debugging purposes
[ -d "$path" ] && find "$path" -type f -mmin +15 -delete;
#[ -d "$path" ] && find $path -type f -mmin +15 -print0 | xargs -0 -n 100 -I '{}' sh -c 'echo "{}" | wc -w; rm -f {}';

# Problem with this, the previous command actually modifies directories.
# On the other hand, there would be files if somebody currently writting. So 'empty' check is enough
[ -d "$path" ] && find "$path" -type d -empty -delete
#[ -d "$path" ] && find $path -type d -mmin +15 -empty -delete

exit 0