#!/bin/sh # @(#) tar and compress and encrypt and uuencode file so it is reliably mailable #set -x ################################################################################ # PURPOSE: # tar files and directories on parameter list into a compressed file # and uuencode it so that it will expand as MAIL.tar.Z and mail it # to my ID after encrypting it. Should add option to split(1) the file. ################################################################################ # REASON: # Handy and relatively secure way to move a number of (relatively small) # files to another machine just using mail instead of ftp or uucp or # cu or tip or screen captures (like with scripts or xterm logs) or # kermit or xmodem or zmodem or umodem. ################################################################################ # LIMITATIONS: # RECEIVER MUST BE ON UNIX (OR HAVE UUDECODE, CRYPT, UNCOMPRESS, and TAR). # SOME UNIX MACHINES MIGHT NOT HAVE UNCOMPRESS, BUT MIGHT HAVE PACK INSTEAD. # IF IT IS AVAILABLE, USE GUNZIP, WHICH CAN EXPAND OUT BOTH (GUNZIP IS GNU). # SOME MAIL SYSTEMS WILL NOT LET FILES MORE THAN A CERTAIN SIZE THRU. THIS IS # BECOMING LESS AND LESS OF A PROBLEM. ################################################################################ # John S. Urban, Last Revised: 1995/02/06 echo 'Enter CRYPT password' ( cat <<\EOF ================================================================================ auto-download You have been sent an encrypted, compressed tar file. First, save the message to a file from mail. Assuming you have placed the file on XX: #!/bin/sh # decode message (do not need to edit it) and make MAIL.tar.Z.key NAME=${1:-'XX'} uudecode $NAME # just to make sure the file is readable chmod u+r MAIL.tar.Z.key # decrypt, uncompress, and place into MAIL.tar # put the encryption password in where the string KEY appears # crypt KEY MAIL.tar crypt MAIL.tar # check table of contents of tar file and # CAREFULLY NOTE WHAT FILENAMES IT WILL CREATE tar tvf MAIL.tar echo "CONTINUE?" read JUNKO # MOVE MAIL.tar into a temporary or appropriate directory if test "$JUNKO" = 'y' then tar xvf MAIL.tar &&rm -f MAIL.tar* fi exit IT IS ASSUMED YOU HAVE BEEN GIVEN THE CRYPT KEY ================================================================================ EOF echo 'Table of Contents:' tar cvf - $*|tar tvf - echo ================================================================================ # group the compress and stuff or crypt and tar can get into trouble tar cf - $*|(compress|crypt|uuencode MAIL.tar.Z.key) )>$$.uu echo "Mail $$.uu" #)|mail urbanj@cecil.pgh.wec.com urbanj@h01.pgh.wec.com urban@cray.com #)|mail urbanjs@bettis.gov #)|mail urban1@alltel.net #)|mail urban@pittpa.cray.com #)|mail osjsu@\[129.228.2.121\] #)|mail urban@sgi.com exit #=============================================================================== Used to encrypt and make copy with date in name and write that to a migrating archive server export FILENAME yymmdd yymmdd=`date '+%y%m%d'` FILENAME=$yymmdd.tar.Z.xx.uu # do grouping or odd things happen if crypt and tar in same area? ( tar hcf - $*|(compress|crypt|uuencode MAIL.tar.Z.key))|tee /cray/uss/a1/urban/V4S/$FILENAME| exit #=============================================================================== NOTES: uses address way of mailing because on a machine without name service right now might be nice to add options to include an automatic list of who it is from and might be nice to allow an option to specify who to send to. Assume any string with @ in it is an address, or anything that is not a filename, or use a keyword or prompt for it. #From ohkawak@cecil.pgh.wec.com Tue Oct 29 08:32 EST 1996 #From ohkawak@h01.pgh.wec.com Fri Nov 28 09:08 EST 1997