#! /bin/sh
-# $Cambridge: exim/src/src/exicyclog.src,v 1.2 2004/12/21 16:26:31 ph10 Exp $
+# $Cambridge: exim/src/src/exicyclog.src,v 1.4 2005/06/16 15:48:58 ph10 Exp $
# Copyright (c) 2004 University of Cambridge.
# See the file NOTICE for conditions of use and distribution.
# This is a shell script for cycling exim main and reject log files. Each time
# it is run, the files get "shuffled down" by one, the current one (e.g.
# mainlog) becoming mainlog.01, the previous mainlog.01 becoming mainlog.02,
-# and so on, up to the limit configured here. When the number to keep is
-# greater than 99 (not common, but some people do it), three digits are used
-# (e.g. mainlog.001). The same shuffling happens to the reject logs. All
+# and so on, up to the limit configured here. When the number to keep is
+# greater than 99 (not common, but some people do it), three digits are used
+# (e.g. mainlog.001). The same shuffling happens to the reject logs. All
# renamed files with numbers greater than 1 are compressed.
# This script should be called regularly (e.g. daily) by a root crontab
log_file_path=`echo "$log_file_path" | \
sed 's/^ *:\{0,1\} *syslog *:\{0,1\} *//;s/: *syslog *:/:/;s/: *syslog *$//'`
-# If log_file_path is empty, then the logs we are interested in are called
-# "mainlog" and "rejectlog" in the directory called "log" in the spool
-# directory. Otherwise we fish out the directory from the given path, and
-# also the names of the logs.
+# If log_file_path is empty, try and get the compiled in default by using
+# /dev/null as the configuration file.
+
+if [ "$log_file_path" = "" ]; then
+ log_file_path=`$exim_path -C /dev/null -bP log_file_path | sed 's/.*=[ ]*//'`
+ log_file_path=`echo "$log_file_path" | \
+ sed 's/^ *:\{0,1\} *syslog *:\{0,1\} *//;s/: *syslog *:/:/;s/: *syslog *$//'`
+fi
+
+# If log_file_path is still empty, the logs we are interested in are probably
+# called "mainlog" and "rejectlog" in the directory called "log" in the spool
+# directory. Otherwise we fish out the directory from the given path, and also
+# the names of the logs.
if [ "$log_file_path" = "" ]; then
logdir=$spool_directory/log
while [ $count -gt 1 ]; do
old=`expr $count - 1`
if [ $keep -gt 99 ]; then
- if [ $old -lt 10 ]; then oldt=00$old
+ if [ $old -lt 10 ]; then oldt=00$old
elif [ $old -lt 100 ]; then oldt=0$old
else oldt=$old
- fi
- else
+ fi
+ else
if [ $old -lt 10 ]; then oldt=0$old; else oldt=$old; fi;
- fi
+ fi
if [ -f $mainlog.$oldt ]; then
$mv $mainlog.$oldt $mainlog.$countt
elif [ -f $mainlog.$oldt.$suffix ]; then
if [ $count -lt 10 ]; then countt=00$count
elif [ $count -lt 100 ]; then countt=0$count
else countt=$count
- fi
- else
+ fi
+ else
if [ $count -lt 10 ]; then countt=0$count; else countt=$count; fi
- fi
+ fi
if [ -f $mainlog.$countt ]; then $compress $mainlog.$countt; fi
if [ -f $mainlog.$countt.$suffix ]; then
$chown $user:$group $mainlog.$countt.$suffix