next up previous contents
Next: /etc/fstab Up: RedHat 9 Lab Machines Previous: /etc/nsswitch.conf   Contents

/etc/profile

# /etc/profile
#
# for CIS server and lab machines
#
# Eric Thern
#
# 04.20.2001 -- initial edits, creation
# 11.03.2001 -- updated some aliases (ps, ls)
# 09.01.2002 -- redid profile to support servers and lab machines
# 09.15.2002 -- added quota information, moved mail notificaton around, added SSH/telnet check
#

#
# initial PATH variable - keep /usr/local/bin in the front, override ls, du, ps, (and other standard GNU utils)
#

PATH=/usr/local/bin:/usr/local/j2sdk1.4.1_01/bin:/usr/sbin:/usr/bin:/bin:/usr/ccs/bin:/usr/local/mysql/bin:/usr/lo
cal/teTeX/bin/sparc-sun-solaris2.8:/usr/local/maple/bin

MANPATH=/usr/local/man:/usr/local/j2sdk1.4.1_01/man:/usr/share/man:/usr/local/mysql/man:/usr/local/teTeX/man:/usr/
local/maple/man

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/usr/local/lib:/usr/local/teTeX/lib:/usr/local/j2sdk1.4.1_01/lib

PYTHONPATH=/usr/local/lib/python2.1:/usr/local/lib/python2.1/lib-dynload:/usr/share/ask


#
# standard PS1 -- looks like any other PS1
#
PS1="[\u@\h \W]\\$ "

# Eric's favorite PS1 (nobody else likes it, though)
#PS1="\n[\u@\H] [(tty)\l] [\d \@]\n[\w]\\$ "

#
# set these readonly, can't exploit them
#
HISTSIZE=5000
readonly HISTFILE HISTFILESIZE HISTSIZE

export PATH PYTHONPATH MANPATH LD_LIBRARY_PATH PS1 CLASSPATH

trap ""  2 3
export LOGNAME PATH

#
# CISMACHINE variable
#
CISMACHINE=`echo $HOSTNAME | awk -F. '{print $1}'`


if [ "$CISMACHINE" = "ultraminos" ]
then
        if [ "$TERM" = "" ]
        then
                if /bin/i386
                then
                        TERM=sun-color
                else
                        TERM=sun
                fi
                export TERM
        fi
else
        CISMACHINE=other
fi

if [ "$CISMACHINE" = "ultraminos" ]
then
        #
        # set aliases for ultraminos
        #
alias turnin=/export/home/faculty/nostrand/turnin/bin/turnin
alias check=/export/home/faculty/nostrand/turnin/bin/check
alias retrieve=/export/home/faculty/nostrand/turnin/bin/retrieve
alias ls="/usr/local/bin/ls --color"
alias dir=ls
alias ps=/usr/ucb/ps
alias vi=vim

        #
        # set ulimits on ultraminos based on user class
        #
        
        if [ "`/usr/xpg4/bin/id -g`" = "84" ]
                then
                # faculty ulimits, higher limits than students
                        ulimit -c 32768
                        ulimit -d 32768
                        ulimit -f 1000000
                        ulimit -n 512
                        ulimit -s 65536
                        ulimit -t 3500
                        # don't limit virtual memory size, has HUGE problems with java!!!
                        #ulimit -v 32768
                        # would like to limit processes... but cant :(
                        #ulimit -u 512
                else
                        # set timeout to 2 hours for students.  no stragglers!
                        TMOUT=7200
                        # set this to readonly to not allow people to change it
                        #readonly TMOUT
                        #alias w="w $USER"
                        #alias finger="finger -s -m $USER"
                        #alias who="who am i"
                # student ulimits, limiting core file size to 0
                # memory, cputime, virtual memory, open files, etc.
                        ulimit -c 0
                        ulimit -d 16384
                        ulimit -f 512000
                        ulimit -n 256
                        ulimit -s 16384
                        ulimit -t 1500
                        #ulimit -v 32768
                        #ulimit -u 256

        fi
else

        #
        # set aliases on lab machines
        #
alias turnin="echo 'turnin, check and retrieve only work on ultraminos - not on lab machines.  Please ssh to ultra
minos to use these utilities'"
alias check="echo 'turnin, check and retrieve only work on ultraminos - not on lab machines.  Please ssh to ultram
inos to use these utilities'"
alias retrieve="echo 'turnin, check and retrieve only work on ultraminos - not on lab machines.  Please ssh to ult
raminos to use these utilities'"
alias submit="echo 'submit will only work on ultraminos - not on the lab machines.  Please ssh to ultraminos to us
e this utility'"

alias cp='cp -i'
alias l.='ls -d .[a-zA-Z]* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

        #
        # set ulimits on lab machines
        #
        ulimit -c 65536
        ulimit -d 32768
        ulimit -f 1000000
        ulimit -l 128000
        ulimit -m 196000
        ulimit -s 65536
        ulimit -t 3500
        ulimit -u 256
       #ulimit -v 128000
fi



#       Login and -su shells get /etc/profile services.
#       -rsh is given its environment in its .profile.


case "$0" in
-bash | -sh | -ksh | -jsh)

if [ "$CISMACHINE" = "ultraminos" ]
then
        
        #
        # set ultraminos server defaults
        #

        #
        # SSH sets the $USER variable correctly, but telnet does not
        # so lets not mess around - lets set it here for everyone.
        #
        USER="`/usr/xpg4/bin/id -un`"
        LOGNAME=$USER


else

        #
        # set lab machine defaults
        #

        PATH=$PATH:/usr/X11R6/bin

        USER="`id -un`"
        LOGNAME=$USER
        MAIL="/var/spool/mail/$USER"
        HOSTNAME=`/bin/hostname`
        if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
            INPUTRC=/etc/inputrc
        fi

        export USER LOGNAME HOSTNAME MAIL PATH
fi
esac

if [ "$CISMACHINE" = "ultraminos" ]
then

quota=$( cat /etc/drgchk |grep -n "$USER " |grep ":$USER " | awk '{ print $4/1000 }')
space=$( cat /etc/drgchk |grep -n "$USER " |grep ":$USER " | awk '{ print $3/1000 }')

        if [ ! -f .hushlogin ]
        then
                /usr/sbin/quota
                #       Allow the user to break the Message-Of-The-Day only.
                trap "trap '' 2"  2
                /bin/cat -s /etc/motd
                trap "" 2

        fi

        echo " "
        echo "----Welcome to $(hostname)----"
        echo "    <<< Last 3 Users: >>>     "
        last -3  
        echo "------------------------------"
        echo " "

#
# SSH check - if client is not running ssh - ADMONISH THEM
#
if [ -z "$SSH_CLIENT" ]
then
echo -e "\033[1;34m(\033[1;30mYour session is INSECURE! PLEASE use ssh\033[1;34m)"
else
        NON_SSH_CLIENT=TRUE
fi

#
# quota checks - limit and usage
# these are used with the following crontab entry:
#
# 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/sbin/repquota -v /export/home > /etc/drgchk 
#
# basically this does a report quota on /export/home and outputs it to /etc/drgchk
# (which is world readable) so that users logging in can get information from it
# 
# which of course all happens in the following two almighty cat/grep/awk lines.
#

quota=$( cat /etc/drgchk |grep -n "$USER " |grep ":$USER " | awk '{ print $4/1000 }')
space=$( cat /etc/drgchk |grep -n "$USER " |grep ":$USER " | awk '{ print $3/1000 }')

echo -e "\033[1;34mQuota Limit: \033[1;30m$quota MB"
echo -e "\033[1;34mQuota Usage: \033[1;30m$space MB"
echo -e "\033[1;0m"

/bin/mail -E
case $? in
        0)
        echo -e "\033[1;34mYou have new mail."
        echo -e "\033[1;0m"
        ;;
        2)
        echo -e "\033[1;34mYou have mail."
        echo -e "\033[1;0m"
        ;;
esac


else
echo "
WELCOME TO THE UNIX LAB

You are logged into a lab computer.
This computer is an `uname -m` machine.
turnin, retrieve, check and submit will not work here.
please log into ultraminos using ssh: ssh ultraminos 
in order to use these utilities.

Please log off this system when you are finished.

DO NOT TURN THE SYSTEM OR MONITOR OFF!
These systems have power management.

"
        
fi



#
# set default umask 027 - world NOT READABLE! (just because)
#
#umask 027
umask 022
trap  2 3



2003-08-28