/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to scripts/cron/adei_clean.manual.sh

  • Committer: Suren A. Chilingaryan
  • Date: 2019-10-05 23:29:32 UTC
  • Revision ID: csa@suren.me-20191005232932-gmfg69fte8092x29
Optimization of cleanup scripts

Show diffs side-by-side

added added

removed removed

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