git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tidying
[exim.git]
/
src
/
src
/
exicyclog.src
diff --git
a/src/src/exicyclog.src
b/src/src/exicyclog.src
index 56e3b664440ea2874a5b16598b21715c2641240d..4fb160ac03a54e1ec5c7e7050921abca7ea12d35 100644
(file)
--- a/
src/src/exicyclog.src
+++ b/
src/src/exicyclog.src
@@
-1,7
+1,6
@@
#! /bin/sh
#! /bin/sh
-# $Cambridge: exim/src/src/exicyclog.src,v 1.7 2008/02/06 12:35:03 nm4 Exp $
-# Copyright (c)
2006 University of Cambridge.
+# Copyright (c)
University of Cambridge, 1995 - 2015
# See the file NOTICE for conditions of use and distribution.
# This script takes the following command line arguments:
# See the file NOTICE for conditions of use and distribution.
# This script takes the following command line arguments:
@@
-53,12
+52,12
@@
keep=EXICYCLOG_MAX
compress=COMPRESS_COMMAND
suffix=COMPRESS_SUFFIX
compress=COMPRESS_COMMAND
suffix=COMPRESS_SUFFIX
-chown=CHOWN_COMMAND
chgrp=CHGRP_COMMAND
chmod=CHMOD_COMMAND
chgrp=CHGRP_COMMAND
chmod=CHMOD_COMMAND
-
touch=TOUCH
_COMMAND
+
chown=CHOWN
_COMMAND
mv=MV_COMMAND
rm=RM_COMMAND
mv=MV_COMMAND
rm=RM_COMMAND
+touch=TOUCH_COMMAND
# End of editable lines
#########################################################################
# End of editable lines
#########################################################################
@@
-84,7
+83,7
@@
done
# in different places. We have a fudge that will search the usual suspects if
# requested.
# in different places. We have a fudge that will search the usual suspects if
# requested.
-for cmd in ch
own chgrp mv rm
; do
+for cmd in ch
grp chmod chown mv rm touch
; do
eval "oldcmd=\$$cmd"
if [ "$oldcmd" != "look_for_it" ] ; then continue ; fi
newcmd=$cmd
eval "oldcmd=\$$cmd"
if [ "$oldcmd" != "look_for_it" ] ; then continue ; fi
newcmd=$cmd
@@
-233,16
+232,16
@@
$b
# Now do the job. First remove the files that have "fallen off the bottom".
# Look for both the compressed and uncompressed forms.
# Now do the job. First remove the files that have "fallen off the bottom".
# Look for both the compressed and uncompressed forms.
-if [ $keep -lt 10 ]; then
keept=0$keep; else keept
=$keep; fi;
+if [ $keep -lt 10 ]; then
rotation=0$keep; else rotation
=$keep; fi;
-if [ -f $mainlog.$
keept ]; then $rm $mainlog.$keept
; fi;
-if [ -f $mainlog.$
keept.$suffix ]; then $rm $mainlog.$keept
.$suffix; fi;
+if [ -f $mainlog.$
rotation ]; then $rm $mainlog.$rotation
; fi;
+if [ -f $mainlog.$
rotation.$suffix ]; then $rm $mainlog.$rotation
.$suffix; fi;
-if [ -f $rejectlog.$
keept ]; then $rm $rejectlog.$keept
; fi;
-if [ -f $rejectlog.$
keept.$suffix ]; then $rm $rejectlog.$keept
.$suffix; fi;
+if [ -f $rejectlog.$
rotation ]; then $rm $rejectlog.$rotation
; fi;
+if [ -f $rejectlog.$
rotation.$suffix ]; then $rm $rejectlog.$rotation
.$suffix; fi;
-if [ -f $paniclog.$
keept ]; then $rm $paniclog.$keept
; fi;
-if [ -f $paniclog.$
keept.$suffix ]; then $rm $paniclog.$keept
.$suffix; fi;
+if [ -f $paniclog.$
rotation ]; then $rm $paniclog.$rotation
; fi;
+if [ -f $paniclog.$
rotation.$suffix ]; then $rm $paniclog.$rotation
.$suffix; fi;
# Now rename all the previous old files by increasing their numbers by 1.
# When the number is less than 10, insert a leading zero.
# Now rename all the previous old files by increasing their numbers by 1.
# When the number is less than 10, insert a leading zero.
@@
-251,7
+250,7
@@
count=$keep
if [ $count -lt 10 ]; then countt=0$count; else countt=$count; fi
while [ $count -gt 1 ]; do
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
if [ $old -lt 10 ]; then oldt=00$old
elif [ $old -lt 100 ]; then oldt=0$old
@@
-283,28
+282,34
@@
done
if [ $keep -gt 99 ]; then first=001; else first=01; fi
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
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
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
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
fi
# Now scan the (0)02 and later files, compressing where necessary, and
@@
-334,7
+339,7
@@
while [ $count -le $keep ]; do
$chown $user:$group $paniclog.$countt.$suffix
fi
$chown $user:$group $paniclog.$countt.$suffix
fi
- count=`expr $count + 1`
+ count=`expr
--
$count + 1`
done
# End of exicyclog
done
# End of exicyclog