1 |
laffer1 |
592 |
#!/bin/sh |
2 |
|
|
# |
3 |
|
|
# $FreeBSD: ports/mail/squirrelmail/files/111.clean-squirrelmail,v 1.1 2004/01/13 09:14:24 edwin Exp $ |
4 |
|
|
# |
5 |
|
|
# This script copied from /etc/periodic/daily/110.clean-tmps,v 1.6.2.4 2002/10/13 19:59:01 |
6 |
|
|
# |
7 |
|
|
# Perform attachment directory cleaning so that long-lived systems |
8 |
|
|
# don't end up with excessively old files there. |
9 |
|
|
# |
10 |
|
|
|
11 |
|
|
# Define these variables in either /etc/periodic.conf or |
12 |
|
|
# /etc/periodic.conf.local to override the default values. |
13 |
|
|
# |
14 |
|
|
# 111.clean-squirrelmail |
15 |
|
|
clean_squirrelmail_enable="NO" # Delete squirrelmail attachments |
16 |
|
|
clean_squirrelmail_dirs="/var/spool/squirrelmail/attach" # Delete under here |
17 |
|
|
clean_squirrelmail_days="10" # If not accessed for |
18 |
|
|
clean_squirrelmail_ignore="quota.user quota.group" # Don't delete these |
19 |
|
|
clean_squirrelmail_verbose="YES" # Mention files deleted |
20 |
|
|
|
21 |
|
|
# If there is a global system configuration file, suck it in. |
22 |
|
|
# |
23 |
|
|
if [ -r /etc/defaults/periodic.conf ] |
24 |
|
|
then |
25 |
|
|
. /etc/defaults/periodic.conf |
26 |
|
|
source_periodic_confs |
27 |
|
|
fi |
28 |
|
|
|
29 |
|
|
case "$clean_squirrelmail_enable" in |
30 |
|
|
[Yy][Ee][Ss]) |
31 |
|
|
if [ -z "$clean_squirrelmail_days" ] |
32 |
|
|
then |
33 |
|
|
echo '$clean_squirrelmail_enable is set but' \ |
34 |
|
|
'$clean_squirrelmail_days is not' |
35 |
|
|
rc=2 |
36 |
|
|
else |
37 |
|
|
echo "" |
38 |
|
|
echo "Removing old SquirrelMail Attachment files:" |
39 |
|
|
|
40 |
|
|
set -f noglob |
41 |
|
|
args="-atime +$clean_squirrelmail_days -mtime +$clean_squirrelmail_days" |
42 |
|
|
args="${args} -ctime +$clean_squirrelmail_days" |
43 |
|
|
[ -n "$clean_squirrelmail_ignore" ] && |
44 |
|
|
args="$args "`echo " ${clean_squirrelmail_ignore% }" | |
45 |
|
|
sed 's/[ ][ ]*/ ! -name /g'` |
46 |
|
|
case "$clean_squirrelmail_verbose" in |
47 |
|
|
[Yy][Ee][Ss]) |
48 |
|
|
print=-print;; |
49 |
|
|
*) |
50 |
|
|
print=;; |
51 |
|
|
esac |
52 |
|
|
|
53 |
|
|
rc=$(for dir in $clean_squirrelmail_dirs |
54 |
|
|
do |
55 |
|
|
[ ."${dir#/}" != ."$dir" -a -d $dir ] && cd $dir && { |
56 |
|
|
find -d . -type f $args -delete $print |
57 |
|
|
find -d . ! -name . -type d -empty -mtime \ |
58 |
|
|
+$clean_squirrelmail_days -delete $print |
59 |
|
|
} | sed "s,^\\., $dir," |
60 |
|
|
done | tee /dev/stderr | wc -l) |
61 |
|
|
[ -z "$print" ] && rc=0 |
62 |
|
|
[ $rc -gt 1 ] && rc=1 |
63 |
|
|
set -f glob |
64 |
|
|
fi;; |
65 |
|
|
|
66 |
|
|
*) rc=0;; |
67 |
|
|
esac |
68 |
|
|
|
69 |
|
|
exit $rc |