#! /bin/sh # # Filename: archive Platform: HP-UX # # Programmer: Br. David Carlson # # Date: January 27, 1997 # # Update: Feb 7, 1997 by Br. David to change owner to root for archived mail. # # Usage: archive # # Purpose: To copy a user's home directory (and any subdirectories) # to /u2/sav/oldusers in case anything is needed again. Also moves the # user's mail to /u2/sav/oldmail. If a mailfile already exists by that # name, the script bails out so that you can decide what to do manually. # If a directory already exists in /u2/sav/oldusers under the user's name # then the script also aborts so that you can decide what to do. if [ $# -ne 1 ] then echo "ERROR: one parameter needed -- the user login id" echo "Usage: archive " exit 1 fi if [ -d /users/$1 ] then if [ -d /u2/sav/oldusers/$1 ] then echo "/u2/sav/oldusers/$1 already exists, aborting script..." echo "Check to see if these are for the same person or not." exit 2 else echo "Copying home directory for $1" cp -r /users/$1 /u2/sav/oldusers rm /u2/sav/oldusers/$1/.plan /u2/sav/oldusers/$1/.project echo "Use userdel -r $1 to remove the account and home directory" fi else echo "No home directory could be found for user $1, aborting script..." exit 3 fi if [ -f /var/mail/$1 ] then if [ -s /var/mail/$1 ] then if [ -s /u2/sav/oldmail/$1 ] then echo "/u2/sav/oldmail/$1 already exists, aborting script..." echo "Check to see if these are for the same person or not." exit 4 else echo "Moving mail file for $1" mv /var/mail/$1 /u2/sav/oldmail chown root /u2/sav/oldmail/$1 fi else echo "Deleting empty mail file for $1" rm /var/mail/$1 fi else echo "No mail file found for user $1" fi exit 0