#! /bin/sh # daily DCC cron job # This script should be run daily or more often when there is a shortage # of disk space to run dbclean to discard and compress old checksums. # It also discards old DCC client log files. #. By default it is installed in @libexecdir@. Instead of being copied # to a directory such as /etc/cron/daily on some systems, a symbolic link # should be used. # cron tab entry like this can be used: # 15 2 * * * @libexecdir@/cron-dccd # It is best to choose different times for each of your DCC servers so # that your servers are not all busy cleaning their databases at once. # -x turn on debugging # -F do not follow symbolic links when cleaning log files and per-user # whitelists because symbolic links are used to share per-user # directories # -h dir override DCC home directory @prefix@ # -a args for dbclean in addition to DBCLEAN_ARGS in @prefix@/dcc_conf # --S-LICENSE-- # $Revision: 1.86 $ # @configure_input@ exec 1>&2 /dev/null; then : else USERDIRS="$USERDIRS $DCCIFD_USERDIRS" fi fi # trim the greylist database case X"$GREY_ENABLE" in [oO][nN]) GREY_ENABLE=on ;; X) if test -n "$GREY_CLIENT_ARGS"; then GREY_ENABLE=on fi ;; esac if test -z "$GREY_SRVR_ID"; then if grep '# auto local greylist server-ID' $DCC_HOMEDIR/ids >/dev/null \ && grep '^32702[ ]' $DCC_HOMEDIR/ids >/dev/null; then GREY_SRVR_ID=32702 fi fi if test -n "$GREY_SRVR_ID" -a "$GREY_ENABLE" = on; then if $DCC_LIBEXEC/dbclean -Gon -i $GREY_SRVR_ID $GREY_DBCLEAN_ARGS; then : else # assume EX_DCC_RESTART=79 if test $? -eq 79; then eval $DCC_LOGGER \"running dbclean -S and restarting greylist server\" $DCC_LIBEXEC/dbclean -S -Gon -i $GREY_SRVR_ID $GREY_DBCLEAN_ARGS $DCC_LIBEXEC/start-grey fi fi fi # Delete old checksums from the dccd database if it seems dccd can run. # For historical reasons, SRVR_ID set and DCCD_ENABLE null # also turns on dccd. case "$DCCD_ENABLE" in [oO][fF][fF]) DCCD_ENABLE=off;; *) DCCD_ENABLE=on;; esac if test -n "$SRVR_ID" -a "$DCCD_ENABLE" = on; then if $DCC_LIBEXEC/dbclean -i $SRVR_ID $SADDR $DBCLEAN_ARGS; then : else # assume EX_DCC_RESTART=79 if test $? -eq 79; then eval $DCC_LOGGER \"running dbclean -S and restarting DCC server\" $DCC_LIBEXEC/dbclean -S -i $SRVR_ID $SADDR $DBCLEAN_ARGS $DCC_LIBEXEC/start-dccd fi fi fi # Remove old dccm and dccifd log files. if test -n "$DBCLEAN_LOGDAYS" -a -n "$LOGDIRS$USERDIRS"; then ( find $LOGDIRS $USERDIRS $FOLLOW -type f \ \( \( -name 'msg.*' -mtime +$DBCLEAN_LOGDAYS \) \ -o \( -name 'tmp.*' -mtime +1 \) \) -print \ | @DCC_XARGS@ /bin/rm find $LOGDIRS $USERDIRS $FOLLOW -depth -type d \ \( -name '[0-9]' -o -name '[0-9][0-9]' \ -o -name '[0-9][0-9][0-9]' \) -print \ | @DCC_XARGS@ /bin/rmdir ) 2>&1 | grep -v 'No such file or directory' \ | grep -v 'Directory not empty' fi # Notify users about new log files. # The file $DCC_LIBEXEC/webuser-notify must be a script that will send # a suitable message. See the example in the cgi-bin directory. if test -n "$USERDIRS" -a -x $DCC_LIBEXEC/webuser-notify; then for DIR in $USERDIRS; do MARKER=$DIR/notify.marker if test -r $MARKER; then NEWER="-newer $MARKER" else NEWER= fi rm -f $MARKER.new touch $MARKER.new # Find usernames with a pending message or with a new but not newer # than new log file. Avoid newer than new files to ensure we # generate at most one notification per log file. (cd $DIR; find . $FOLLOW -type f \( -name notify.pending \ -o \( $NEWER -name 'msg.*' \) \) \ ! -newer $MARKER.new -print ) \ | sed -n -e 's@\./\(.*\)/log/msg\..*@\1@p' \ -e 's@\./\(.*\)/log/[0-9/]*/msg\..*@\1@p' \ -e 's@\./\(.*\)/notify.pending$@\1@p' \ | sort -u \ | $DCC_LIBEXEC/webuser-notify $DEBUG -d "$DIR" mv -f $MARKER.new $MARKER done fi # encourage local DCC clients to switch back @bindir@/cdcc -q rtt >/dev/null 2>&1