minix/etc/usr/daily
Jean-Baptiste Boric 69eead77ff New image framework generation
The CD now boots directly from the ISO 9660 filesystem instead of using
MBR partitioning with Minix file systems. This saves some space on the
CD and reduces memory requirements by some unknown amount as the root
ramdisk is completely eliminated.

The x86 hard drive image creation is also rewritten in the same
fashion.

The setup is modified to be more NetBSD-like (unpacking sets
tarballs instead of blindly copying the CD contents). Splitting MINIX
into sets is done in another commit due to it being a nightmare to
rebase.

Since MINIX lacks union mounts for now, a bunch of ramdisks are
generated at run-time to make parts of the filesystem writeable for the
CD. This solution isn't ideal, but it's enough for an installation CD.

Change-Id: Icbd9cca4dafebf7b42c345b107a17679a622d5cd
2015-10-10 19:09:35 +02:00

76 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
#
# daily - daily cleanup of the system.
# Doesn't make sense when running from CD
if [ ! -z $(sysenv bootcd) ]
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
# Update last-run time
echo >$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 but don't warn about nonexistant dirs
/usr/libexec/makewhatis -f 2>/dev/null
# Continue with a local script if present.
test -f /usr/local/etc/daily && sh /usr/local/etc/daily $caller
exit 0