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