home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / policy / part01 / scripts / 1stlogin.sh next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-02-28  |  3.6 KB  |  119 lines

  1. :
  2. #!/bin/sh
  3. # $Id: 1stlogin.sh,v 5.3.2.5 91/09/03 09:55:00 policy USENET $
  4. #
  5. # Copyright (c) 1991 by Bergen B. Hovell, Jr.
  6. # You may not distribute or otherwise use this work for any profit-making
  7. # purpose without the express permission of the author, but this work is
  8. # otherwise freely distributable so long as this header remains attached.
  9. ##################### edit these in the Makefile! ########################
  10. PATH=
  11. pager=
  12. record=
  13. poldir=
  14. announcement=
  15. defterm=
  16. mssgto=
  17. name=
  18. fast=
  19. ##########################################################################
  20. IFS="
  21. "
  22. export PATH IFS
  23.  
  24. trap '' 2;                            # Allow no user interrupts
  25.  
  26. logdate=`exec 'date'`                 # Date of record of this announcement
  27.  
  28. # Let's do it:
  29. if [ ! -r "$announcement" ]
  30. then echo "Subject: New-login info failed for '$name' on $logdate!" \
  31.                                                                | mail $mssgto
  32. else if [ ! "$TERM" ]
  33.      then TERM=$defterm
  34.           export TERM
  35.           noterm=yes
  36.      fi
  37.      
  38.      # Do we have a "clear" function available?
  39.      if [ -x /bin/clear -o -x /usr/bin/clear -o -x /usr/ucb/clear ]
  40.      then clear=`clear`
  41.      # ....or curses?
  42.      elif  [ -x /usr/bin/tput ]
  43.      then clear=`tput clear`
  44.      # ....nada....
  45.      else clear=
  46.      fi
  47.      
  48.      # Call up the new-login announcement into the pager, and apologize if
  49.      # we are not a fast machine:
  50.      echo  $clear
  51.      $pager $announcement
  52.      echo  $clear
  53.      if [ "$fast" != "yes" ]
  54.      then cat << "     endmssg"  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                           ADMINISTRATIVE NOTICE!
  62.  
  63.           * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  64.           *                                                     *
  65.           *  Sorry for the brief delay, but I must do some one- *
  66.           *  time tasks related to your first login session.    *
  67.           *                                                     *
  68.           *  Please be patient................................  *
  69.           *                                                     *
  70.           * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.      endmssg
  79.      fi
  80.      
  81.      # Create a file for us to test hereafter so this script never runs
  82.      # again for this user:
  83.      cat << "     endmssg"  > $record
  84.  
  85.                * * * * * * * * * * * * * * * * * * * * * * * 
  86.                *                  NOTICE                   *
  87.                *                                           *
  88.                *  The existence of this file suppresses    *
  89.                *  the one-time login announcement about    *
  90.                *  policies on this host. If you remove     *
  91.                *  this file, that announcement will again  *
  92.                *  bore you the next time you log in. :-)   *
  93.                *                                           *
  94.                * * * * * * * * * * * * * * * * * * * * * * * 
  95.  
  96.                              Thanks.....System Administrator
  97.      endmssg
  98.      chmod 440 $record
  99.      
  100.      # Notify the administrator that the user has completed his first login and
  101.      # has seen the announcement (or that he did not!):
  102.      if [ -f $record ]
  103.      then echo "Subject: Successful new-login '$name' logged in on $logdate" \
  104.                                                                | mail $mssgto
  105.      else echo "Subject: New-login info failed for '$name' on $logdate!"     \
  106.                                                                | mail $mssgto
  107.      fi
  108.  
  109.      # If he didn't have a TERM value coming into this script on this system,
  110.      # then be sure it is null going out:
  111.      if [ "$noterm" ]
  112.      then TERM=""
  113.           export TERM
  114.      fi
  115.  
  116. fi
  117.    
  118. # end of file
  119.