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