| 4 |
- |
1 |
#!/bin/sh
|
|
|
2 |
|
|
|
3 |
CONFIG=/etc/zarafa/server.cfg
|
|
|
4 |
test -f ${CONFIG} || exit 0
|
|
|
5 |
|
|
|
6 |
LOGPATH=$(grep -w client_update_log_path ${CONFIG} | grep -v \# | cut -d= -f2 | sed -e 's/[[:blank:]\r]//g')
|
|
|
7 |
if test -z "${LOGPATH}"; then
|
|
|
8 |
LOGPATH=/var/lib/zarafa/client
|
|
|
9 |
fi
|
|
|
10 |
if ! test -r "${LOGPATH}"; then
|
|
|
11 |
exit 0
|
|
|
12 |
fi
|
|
|
13 |
LOGPATH=$(readlink -e ${LOGPATH})
|
|
|
14 |
if test -z "${LOGPATH}"; then
|
|
|
15 |
exit 0
|
|
|
16 |
fi
|
|
|
17 |
PATHDEPTH=$(echo -en ${LOGPATH} | sed -e 's_[^/]__g' | wc -c)
|
|
|
18 |
if test -n ${LOGPATH} -a ${PATHDEPTH} -gt 2 -a -d ${LOGPATH}; then
|
|
|
19 |
# remove all files older than 14 days
|
|
|
20 |
find ${LOGPATH} -mindepth 2 -maxdepth 2 -type f -ctime +14 -exec rm {} \;
|
|
|
21 |
# remove all empty directories
|
|
|
22 |
find ${LOGPATH} -mindepth 1 -maxdepth 1 -type d -exec rmdir --ignore-fail-on-non-empty {} \;
|
|
|
23 |
fi
|