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