#!/bin/sh 
# Eliminate BIRCH from a user's account.
# Lines added to user .rc files all contain #_BIRCH.
# Remove these lines.

# Synopsis nobirch [-Q]
#
#      -Q - quiet option. Do not prompt to verify 

JOBID=$$
CHOICE="n"

if  [ "$1" = "-Q" ]
  then
    CHOICE='y'
  else
    echo '>>> You are about remove access to the BIRCH system for this account!'
    echo '>>> Type y to continue, n to exit'
    read CHOICE
fi


if [ "$CHOICE" = "y" ]
   then 
     # RM_CMD - command to be used for removing files and directories
    if [ -f /usr/bin/rm ]
      then
	RM_CMD=/usr/bin/rm
      else 
	if [ -f /bin/rm ]
	  then
            RM_CMD=/bin/rm
          else
            RM_CMD=rm
	fi
     fi

   #. . . . . .  delete BIRCH directories
   cd
   unset noclobber
   for file in ".login" ".cshrc" ".profile" ".bash_profile" ".bash_login" ".bashrc" ".zshenv"
      do
      echo 'Deleting lines containing #_BIRCH from '$file
      grep -v '#_BIRCH' $file > temp.$JOBID
      cat temp.$JOBID > $file
      chmod 700 $file
      $RM_CMD -f temp.$JOBID
      done
   echo Done!
   echo Logout and login again so that the changes can take effect.
   echo 'If you wish to restore BIRCH access, type'
   echo    $BIRCH/admin/newuser

else
 echo '>>> exiting program. No files changed.'
fi 


