comparison debian/dcc-server.cron.daily.diff @ 1:9b8d79ac0dc3

blindly adding debian patch for old version
author Peter Gervai <grin@grin.hu>
date Tue, 10 Mar 2009 14:25:08 +0100
parents
children
comparison
equal deleted inserted replaced
0:c7f6b056b673 1:9b8d79ac0dc3
1 --- dcc-1.2.74.orig/debian/dcc-server.cron.daily
2 +++ dcc-1.2.74/debian/dcc-server.cron.daily
3 @@ -0,0 +1,156 @@
4 +#! /bin/sh
5 +
6 +# daily DCC cron job
7 +
8 +# This script should be run daily or more often when there is a shortage
9 +# of disk space to run dbclean to discard and compress old checksums.
10 +# It also discards old DCC client log files.
11 +
12 +#. By default it is installed in /usr/lib/dcc. Instead of being copied
13 +# to a directory such as /etc/cron/daily on some systems, a symbolic link
14 +# should be used.
15 +
16 +# Copyright (c) 2004 by Rhyolite Software
17 +#
18 +# Permission to use, copy, modify, and distribute this software for any
19 +# purpose with or without fee is hereby granted, provided that the above
20 +# copyright notice and this permission notice appear in all copies.
21 +#
22 +# THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE DISCLAIMS ALL
23 +# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
24 +# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE
25 +# BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
26 +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
27 +# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
28 +# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
29 +# SOFTWARE.
30 +# Rhyolite Software DCC 1.2.50-1.45 $Revision: 1.1 $
31 +# Generated automatically from cron-dccd.in by configure.
32 +
33 +exec 1>&2 </dev/null
34 +
35 +DCC_LOGGER="logger -s -p ${DCC_ERROR_LOG_FACILITY-mail.err} -t DCC"
36 +DCC_HOMEDIR=/var/lib/dcc
37 +DEBUG=
38 +QUIET=-q
39 +# check the args once to get the home directory
40 +while getopts "xh:a:" c; do
41 + case $c in
42 + x) set -x; DEBUG=-x; QUIET=;;
43 + h) DCC_HOMEDIR="$OPTARG";;
44 + *) ;;
45 + esac
46 +done
47 +. $DCC_HOMEDIR/dcc_conf
48 +# deal with bash reserved $UID and old versions of dcc_conf
49 +if test 0"$DCC_CONF_VERSION" -lt 2 -a -z "$DCCUID" -a ! -z "$UID"; then
50 + DCCUID="$UID"
51 +fi
52 +
53 +USAGE="`basename $0`: [-x] [-h homedir] [-a args]"
54 +OPTIND=1
55 +while getopts "xh:a:" c; do
56 + case $c in
57 + x) ;;
58 + h) ;;
59 + a) DBCLEAN_ARGS="$DBCLEAN_ARGS $OPTARG";;
60 + *) eval $DCC_LOGGER "$USAGE"; exit 1;;
61 + esac
62 +done
63 +shift `expr $OPTIND - 1 || true`
64 +if test "$#" -ne 0; then
65 + eval $DCC_LOGGER "$USAGE"
66 + exit 1
67 +fi
68 +
69 +# make the paths absolute and trim the per day/hour/minute business
70 +LOGDIR=`echo $DCCM_LOGDIR \
71 + | sed -e "s@^[DHM]?@@" -e "s@^[^/]@$DCC_HOMEDIR/&@"`
72 +USERDIRS=`echo $DCCM_USERDIRS \
73 + | sed -e "s@^[^/]@$DCC_HOMEDIR/&@"`
74 +
75 +OARGS=64dDGNRPSVqi
76 +DBCLEAN_ARGS="$QUIET -h $DCC_HOMEDIR $DCC_LOG_ARGS $DBCLEAN_ARGS"
77 +GREY_DBCLEAN_ARGS=`echo "$DBCLEAN_ARGS" \
78 + | sed -e "s/-[eEt][ ]*[^ ]\{1,\}//g" \
79 + -e "s/\(-[$OARGS]\{1,\}\)[eEt][ ]*[^ ]\{1,\}/\1/g"`
80 +
81 +# Removed old dccm log files.
82 +if test ! -z "$DBCLEAN_LOGDAYS"; then
83 + if test -d "$LOGDIR"; then
84 + find "$LOGDIR" -follow \( -name 'msg.*' -o -name 'tmp.*' \) \
85 + -mtime +$DBCLEAN_LOGDAYS \
86 + | xargs /bin/rm -f
87 + # remove empty subdirectories
88 + find "$LOGDIR" -follow -depth -name '[0-9]*' -type d \
89 + | xargs /bin/rmdir 2>/dev/null
90 + fi
91 + # clean per-user logs
92 + if test "$USERDIRS" != "" -a -d "$USERDIRS"; then
93 + find "$USERDIRS" -follow \( -name 'msg.*' -o -name 'tmp.*' \) \
94 + -mtime +$DBCLEAN_LOGDAYS \
95 + | xargs /bin/rm -f
96 + fi
97 +fi
98 +
99 +# Notify users about new log files.
100 +# The file $DCC_LIBEXEC/webuser-notify must be a script that will send
101 +# a suitable message. See the example in the cgi-bin directory.
102 +if test "$USERDIRS" != "" -a -d "$USERDIRS" \
103 + -a -x $DCC_LIBEXEC/webuser-notify; then
104 + MARKER=$USERDIRS/notify.marker
105 + touch $MARKER.new
106 + if test -r $MARKER; then
107 + NEWER="-newer $MARKER"
108 + else
109 + NEWER=
110 + fi
111 + # Find usernames with a pending message or with a new but not newer
112 + # than new log files
113 + # Avoid newer than new files to ensure we generate at most
114 + # one notification per log file.
115 + find "$USERDIRS" -follow \( -name notify.pending \
116 + -o \( -name 'msg.*' $NEWER \) \) ! -newer $MARKER.new \
117 + | sed -n -e 's@.*/\([^/]*/[^/]*\)/log/msg\.[^/]*$@\1@p' \
118 + -e 's@.*/\([^/]*/[^/]*\)/notify.pending$@\1@p' \
119 + | sort -u \
120 + | $DCC_LIBEXEC/webuser-notify $DEBUG -d "$USERDIRS"
121 +
122 + mv -f $MARKER.new $MARKER
123 +fi
124 +
125 +
126 +# trim the greylist database
127 +case X"$GREY_ENABLE" in
128 + [oO][nN])
129 + GREY_ENABLE=on
130 + ;;
131 + X)
132 + if test ! -z "$GREY_CLIENT_ARGS"; then
133 + GREY_ENABLE=on
134 + fi
135 + ;;
136 +esac
137 +if test ! -z "$GREY_SRVR_ID" -a "$GREY_ENABLE" = on; then
138 + SADDR=`expr "X$GREY_DCCD_ARGS" : ".*-[$OARGS]*a[ ]*\([^ ]*\).*"`
139 + if test ! -z "$SADDR"; then
140 + SADDR="-a $SADDR"
141 + fi
142 + $DCC_LIBEXEC/dbclean -Gon -i $GREY_SRVR_ID $SADDR $GREY_DBCLEAN_ARGS
143 +fi
144 +
145 +
146 +# Delete old checksums from the dccd database if it seems dccd can run.
147 +# For historical reasons, SRVR_ID set and DCCD_ENABLE nul
148 +# turns on dccd
149 +case "$DCCD_ENABLE" in
150 + [oO][fF][fF]) DCCD_ENABLE=off;;
151 + *) DCCD_ENABLE=on;;
152 +esac
153 +if test ! -z "$SRVR_ID" -a "$DCCD_ENABLE" = on; then
154 + SADDR=`expr "X$DCCD_ARGS" : ".*-[$OARGS]*a[ ]*\([^ ]*\).*"`
155 + if test ! -z "$SADDR"; then
156 + SADDR="-a $SADDR"
157 + fi
158 + $DCC_LIBEXEC/dbclean -i $SRVR_ID $SADDR $DBCLEAN_ARGS
159 +fi