#! /bin/sh
-# $Cambridge: exim/src/src/exicyclog.src,v 1.8 2008/07/28 18:24:13 fanf2 Exp $
-# Copyright (c) 2006 University of Cambridge.
+# Copyright (c) University of Cambridge, 1995 - 2007
# See the file NOTICE for conditions of use and distribution.
# This script takes the following command line arguments:
compress=COMPRESS_COMMAND
suffix=COMPRESS_SUFFIX
-chown=CHOWN_COMMAND
chgrp=CHGRP_COMMAND
chmod=CHMOD_COMMAND
-touch=TOUCH_COMMAND
+chown=CHOWN_COMMAND
mv=MV_COMMAND
rm=RM_COMMAND
+touch=TOUCH_COMMAND
# End of editable lines
#########################################################################
# in different places. We have a fudge that will search the usual suspects if
# requested.
-for cmd in chown chgrp chmod mv rm ; do
+for cmd in chgrp chmod chown mv rm touch; do
eval "oldcmd=\$$cmd"
if [ "$oldcmd" != "look_for_it" ] ; then continue ; fi
newcmd=$cmd
if [ $count -lt 10 ]; then countt=0$count; else countt=$count; fi
while [ $count -gt 1 ]; do
- old=`expr $count - 1`
+ old=`expr -- $count - 1`
if [ $keep -gt 99 ]; then
if [ $old -lt 10 ]; then oldt=00$old
elif [ $old -lt 100 ]; then oldt=0$old
if [ $keep -gt 99 ]; then first=001; else first=01; fi
+# Grab our pid ro avoid race in file creation
+ourpid=$$
+
if [ -f $mainlog ]; then
$mv $mainlog $mainlog.$first
$chown $user:$group $mainlog.$first
- $touch $mainlog
- $chown $user:$group $mainlog
- $chmod 640 $mainlog
+ $touch $mainlog.$ourpid
+ $chown $user:$group $mainlog.$ourpid
+ $chmod 640 $mainlog.$ourpid
+ $mv $mainlog.$ourpid $mainlog
fi
if [ -f $rejectlog ]; then
$mv $rejectlog $rejectlog.$first
$chown $user:$group $rejectlog.$first
- $touch $rejectlog
- $chown $user:$group $rejectlog
- $chmod 640 $rejectlog
+ $touch $rejectlog.$ourpid
+ $chown $user:$group $rejectlog.$ourpid
+ $chmod 640 $rejectlog.$ourpid
+ $mv $rejectlog.$ourpid $rejectlog
fi
if [ -f $paniclog ]; then
$mv $paniclog $paniclog.$first
$chown $user:$group $paniclog.$first
- $touch $paniclog
- $chown $user:$group $paniclog
- $chmod 640 $paniclog
+ $touch $paniclog.$ourpid
+ $chown $user:$group $paniclog.$ourpid
+ $chmod 640 $paniclog.$ourpid
+ $mv $paniclog.$ourpid $paniclog
fi
# Now scan the (0)02 and later files, compressing where necessary, and
$chown $user:$group $paniclog.$countt.$suffix
fi
- count=`expr $count + 1`
+ count=`expr -- $count + 1`
done
# End of exicyclog