#!/bin/sh #---------------------------------------------------------------------------- # /usr/sbin/logrotate-all # # Creation : 2023-02-01 holbru # Last update: $Id$ # # Copyright (c) 2011-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # vorlage von: # Mon Jan 23 2023 Fabian Vogt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- set -eu NAME=logrotate DAEMON=/usr/sbin/${NAME} LOG_NAME=logger LOG=/usr/bin/${LOG_NAME} SENDMAIL=/usr/sbin/sendmail QUALIFY_DOMAIN=$(hostname -f) # check if DAEMON exists and has executable rights if [ ! -x "${DAEMON}" ] then ${LOG} -t logrotate "logrotate is missing, or has no executable rights - exiting" exit 1 fi # exit immediately if there is another instance running if /sbin/checkproc ${DAEMON} then ${LOG} -t logrotate "ALERT another instance of logrotate is running - exiting" exit 1 fi configs= # Only read /usr/etc/logrotate.conf if /etc/logrotate.conf does not exist if ! [ -e /etc/logrotate.conf ] then configs="${configs} /usr/etc/logrotate.conf" else configs="${configs} /etc/logrotate.conf" fi # Then read in all of {/usr,}/etc/logrotate.d/*, with /etc/ overriding /usr/etc/. dirs= [ -d /usr/etc/logrotate.d ] && dirs="/usr/etc/logrotate.d" [ -d /etc/logrotate.d ] && dirs="${dirs} /etc/logrotate.d" if [ -n "${dirs}" ] then for confname in $(find ${dirs} -type f -printf "%P\n" | sort -u) do if [ -e "/etc/logrotate.d/${confname}" ] then configs="${configs} /etc/logrotate.d/${confname}" else configs="${configs} /usr/etc/logrotate.d/${confname}" fi done fi TMPF=$(/usr/bin/mktemp -t logrotate.XXXXXXXXXX) #exec ${DAEMON} ${configs} 2>&1 >> ${TMPF} if [ -s "${TMPF}" ] then # wait a sec, we might just have restarted syslog sleep 1 { echo "From: The Logrotate Agent " echo "To: " echo "Subject: Logrotate Report from Server '${HOSTNAME}'" echo "Mime-Version: 1.0" echo "X-Mailer: sendmail logrotate on eisfair" echo "Content-Type: text/plain; charset=us-ascii" echo "Content-Transfer-Encoding: 8bit" echo echo echo "Dispatched from Logrotate on Server '${HOSTNAME}'" echo "Current Date: $(/bin/date +%Y-%m-%d) Time: $(/bin/date +%H:%M:%S)" echo cat ${TMPF} } | ${SENDMAIL} postmaster@${QUALIFY_DOMAIN} fi rm -f ${TMPF} exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------