home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / pdksh-4.5.lha / pdksh-4.5 / etc / profile < prev    next >
Encoding:
Text File  |  1993-12-01  |  5.3 KB  |  231 lines

  1. :
  2. # NAME:
  3. #    profile - global initialization for sh,ksh
  4. #
  5. # DESCRIPTION:
  6. #    This file is processed during login by /bin/sh
  7. #    and /bin/ksh.  It is used to setup the default user
  8. #    environment.  It is processed with root privs.
  9. #
  10. # SEE ALSO:
  11. #    $HOME/.profile
  12. #    /etc/ksh.kshrc
  13. #
  14. # RCSid:
  15. #    $Id: profile,v 1.3 1992/05/03 08:28:27 sjg Exp $
  16. #    @(#)Copyright (c) 1991 Simon J. Gerraty
  17. #
  18. #    This file is provided in the hope that it will
  19. #    be of use.  There is absolutely NO WARRANTY.
  20. #    Permission to copy, redistribute or otherwise
  21. #    use this file is hereby granted provided that 
  22. #    the above copyright notice and this notice are
  23. #    left intact. 
  24.  
  25. case "$_INIT_" in
  26. *env*) ;;
  27. *)    # do these once
  28.     _INIT_="$_INIT_"env
  29.     export _INIT_
  30.     # sys_config.sh should set ARCH,OS,C,N,HOSTNAME,uname
  31.     # we use these in lots of scripts...
  32.     [ -f /etc/sys_config.sh ] && . /etc/sys_config.sh
  33.  
  34.     # pick one of the following for the default umask
  35.     # umask 002    # relaxed    -rwxrwxr-x
  36.     umask 022    # cautious    -rwxr-xr-x
  37.     # umask 027    # uptight    -rwxr-x---
  38.     # umask 077    # paranoid    -rwx------
  39.     # you can override the default umask
  40.     # for specific groups later...
  41.  
  42.     if [ -d /local ]; then
  43.         LOCAL=/local
  44.     else
  45.         LOCAL=/usr/local
  46.     fi
  47.  
  48.     # set system specific things,
  49.     # eg. set PATH,MANPATH 
  50.     # override default ulimit if desired.
  51.     # defult ulmit is unlimited on SunOS
  52.     # and 4Mb for most System V
  53.     case $OS in
  54.     SunOS)
  55.         # On sun's /bin -> /usr/bin so leave it out!
  56.         PATH=.:/usr/bin:/usr/ucb:/usr/5bin
  57.         MANPATH=/usr/man
  58.         defterm=vt220
  59.         ;;
  60.     SCO-UNIX)
  61.         PATH=.:/bin:/usr/bin:/usr/lbin:/usr/dbin:/usr/ldbin
  62.         MANPATH=/usr/man
  63.         defterm=ansi
  64.         ;;
  65.     B.O.S.)
  66.         PATH=.:/bin:/usr/bin
  67.         if [ -d /usr/ucb ]; then
  68.             PATH=$PATH:/usr/ucb
  69.         fi
  70.         MANPATH=/usr/catman
  71.         defterm=vt220
  72.         SRC_COMPAT=_SYSV
  73.         export SRC_COMPAT
  74.         ;;
  75.     *)
  76.         PATH=.:/bin:/usr/bin
  77.         if [ -d /usr/ucb ]; then
  78.             PATH=$PATH:/usr/ucb
  79.         fi
  80.         MANPATH=/usr/catman
  81.         defterm=vt220
  82.         ;;
  83.     esac
  84.     if [ -d ${LOCAL}/bin ]; then
  85.         PATH=$PATH:${LOCAL}/bin
  86.     fi
  87.     if [ -d $HOME/bin -a "$HOME" != / ]; then
  88.         PATH=$PATH:$HOME/bin
  89.     fi
  90.     if [ -d ${LOCAL}/man ]; then
  91.         MANPATH=$MANPATH:${LOCAL}/man
  92.     fi
  93.     # make sure these are set at least once
  94.     LOGNAME=${LOGNAME:-`logname`}
  95.     USER=${USER:-$LOGNAME}
  96.  
  97.     # this is adapted from my whoami.sh
  98.     # we expect id to produce output like:
  99.     # uid=100(sjg) gid=10(staff) groups=10(staff),...
  100.     S='('
  101.     E=')'
  102.     GROUP=`id | cut -d= -f3 | \
  103.         sed -e "s;^[^${S}][^${S}]*${S}\([^${E}][^${E}]*\)${E}.*$;\1;"`
  104.  
  105.     # set some group specific defaults
  106.     case "$GROUP" in
  107.     staff)    # staff deal with things that non-staff 
  108.         # have no business looking at
  109.         umask 027
  110.         ;;
  111.     extern)    # we put external accounts in group "extern"
  112.         # give them as much privacy as we can...
  113.         umask 077
  114.         ulimit 16384    # 8Mb file limit
  115.         TMOUT=600    # idle timeout
  116.         ;;
  117.     esac
  118.  
  119.     unset S E GROUP
  120.     export LOCAL TTY PATH LOGNAME USER
  121.  
  122.     if [ -t 1 ]; then
  123.         TTY=`tty`
  124.         TTY=`basename $TTY`
  125.         ORGANIZATION=""
  126.         COPYRIGHT="Copyright (c) `date +19%y` $ORGANIZATION"
  127.         export ORGANIZATION COPYRIGHT
  128.  
  129.         # set up some env variables
  130.         MAIL=/usr/spool/mail/$USER
  131.         MAILPATH=/usr/spool/mail/$USER:/etc/motd
  132.         EMACSDIR=${LOCAL}/lib/emacs
  133.         PAGER=${PAGER:-more}
  134.         export MAIL EMACSDIR MANPATH MAILPATH PAGER
  135.  
  136.         EDITOR=emacs
  137.         FCEDIT=${EDITOR}    
  138.  
  139.         PROMPT="<$LOGNAME@$HOSTNAME>$ "
  140.         PUBDIR=/usr/spool/uucppublic
  141.         export PUBDIR 
  142.         [ -f /etc/profile.TeX ] && . /etc/profile.TeX
  143.     else
  144.         TTY=none
  145.     fi
  146.  
  147.     # test (and setup if we are Korn shell)
  148.     if [ "$RANDOM" != "$RANDOM" ]; then
  149.         # we are Korn shell
  150.         SHELL=/bin/ksh
  151.         ENV=${HOME%/}/.kshrc
  152.         PROMPT="<$LOGNAME@$HOSTNAME:!>$ "
  153.         export HISTSIZE HISTFILE ENV
  154.         CDPATH=.:$HOME
  155.         if [ "$TMOUT" ]; then
  156.             typeset -r TMOUT
  157.         fi
  158.     else
  159.         SHELL=/bin/sh
  160.     fi
  161.     PS1=$PROMPT
  162.     export SHELL PS1 EDITOR PATH PROMPT HOSTNAME CDPATH FCEDIT
  163.  
  164. ;;
  165. esac
  166.  
  167. # login time initialization
  168. case "$_INIT_" in
  169. *log*) ;;
  170. *)    _INIT_="$_INIT_"log
  171.  
  172.     if [ $TTY != none -a "$0" != "-su" -a "$LOGNAME" = "`logname`" -a ! -f ~/.hushlogin ]
  173.     then
  174.         case $TERM in
  175.         network|unknown|dialup|"") 
  176.             echo $N "Enter terminal type [$defterm]: $C" 1>&2
  177.             read tmpterm
  178.             TERM=${tmpterm:-$defterm}
  179.             ;;
  180.         esac
  181.         # set up desired tty modes
  182.         stty intr '^c'
  183.         case $TERM in
  184.         wy50)    stty erase '^h';;
  185.         *)    stty erase '^?';;
  186.         esac
  187.         # welcome first time users
  188.         [ -r ${LOCAL}/etc/1stlogin.ann -a ! -f $HOME/... ] && \
  189.             . ${LOCAL}/etc/1stlogin.ann
  190.         # not all of the following are appropriate at all sites
  191.         # Sun's don't need to cat /etc/motd for instance
  192.         case "$OS" in
  193.         SunOS)    ;;
  194.         SCO-UNIX)    
  195.             [ -s /etc/motd ] && cat /etc/motd
  196.             [ -x /usr/bin/mail -a -s "$MAIL" ] && 
  197.                 echo "You have mail."
  198.             [ -x /usr/bin/news ] && /usr/bin/news -n
  199.             ;;
  200.         *)
  201.             [ -s /etc/motd ] && cat /etc/motd
  202.             if [ -x /usr/bin/mailx ]; then
  203.                if mailx -e; then
  204.                 echo "You have mail."
  205.                 # show the the headers, this might
  206.                 # be better done in .profile so they
  207.                 # can override it.
  208. #                mailx -H
  209.               fi
  210.             fi
  211.             [ -x /usr/bin/news ] && /usr/bin/news -n
  212.             ;;
  213.         esac
  214.         [ -x /usr/games/fortune ] && /usr/games/fortune -a
  215.         # remind folk who turned on reply.pl to turn it off.
  216.         if [ -f $HOME/.forward ]; then
  217.             echo "Your mail is being forwarded to:"
  218.             cat $HOME/.forward
  219.             if [ -f $HOME/.recording ]; then
  220.                 echo "Perhaps you should run \"reply.pl off\""
  221.             fi
  222.         fi
  223.     fi
  224.     unset tmpterm defterm C N
  225.     TERM=${TERM:-unknown}
  226.     export TERM TTY
  227. ;;
  228. esac
  229. # Handle X-terminals if necessary
  230. [ -f /etc/profile.X11 ] && . /etc/profile.X11
  231.