re-mark 1.29b-2 as not yet uploaded (merge madness!)
[debian/tar] / scripts / dump-remind.in
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 # Copyright 2004-2005, 2010, 2012-2014, 2016 Free Software Foundation,
12 # Inc.
13
14 # This file is part of GNU tar.
15
16 # GNU tar is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 3 of the License, or
19 # (at your option) any later version.
20
21 # GNU tar is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 # GNU General Public License for more details.
25
26 # You should have received a copy of the GNU General Public License
27 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
28
29 # Include location of 'sendmail' and GNU finger.
30 PATH="/usr/lib:/usr/local/gnubin:${PATH}"
31 export PATH
32
33 # Load library routines
34 SYSCONFDIR=${SYSCONFDIR-@sysconfdir@}
35 . ${LIBPATH-@libexecdir@}/backup.sh
36
37 MT_REWIND
38 MT_OFFLINE
39
40 # Get a list of people to whom to mail a request for changing the tape.
41 # This egregious nightmare parses the output from GNU finger which shows
42 # which users are logged into consoles (and thus in the office and capable
43 # of changing tapes).
44 #
45 # Certain users (like 'root') aren't real users, and shouldn't be notified.
46 # Neither should 'zippy', 'elvis', etc. (on the GNU machines) since they're
47 # just test accounts.
48 recipients="`
49     finger .clients 2> /dev/null \
50      | sed -ne '
51           1{
52             /clientstatus: file has not changed in/{
53                n;n;n;n;d
54             }
55             n;n;d
56            }
57           s/^..................................................//
58           $!{/^$/d
59              /^root?*$/d
60              /^zippy$/d
61              /^fnord$/d
62              /^elvis$/d
63              /^snurd$/d
64              H
65             }
66           ${g
67             : 1
68             s/\(\n\)\([A-Za-z0-9_][A-Za-z0-9_]*\)\(\n.*\)\2\(.*\)/\1\2\3\4/g
69             s/\n$//g
70             t 1
71             s/^\n//
72             s/\n$//g
73             s/\n/, /g
74             : 2
75             s/, ,/,/g
76             t 2
77             p
78            }'`"
79
80 # Customized behavior for FSF machines, to bring attention to the fact that
81 # the tape needs to be changed (who looks at the terminal?)
82 sendmail -oi -t << __EOF__
83 From: `basename $0` (backup tape-changing reminder)
84 To: ${recipients}
85 Cc: ${ADMINISTRATOR}
86 Subject: Backup needs new tape for volume ${TAR_VOLUME}
87 Reply-To: ${ADMINISTRATOR}
88
89 This is an automated report from the backup script running on
90 `hostname`.
91
92 Volume ${TAR_VOLUME} of the backup needs to be put in the tape drive.
93 Usually whoever prepared the backup leaves labeled tapes on top of the
94 drive itself.  If there aren't any more, information about where to find
95 tapes and how to label them are posted on the wall by apple-gunkies
96 (unhelpfully obscured by a bookshelf).  An online copy (which is probably
97 more up-to-date) can also be found in ~friedman/etc/fsf/backup.how.
98 __EOF__
99
100
101 echo "\aPlease put volume ${TAR_VOLUME} in tape drive and press RETURN"
102 read input
103 echo "Writing volume ${TAR_VOLUME}..."
104
105 sendmail -oi -t << __EOF__
106 From: `basename $0` (backup tape-changing reminder)
107 To: ${recipients}
108 Cc: ${ADMINISTRATOR}
109 Subject: Volume ${TAR_VOLUME} for backup has been added
110 Reply-To: ${ADMINISTRATOR}
111
112 This is an automated report from the backup script running on
113 `hostname`.
114
115 The backup has been continued, so for now no further attention is required.
116 __EOF__
117
118 exit 0
119
120 # eof