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