minix/etc/usr/daily
Ben Gras 0c3983b25a update/fix manpage support
. add bsd-style MLINKS to minix man set, restoring aliases
	  (e.g. man add64 -> int64)
	. update daily cron script to run makewhatis and restore makewhatis
	  in man Makefile (makedb), restores functionality of man -k
	. netbsd imports of man, mdocml, makewhatis, libutil, apropos
	. update man.conf with manpage locations, restoring man [-s] <section>
	. throws out some obsolete manpages
2011-09-28 15:24:15 +00:00

75 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
#
# daily - daily cleanup of the system.
# Doesn't make sense when running from CD
if [ -f /CD ]
then exit
fi
case "$#:$1" in
1:cron|1:boot)
caller=$1
;;
*) echo >&2 "Usage: $0 cron|boot"
exit 1
esac
test -d /usr/adm || exit
cd /usr/adm || exit
# Last run must have been on a previous day.
timestamp=daily.lasttime
if test -f $timestamp
then
set -- `ls -lT $timestamp`
test "$6 $7 $9" = "$(date '+%b %d %Y')" && exit
fi
>$timestamp
# Remove three day old files from various tmp dirs.
cleantmp -3 /tmp /usr/tmp /usr/preserve /usr/spool/lpd /usr/spool/at/past
# Truncate log files in /usr/adm.
test -d old || mkdir old || exit
cycle()
{
# Cycle a log file if larger than a size in kilobytes.
local size="`expr "$1" + "$1"`"
local log="$2"
if test -f "$log" && test -n "$(find "$log" -size +"$size")"
then
test -f "old/$log.2" && cp -p "old/$log.2" "old/$log.3"
test -f "old/$log.1" && cp -p "old/$log.1" "old/$log.2"
cp -p "$log" "old/$log.1"
: > "$log"
fi
}
cycle 100 wtmp
cycle 100 log
cycle 20 ftplog
cycle 200 aftplog
# Make copies of /etc/passwd and /etc/shadow if they have been changed.
for file in passwd shadow
do
if cmp -s /etc/$file old/$file.1
then
# Fine.
else
test -f old/$file.2 && cp -p old/$file.2 old/$file.3
test -f old/$file.1 && cp -p old/$file.1 old/$file.2
test -f /etc/$file && cp -p /etc/$file old/$file.1
fi
done
# Update manpage index
/usr/libexec/makewhatis
# Continue with a local script if present.
test -f /usr/local/etc/daily && sh /usr/local/etc/daily $caller
exit 0