Line | |
---|
1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # daily - daily cleanup of the system.
|
---|
4 |
|
---|
5 | # Doesn't make sense when running from CD
|
---|
6 | if [ -f /CD ]
|
---|
7 | then exit
|
---|
8 | fi
|
---|
9 |
|
---|
10 | case "$#:$1" in
|
---|
11 | 1:cron|1:boot)
|
---|
12 | caller=$1
|
---|
13 | ;;
|
---|
14 | *) echo >&2 "Usage: $0 cron|boot"
|
---|
15 | exit 1
|
---|
16 | esac
|
---|
17 |
|
---|
18 | test -d /usr/adm || exit
|
---|
19 | cd /usr/adm || exit
|
---|
20 |
|
---|
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
|
---|
27 | fi
|
---|
28 | >$timestamp
|
---|
29 |
|
---|
30 | # Remove three day old files from various tmp dirs.
|
---|
31 | cleantmp -3 /tmp /usr/tmp /usr/preserve /usr/spool/lpd /usr/spool/at/past
|
---|
32 |
|
---|
33 | # Truncate log files in /usr/adm.
|
---|
34 | test -d old || mkdir old || exit
|
---|
35 |
|
---|
36 | cycle()
|
---|
37 | {
|
---|
38 | # Cycle a log file if larger than a size in kilobytes.
|
---|
39 | local size="`expr "$1" + "$1"`"
|
---|
40 | local log="$2"
|
---|
41 |
|
---|
42 | if test -f "$log" && test -n "$(find "$log" -size +"$size")"
|
---|
43 | then
|
---|
44 | test -f "old/$log.2" && cp -p "old/$log.2" "old/$log.3"
|
---|
45 | test -f "old/$log.1" && cp -p "old/$log.1" "old/$log.2"
|
---|
46 | cp -p "$log" "old/$log.1"
|
---|
47 | : > "$log"
|
---|
48 | fi
|
---|
49 | }
|
---|
50 |
|
---|
51 | cycle 100 wtmp
|
---|
52 | cycle 100 log
|
---|
53 | cycle 20 ftplog
|
---|
54 | cycle 200 aftplog
|
---|
55 |
|
---|
56 | # Make copies of /etc/passwd and /etc/shadow if they have been changed.
|
---|
57 | for file in passwd shadow
|
---|
58 | do
|
---|
59 | if cmp -s /etc/$file old/$file.1
|
---|
60 | then
|
---|
61 | # Fine.
|
---|
62 | else
|
---|
63 | test -f old/$file.2 && cp -p old/$file.2 old/$file.3
|
---|
64 | test -f old/$file.1 && cp -p old/$file.1 old/$file.2
|
---|
65 | test -f /etc/$file && cp -p /etc/$file old/$file.1
|
---|
66 | fi
|
---|
67 | done
|
---|
68 |
|
---|
69 | # Continue with a local script if present.
|
---|
70 | test -f /usr/local/etc/daily && sh /usr/local/etc/daily $caller
|
---|
71 | exit 0
|
---|
Note:
See
TracBrowser
for help on using the repository browser.