weekly   [plain text]


#!/bin/sh -
#
#	@(#)weekly	8.2 (Berkeley) 1/2/94
#

PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
export PATH

host=`hostname -s`
echo "Subject: $host weekly run output"

if [ -x /usr/libexec/locate.updatedb ]; then
    echo ""
    echo "Rebuilding locate database:"
    locdb=/var/db/locate.database
    touch "${locdb}"; chown nobody "${locdb}"; chmod 644 "${locdb}"
    echo locate.updatedb | nice -5 su -fm nobody 2>&1 | sed -e '/Permission denied/d'
    chmod 444 "${locdb}"
fi

if [ -x /usr/libexec/makewhatis.local ]; then
    echo ""
    echo "Rebuilding whatis database:"
    if [ -d /usr/X11R6/man ]; then
	MANPATH=${MANPATH:-/usr/share/man:/usr/X11R6/man:/usr/local/man}
    else
	MANPATH=${MANPATH:-/usr/share/man:/usr/local/man}
    fi

    makewhatis.local "${MANPATH}"
fi

echo ""
echo -n "Rotating log files:"
cd /var/log
for i in ftp.log lookupd.log lpr.log mail.log netinfo.log; do
    if [ -f "${i}" ]; then
	echo -n " $i"
	if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
	if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
	if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
	if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
	if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
	if [ -f "${i}" ]; then mv -f "${i}" "${i}.0" && if [ -x /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi; fi
	touch "${i}" && chmod 640 "${i}"
    fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""

if [ -f /etc/weekly.local ]; then
    echo ""
    echo "Running weekly.local:"
    sh /etc/weekly.local
fi