1 | #!/bin/sh
|
---|
2 | # This file is included in the GNU tar distribution as an example. It is
|
---|
3 | # not used by default unless the proper line is uncommented in backup-specs.
|
---|
4 | # System administrators will probably want to customize this and
|
---|
5 | # backup-specs for their site.
|
---|
6 | #
|
---|
7 | # This script should be run by tar with --info-script (-F) to inform
|
---|
8 | # interested parties that a tape for the next volume of the backup needs to
|
---|
9 | # be put in the tape drive.
|
---|
10 | #
|
---|
11 |
|
---|
12 | # Include location of `sendmail' and GNU finger.
|
---|
13 | PATH="/usr/lib:/usr/local/gnubin:${PATH}"
|
---|
14 | export PATH
|
---|
15 |
|
---|
16 | # Load library routines
|
---|
17 | SYSCONFDIR=${SYSCONFDIR-@sysconfdir@}
|
---|
18 | . ${LIBPATH-@libexecdir@}/backup.sh
|
---|
19 |
|
---|
20 | MT_REWIND
|
---|
21 | MT_OFFLINE
|
---|
22 |
|
---|
23 | # Get a list of people to whom to mail a request for changing the tape.
|
---|
24 | # This egregious nightmare parses the output from GNU finger which shows
|
---|
25 | # which users are logged into consoles (and thus in the office and capable
|
---|
26 | # of changing tapes).
|
---|
27 | #
|
---|
28 | # Certain users (like `root') aren't real users, and shouldn't be notified.
|
---|
29 | # Neither should `zippy', `elvis', etc. (on the GNU machines) since they're
|
---|
30 | # just test accounts.
|
---|
31 | recipients="`
|
---|
32 | finger .clients 2> /dev/null \
|
---|
33 | | sed -ne '
|
---|
34 | 1{
|
---|
35 | /clientstatus: file has not changed in/{
|
---|
36 | n;n;n;n;d
|
---|
37 | }
|
---|
38 | n;n;d
|
---|
39 | }
|
---|
40 | s/^..................................................//
|
---|
41 | $!{/^$/d
|
---|
42 | /^root?*$/d
|
---|
43 | /^zippy$/d
|
---|
44 | /^fnord$/d
|
---|
45 | /^elvis$/d
|
---|
46 | /^snurd$/d
|
---|
47 | H
|
---|
48 | }
|
---|
49 | ${g
|
---|
50 | : 1
|
---|
51 | s/\(\n\)\([A-Za-z0-9_][A-Za-z0-9_]*\)\(\n.*\)\2\(.*\)/\1\2\3\4/g
|
---|
52 | s/\n$//g
|
---|
53 | t 1
|
---|
54 | s/^\n//
|
---|
55 | s/\n$//g
|
---|
56 | s/\n/, /g
|
---|
57 | : 2
|
---|
58 | s/, ,/,/g
|
---|
59 | t 2
|
---|
60 | p
|
---|
61 | }'`"
|
---|
62 |
|
---|
63 | # Customized behavior for FSF machines, to bring attention to the fact that
|
---|
64 | # the tape needs to be changed (who looks at the terminal?)
|
---|
65 | sendmail -oi -t << __EOF__
|
---|
66 | From: `basename $0` (backup tape-changing reminder)
|
---|
67 | To: ${recipients}
|
---|
68 | Cc: ${ADMINISTRATOR}
|
---|
69 | Subject: Backup needs new tape for volume ${TAR_VOLUME}
|
---|
70 | Reply-To: ${ADMINISTRATOR}
|
---|
71 |
|
---|
72 | This is an automated report from the backup script running on
|
---|
73 | `hostname`.
|
---|
74 |
|
---|
75 | Volume ${TAR_VOLUME} of the backup needs to be put in the tape drive.
|
---|
76 | Usually whoever prepared the backup leaves labeled tapes on top of the
|
---|
77 | drive itself. If there aren't any more, information about where to find
|
---|
78 | tapes and how to label them are posted on the wall by apple-gunkies
|
---|
79 | (unhelpfully obscured by a bookshelf). An online copy (which is probably
|
---|
80 | more up-to-date) can also be found in ~friedman/etc/fsf/backup.how.
|
---|
81 | __EOF__
|
---|
82 |
|
---|
83 |
|
---|
84 | echo "Please put volume ${TAR_VOLUME} in tape drive and press RETURN"
|
---|
85 | read input
|
---|
86 | echo "Writing volume ${TAR_VOLUME}..."
|
---|
87 |
|
---|
88 | sendmail -oi -t << __EOF__
|
---|
89 | From: `basename $0` (backup tape-changing reminder)
|
---|
90 | To: ${recipients}
|
---|
91 | Cc: ${ADMINISTRATOR}
|
---|
92 | Subject: Volume ${TAR_VOLUME} for backup has been added
|
---|
93 | Reply-To: ${ADMINISTRATOR}
|
---|
94 |
|
---|
95 | This is an automated report from the backup script running on
|
---|
96 | `hostname`.
|
---|
97 |
|
---|
98 | The backup has been continued, so for now no further attention is required.
|
---|
99 | __EOF__
|
---|
100 |
|
---|
101 | exit 0
|
---|
102 |
|
---|
103 | # eof
|
---|