#!/bin/sh # # This adminstration file contains commands that archuser should run once a # day. A good time is somewhere around midnight, local time # # 1995 (c) Bunyip Information Systems Inc. # written by Luc Boulianne # # $Id: daily.admin,v 1.4 1995/03/14 21:20:57 pedro Exp $ # prog=$0 MAIL=/usr/ucb/Mail PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin export PATH usage() { cat - <> /dev/null ; then gzip="y"; else gzip="n"; cat - << EOC Note: \`gzip' not found on this system. This script will run nonetheless, however please install it if you can, as we are using some features of \`gzip' not available to \`compress'. Bunyip can assist if you need help. EOC fi osname=`uname` rel=`uname -r | sed 's/\..*$//'` case $osname in "SunOS") tlink="-h" if [ x$rel = x4 ] ; then PS="/bin/ps aguxwww" else PS="/usr/ucb/ps aguxwww" fi ;; "AIX") tlink="-L" PS="/bin/ps -aef" ;; esac home=`get_home archie` odirsrv=`$PS | grep dirsrv | grep -v grep | awk '{print $1}'` debug "dirsrv owned by $odirsrv" if [ "$odirsrv" = "root" ] ; then # A truly atrocious hack. Need to have a configuration script for # this stuff - lucb eval `grep '^ARCHIE_USER' ../bin/mail_stats`; id=`id | sed 's/(.*$//' | sed 's/^.*=//'`; debug "Your uid is $id"; if [ $id -ne 0 ]; then echo "*PROBLEM* Dirsrv is running as root. $0 must also run as root" echo "*PROBLEM* Dirsrv is running as root. $0 must also run as root"|\ $MAIL -s "Problem with $0" $ARCHIE_USER exit 2; fi fi debug "Cleaning up archie log files in $home/logs" cd $home/logs if [ ! \( -d history -o $tlink history \) ] ; then mkdir history || abort fi # Keep 32 days of archie and email logs f=`ls *.log`; for l in $f; do $home/scripts/rotate $v -d $home/logs/history -c $l 32; chown archie $l; chgrp archie $l; done debug "Taking care of the prospero logs" cd $home/pfs if [ ! \( -d history -o $tlink history \) ] ; then mkdir history || abort fi $home/scripts/rotate $v pfs.log chown archie pfs.log restart_dirsrv # $home/scripts/eval-perf.pl < /pfs/pfs.log debug "Generating prospero statistics" cat /pfs/pfs.log.* | $home/scripts/prospero-stats.pl | \ $MAIL -s "Prospero Statistics Report" $dest debug "Archiving prospero log" if cat /pfs/pfs.log.* | $home/scripts/trimplog.pl $v -d /pfs/history -g $gzip ; then debug "Trimming prospero log" rm -f /pfs/pfs.log.* fi cd /pfs/history debug "Clean history files older than six months" find . -mtime +180 -print | xargs rm # If gzip is not available, then compress the log files after 7 # days. DO NOT COMPRESS immediately. trimplog may append to an already # existing log file. If gzip is available, compression will be automatic, # as gzip allows concatenation of compressed items. if [ $gzip = "n" ] ; then debug "Compressing archived log files older than seven days" find . -mtime +7 -print | xargs compress fi