mkfs: drop support for zone != block
[minix.git] / etc / usr / daily
blob8a6c5c60423187da16163d4717f743579d59c146
1 #!/bin/sh
3 # daily - daily cleanup of the system.
5 # Doesn't make sense when running from CD
6 if [ -f /CD ]
7 then exit
8 fi
10 case "$#:$1" in
11 1:cron|1:boot)
12 caller=$1
14 *) echo >&2 "Usage: $0 cron|boot"
15 exit 1
16 esac
18 test -d /usr/adm || exit
19 cd /usr/adm || exit
21 # Last run must have been on a previous day.
22 timestamp=daily.lasttime
23 if test -f $timestamp
24 then
25 set -- `ls -lT $timestamp`
26 test "$6 $7 $9" = "$(date '+%b %d %Y')" && exit
29 # Update last-run time
30 echo >$timestamp
32 # Remove three day old files from various tmp dirs.
33 cleantmp -3 /tmp /usr/tmp /usr/preserve /usr/spool/lpd /usr/spool/at/past
35 # Truncate log files in /usr/adm.
36 test -d old || mkdir old || exit
38 cycle()
40 # Cycle a log file if larger than a size in kilobytes.
41 local size="`expr "$1" + "$1"`"
42 local log="$2"
44 if test -f "$log" && test -n "$(find "$log" -size +"$size")"
45 then
46 test -f "old/$log.2" && cp -p "old/$log.2" "old/$log.3"
47 test -f "old/$log.1" && cp -p "old/$log.1" "old/$log.2"
48 cp -p "$log" "old/$log.1"
49 : > "$log"
53 cycle 100 wtmp
54 cycle 100 log
55 cycle 20 ftplog
56 cycle 200 aftplog
58 # Make copies of /etc/passwd and /etc/shadow if they have been changed.
59 for file in passwd shadow
61 if cmp -s /etc/$file old/$file.1
62 then
63 # Fine.
64 else
65 test -f old/$file.2 && cp -p old/$file.2 old/$file.3
66 test -f old/$file.1 && cp -p old/$file.1 old/$file.2
67 test -f /etc/$file && cp -p /etc/$file old/$file.1
69 done
71 # Update manpage index but don't warn about nonexistant dirs
72 /usr/libexec/makewhatis -f 2>/dev/null
74 # Continue with a local script if present.
75 test -f /usr/local/etc/daily && sh /usr/local/etc/daily $caller
76 exit 0