home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / SLAKWARE / A8 / TAR.TGZ / TAR.tar / usr / sbin / dump-remind next >
Text File  |  1993-11-27  |  3KB  |  98 lines

  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. # Get definition of TAPE_FILE, VOLNO_FILE, and so on. 
  17. . /home/gd2/dump/backup-specs
  18.  
  19. mt -f "${TAPE_FILE}" rewind
  20. mt -f "${TAPE_FILE}" offl
  21.  
  22. volno="`cat \"${VOLNO_FILE}\" 2> /dev/null`"
  23. if [ $? -ne 0 ]; then
  24.    volno=0
  25. fi
  26. # Until mib fixes a bug, this needs to be incremented by one. 
  27. volno=`expr ${volno} + 1`
  28.  
  29. # Get a list of people to whom to mail a request for changing the tape.
  30. # This egregious nightmare parses the output from GNU finger which shows
  31. # which users are logged into consoles (and thus in the office and capable
  32. # of changing tapes).
  33. #
  34. # Certain users (like `root') aren't real users, and shouldn't be notified.
  35. # Neither should `zippy', `elvis', etc. (on the GNU machines) since they're
  36. # just test accounts. 
  37. recipients="`
  38.     finger .clients 2> /dev/null \
  39.      | sed -ne '
  40.           1{
  41.             /clientstatus: file has not changed in/{
  42.                n;n;n;n;d
  43.             }
  44.             n;n;d
  45.            }
  46.           s/^..................................................//
  47.           $!{/^$/d
  48.              /^root?*$/d
  49.              /^zippy$/d
  50.              /^fnord$/d
  51.              /^elvis$/d
  52.              /^snurd$/d
  53.              H
  54.             }
  55.           ${g
  56.             : 1
  57.             s/\(\n\)\([A-Za-z0-9_][A-Za-z0-9_]*\)\(\n.*\)\2\(.*\)/\1\2\3\4/g
  58.             s/\n$//g
  59.             t 1
  60.             s/^\n//
  61.             s/\n$//g
  62.             s/\n/, /g
  63.             : 2
  64.             s/, ,/,/g
  65.             t 2
  66.             p
  67.            }'`"
  68.  
  69. # Customized behavior for FSF machines, to bring attention to the fact that
  70. # the tape needs to be changed (who looks at the terminal?)
  71. sendmail -oi -t << __EOF__
  72. From: `basename $0` (backup tape-changing reminder)
  73. To: ${recipients}
  74. Cc: ${ADMINISTRATOR}
  75. Subject: Backup needs new tape for volume ${volno}
  76. Reply-To: ${ADMINISTRATOR}
  77.  
  78. This is an automated report from the backup script running on 
  79. `hostname`. 
  80.  
  81. Volume ${volno} of the backup needs to be put in the tape drive.  Usually
  82. whoever prepared the backup leaves labeled tapes on top of the drive
  83. itself.  If there aren't any more, information about where to find tapes
  84. and how to label them are posted on the wall by apple-gunkies (unhelpfully
  85. obscured by a bookshelf).  An online copy (which is probably more
  86. up-to-date) can also be found in ~friedman/etc/fsf/backup.how.
  87.  
  88. __EOF__
  89.  
  90.  
  91. echo "Please put volume ${volno} in tape drive and press RETURN"
  92. read input
  93. echo "Writing volume ${volno}..."
  94.  
  95. exit 0
  96.  
  97. # eof
  98.