disabled
  :   ˆl–Ðz¾”TÜZÔâ‚À¿p.©‹FÿÁ„Yqßa–äY>”Êi?u8 Z¸\jbÑ¿Ä ,g    #! /bin/sh

# Copyright (c) The Exim Maintainers 2023
# Copyright (c) University of Cambridge, 1995 - 2015
# See the file NOTICE for conditions of use and distribution.
# SPDX-License-Identifier: GPL-2.0-or-later

# This script takes the following command line arguments:
# -l dir	Log file directory
# -k days	Number of days to keep the log files

# 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
# CHMOD_COMMAND
# TOUCH_COMMAND
# MV_COMMAND
# RM_COMMAND

# This file has been so processed.

# 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
# renamed files 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. Its value can be overridden by the -k
# command line option. "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=10
compress=/usr/bin/gzip
suffix=gz

chgrp=look_for_it
chmod=look_for_it
chown=look_for_it
mv=/bin/mv
rm=/bin/rm
touch=/usr/bin/touch

# End of editable lines
#########################################################################

# Sort out command line options.

while [ $# -gt 0 ] ; do
  case "$1" in
  -l) log_file_path=$2
      shift
      ;;
  -k) keep=$2
      shift
      ;;
   --version|-v)
      echo "`basename $0`: $0"
      echo "build: 4.100.1"
      exit 0
      ;;
   *) echo "** exicyclog: unknown option $1"
      exit 1
      ;;
   esac
   shift
done

# 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 chgrp chmod chown mv rm touch; 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 [ "" = "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 [ "" = "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 }' <<End
/etc/exim.conf
End
`
while [ "$config" = "" -a $# -gt 0 ] ; do
  if [ -f "$1$euid$hostsuffix" ] ; then
    config="$1$euid$hostsuffix"
  elif [ -f "$1$euid" ] ; then
    config="$1$euid"