home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
pdksh-4.9-src.tgz
/
tar.out
/
contrib
/
pdksh
/
etc
/
profile
(
.txt
)
< prev
next >
Wrap
Microsoft Windows Help File Content
|
1996-09-28
|
7KB
|
259 lines
# NAME:
# profile - global initialization for sh,ksh
# DESCRIPTION:
# This file is processed during login by /bin/sh
# and /bin/ksh. It is used to setup the default user
# environment.
# SEE ALSO:
# $HOME/.profile
# /etc/ksh.kshrc
# RCSid:
# $Id: profile,v 1.6 93/09/29 08:57:52 sjg Exp $
# @(#)Copyright (c) 1991 Simon J. Gerraty
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
sigs="2 3"
trap "" $sigs # don't interrupt us
add_path () { [ -d $1 ] && eval ${2:-PATH}="\$${2:-PATH}:$1"; }
pre_path () { [ -d $1 ] && eval ${2:-PATH}="$1:\$${2:-PATH}"; }
del_path () { eval ${2:-PATH}=`eval echo :'$'${2:-PATH}: |
sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;"`; }
case "$_INIT_" in
*env*) ;;
*) # do these once
_INIT_="$_INIT_"env
export _INIT_
case `echo -n ""` in
-n*)
_N_=""; _C_="\c";;
_N_="-n"; _C_="";;
esac
if [ -f /unix ]; then
# System V
[ -z "$TZ" -a -f /etc/TIMEZONE ] && . /etc/TIMEZONE
set -- `who -r`
case "$3" in
S|5|0) SINGLE=y;;
*) SINGLE=n;;
esac
# sys_config.sh should set ARCH,OS,C,N,HOSTNAME,uname
# we use these in lots of scripts...
[ "$SINGLE" = n -a -f /etc/sys_config.sh ] && . /etc/sys_config.sh
else
[ -f /etc/sys_config.sh ] && . /etc/sys_config.sh
SINGLE=n # doesn't matter so much
# pick one of the following for the default umask
umask 002 # relaxed -rwxrwxr-x
# umask 022 # cautious -rwxr-xr-x
# umask 027 # uptight -rwxr-x---
# umask 077 # paranoid -rwx------
# you can override the default umask
# for specific groups later...
if [ -d /local ]; then
LOCAL=/local
else
LOCAL=/usr/local
# defaults (might be reset below)
PATH=/bin:/usr/bin
MANPATH=/usr/man
SPOOL=/usr/spool
defterm=vt220
# set system specific things,
# eg. set PATH,MANPATH
# override default ulimit if desired.
# defult ulmit is unlimited on SunOS
# and 4Mb for most System V
case $OS in
SunOS)
# On sun's /bin -> /usr/bin so leave it out!
PATH=/usr/bin:/usr/ucb:/usr/5bin:.
SCO-UNIX)
defterm=ansi
B.O.S.)
MANPATH=/usr/catman
SRC_COMPAT=_SYSV
export SRC_COMPAT
386bsd)
MANPATH=/usr/share/man
add_path /usr/X386/man MANPATH
MAILDIR=/var/mail
SPOOL=/var/spool
esac
# add_path only adds them if they exist
add_path /sbin
add_path /usr/sbin
add_path /usr/distbin
add_path /usr/ucb
add_path /usr/lbin
add_path /usr/dbin
add_path /usr/ldbin
add_path ${LOCAL}/bin
add_path /usr/bin/X11
# ensure . is at end
PATH=$PATH:.
case "$HOME" in
/) ;;
""|/tmp)
echo "Using /tmp for HOME"
HOME=/tmp; export HOME
pre_path $HOME/bin
esac
add_path ${LOCAL}/man MANPATH
# make sure these are set at least once
LOGNAME=${LOGNAME:-`logname`}
USER=${USER:-$LOGNAME}
# we expect id to produce output like:
# uid=100(sjg) gid=10(staff) groups=10(staff),...
S='('
E=')'
GROUP=`id | cut -d= -f3 | \
sed -e "s;^[^${S}][^${S}]*${S}\([^${E}][^${E}]*\)${E}.*$;\1;"`
UID=`id | cut -d= -f2 | \
sed -e "s;\([^${S}]*\)${S}.*;\1;"`
# set some group specific defaults
case "$GROUP" in
staff) # staff deal with things that non-staff
# have no business looking at
umask 027
extern) # we put external accounts in group "extern"
# give them as much privacy as we can...
umask 077
ulimit 16384 # 8Mb file limit
TMOUT=600 # idle timeout
esac
unset S E GROUP
export LOCAL TTY PATH LOGNAME USER
if [ -t 1 ]; then
# we are interactive
TTY=`tty`
TTY=`basename $TTY`
if [ -f /etc/organization ]; then
ORGANIZATION="`cat /etc/organization`"
COPYRIGHT="Copyright (c) `date +19%y` $ORGANIZATION"
export ORGANIZATION COPYRIGHT
# set up some env variables
MAIL=${MAILDIR:-$SPOOL/mail}/$USER
MAILPATH=$MAIL:/etc/motd
EMACSDIR=${LOCAL}/lib/emacs
PAGER=${PAGER:-more}
export MAIL EMACSDIR MANPATH MAILPATH PAGER
CVSROOT=${LOCAL}/src/master
EDITOR=emacs
FCEDIT=$EDITOR
export CVSROOT FCEDIT EDITOR
case $UID in
0) PROMPT="<$LOGNAME@$HOSTNAME># ";;
*) PROMPT="<$LOGNAME@$HOSTNAME>$ ";;
esac
[ -f /etc/profile.TeX ] && . /etc/profile.TeX
else
TTY=none
# test (and setup if we are Korn shell)
if [ "$RANDOM" != "$RANDOM" ]; then
# we are Korn shell
SHELL=/bin/ksh
ENV=${HOME%/}/.kshrc
if [ ! -f $ENV ]; then
ENV=/etc/ksh.kshrc
HISTFILE=${HOME%/}/.ksh_hist
case $UID in
PROMPT="<$LOGNAME@$HOSTNAME:!># ";;
*) PROMPT="<$LOGNAME@$HOSTNAME:!>$ ";;
esac
export HISTSIZE HISTFILE ENV
CDPATH=.:$HOME
if [ "$TMOUT" ]; then
typeset -r TMOUT
else
SHELL=/bin/sh
PS1=$PROMPT
export SHELL PS1 EDITOR PATH PROMPT HOSTNAME CDPATH
# login time initialization
case "$_INIT_" in
*log*) ;;
*) _INIT_="$_INIT_"log
case "$SINGLE" in
y) ;;
if [ TTY != none -a "$0" != "-su" -a "$LOGNAME" = "`logname`" -a ! -f ~/.hushlogin ]
then
case $OS in
B.O.S.)
case $TTY in
ttyp*) stty sane # problems with telnetd
;;
esac
;;
esac
# ensure known state
stty isig icanon intr '^c' erase '^h' kill '^u' eof '^d'
mesg y
case $TERM in
network|unknown|dialup|"")
echo ${_N_} "Enter terminal type [$defterm]: ${_C_}" 1>&2
read tmpterm
TERM=${tmpterm:-$defterm}
;;
esac
case "$TERM" in
pc3)
stty erase ^?
;;
esac
# not all of the following are appropriate at all sites
# Sun's don't need to cat /etc/motd for instance
case "$OS" in
SunOS) ;;
SCO-UNIX)
[ -s /etc/motd ] && cat /etc/motd
[ -x /usr/bin/mail -a -s "$MAIL" ] &&
echo "You have mail."
[ -x /usr/bin/news ] && /usr/bin/news -n
;;
386bsd)
# hardware flow control works so use it
case $TTY in
ttyd*) # dialups
stty -ixon -ixany
stty crtscts
;;
esac
;;
[ -s /etc/motd ] && cat /etc/motd
if [ -x /usr/bin/mailx ]; then
if mailx -e; then
echo "You have mail."
# show the the headers, this might
# be better done in .profile so they
# can override it.
# mailx -H
fi
fi
[ -x /usr/bin/news ] && /usr/bin/news -n
;;
esac
if [ -f $LOCAL/etc/1stlogin.ann ]; then
[ -f $HOME/... ] || sh $LOCAL/etc/1stlogin.ann
# [ -x /usr/games/fortune ] && /usr/games/fortune -a
# remind folk who turned on reply.pl to turn it off.
if [ -f $HOME/.forward ]; then
echo "Your mail is being forwarded to:"
cat $HOME/.forward
if [ -f $HOME/.recording ]; then
echo "Perhaps you should run \"reply.pl off\""
fi
unset tmpterm defterm C N _C_ _N_
esac
case "$TERM" in
network|unknown|"") TERM=vt100;;
esac
export TERM TTY
# Handle X-terminals if necessary
[ "$SINGLE" = n -a -f /etc/profile.X11 ] && . /etc/profile.X11
# make sure you have this bit last
trap $sigs # restore signals
unset sigs