X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Fexicyclog.src;fp=src%2Fsrc%2Fexicyclog.src;h=4762f21f796e43905472f53c973be91e611ac231;hp=0000000000000000000000000000000000000000;hb=059ec3d9952740285fb1ebf47961b8aca2eb1b4a;hpb=61ec970df30325dbcd8c9d0f0e431dc793126656 diff --git a/src/src/exicyclog.src b/src/src/exicyclog.src new file mode 100644 index 000000000..4762f21f7 --- /dev/null +++ b/src/src/exicyclog.src @@ -0,0 +1,254 @@ +#! /bin/sh +# $Cambridge: exim/src/src/exicyclog.src,v 1.1 2004/10/07 10:39:01 ph10 Exp $ + +# Copyright (c) 2004 University of Cambridge. +# See the file NOTICE for conditions of use and distribution. + +# Except when they appear in comments, the following placeholders in this +# source are replaced when it is turned into a runnable script: +# +# CONFIGURE_FILE_USE_NODE +# CONFIGURE_FILE_USE_EUID +# CONFIGURE_FILE +# BIN_DIRECTORY +# EXICYCLOG_MAX +# COMPRESS_COMMAND +# COMPRESS_SUFFIX +# CHOWN_COMMAND +# CHGRP_COMMAND +# MV_COMMAND +# RM_COMMAND + +# PROCESSED_FLAG + +# 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. The same happens to the reject +# logs. All those with numbers greater than 1 are compressed. + +# This script should be called regularly (e.g. daily) by a root crontab +# entry of the form + +# 1 0 * * * /opt/exim/bin/exicyclog + +# The following lines are generated from Exim's configuration file when +# this source is built into a script, but you can subsequently edit them +# without rebuilding things, as long are you are careful not to overwrite +# the script in the next Exim rebuild/install. "Keep" is the number of old log +# files that are required to be kept. "Compress" and "suffix" define your +# chosen compression method. The others are provided because the location +# of certain commands varies from OS to OS. Sigh. + +keep=EXICYCLOG_MAX +compress=COMPRESS_COMMAND +suffix=COMPRESS_SUFFIX + +chown=CHOWN_COMMAND +chgrp=CHGRP_COMMAND +mv=MV_COMMAND +rm=RM_COMMAND + +# End of editable lines +######################################################################### + +# Some operating systems have different versions in which the commands live +# in different places. We have a fudge that will search the usual suspects if +# requested. + +for cmd in chown chgrp mv rm ; do + eval "oldcmd=\$$cmd" + if [ "$oldcmd" != "look_for_it" ] ; then continue ; fi + newcmd=$cmd + for dir in /bin /usr/bin /usr/sbin /usr/etc ; do + if [ -f $dir/$cmd ] ; then + newcmd=$dir/$cmd + break + fi + done + eval $cmd=$newcmd +done + +# See if this installation is using the esoteric "USE_EUID" feature of Exim, +# in which it uses the effective user id as a suffix for the configuration file +# name. In order for this to work, exicyclog must be run under the appropriate +# euid. + +if [ "CONFIGURE_FILE_USE_EUID" = "yes" ]; then + euid=.`id -u` +fi + +# See if this installation is using the esoteric "USE_NODE" feature of Exim, +# in which it uses the host's name as a suffix for the configuration file name. + +if [ "CONFIGURE_FILE_USE_NODE" = "yes" ]; then + hostsuffix=.`uname -n` +fi + +# Now find the configuration file name. This has got complicated because the +# CONFIGURE_FILE value may now be a list of files. The one that is used is the +# first one that exists. Mimic the code in readconf.c by testing first for the +# suffixed file in each case. + +set `awk -F: '{ for (i = 1; i <= NF; i++) print $i }' <