# /etc/profile #set -x # # /etc/profile for sunos, solaris, hpux, linux, and irix. # # The purpose of this expanded /etc/profile is to provide sh, ksh and bash # users (root status or otherwise) with a consistent and predictable env # across ALL Unix systems (Solaris, SunOS, hpux, linux, irix, etc). # # /etc/profile is called by the system upon user login, and (optionally) by # a user's own profile if needed. # # Most of the code is just assignments of various sorts. The parts # that actually "do something" will only run for an interactive shell. # ------------------------------------------------------------------------- # # External variables: # # Variables LOGNAME and USER are both already set. LOGNAME is apparently # set by the login program, and "sh" and its derivatives set USER. Both are # always = original login name (ie: su has no effect on them.) # ------------------------------------------------------------------------- # # Variables set in here and used in here and/or in other more local profiles: # # ETC_PROFILE_DONE = "true" if /etc/profile is processed, else undefined. # # INTERACTIVE = "y" if this process is attached to a terminal, else "n". # # OSN = full OS release string (eg: SunOS.5.5.1) # # OSV = simple OS name (eg: "solaris", "sunos", "linux", "irix", "hpux", etc) # # HISTSIZE, HISTFILESIZE = number of lines for ksh, bash cmnd history # # ARCH = machine architecture (eg: sun4m, IP30, etc) # # Last modification (latest at top): # 20/11/98 (for linux on tpm1) + general tidyup # # INTERACTIVE and ETC_PROFILE_DONE may be tested in other profiles later: echo "/etc/profile:" # **************************************************************************** # # Set OSN (OS name), OSV (simplified name), and TB (name of any bin dir # with unported binaries from an older OS version which is known to exist.) # TB may then be added at THE END of a users path so that the latest package # is run by default, but if no port yet, an old version will run if avail. # # **************************************************************************** OSN=`uname -a | tr -s ' ' ' ' | cut -d ' ' -f1,3 | tr ' ' '.'` # Set OSV, and TB = any local subsidiary binaries: case $OSN in SunOS.4*) OSV=sunos TB= ;; SunOS.5*) OSV=solaris TB=/usr/local/bin.sunos ;; IRIX*) OSV=irix TB= ;; HP-UX*) OSV=hpux TB= ;; Linux*) OSV=linux TB= ;; *) OSV=unknown TB= ;; esac export OSN OSV TB # **************************************************************************** # # The rest is skipped for non-interactive shells, ie: for sub-shells which # are only spawned to run commands but which may nevertheless exec this. # # **************************************************************************** if tty -s # (silent test for stdin being a terminal) then INTERACTIVE=y ETC_PROFILE_DONE=true # ****************************************************************** # # Set USER (effective user name), UID if required, and umask. # Also need to define IDCMD, which is that 'id' command for each # unix which operates in a common manner. (The default Solaris # 'id' command is different to everyone elses, but they have a more # obscure one which is okay.) # # ****************************************************************** IDCMD=id #Default one if [ $OSV = solaris ] then IDCMD=/usr/xpg4/bin/id fi USER=`$IDCMD -un` # Most unix's set UID, so only set here if somehow empty: if [ -z "$UID" ] then UID=`$IDCMD -u` fi # Set a rough, default umask. # 775 (002) for users with UID , and 755 (022) UID if [ `$IDCMD -gn` = `$IDCMD -un` -a `$IDCMD -u` -gt 14 ]; then umask 002 else umask 022 fi export USER UID IDCMD # ****************************************************************** # # For use of ksh or bash, set HISTSIZE and HISTFILESIZE. # These have no effect on sh. # # ****************************************************************** HISTSIZE=1000 HISTFILESIZE=1000 export HISTSIZE HISTFILESIZE # -------------------------------------------------------------------- # # Set ARCH = the kernel architecture # # -------------------------------------------------------------------- ARCH=`uname -m|sed 's/\//_/'` # kernel architecture (eg: sun4m) export ARCH # -------------------------------------------------------------------- # # Set COMD = the dir containg the common user profile file that # contains aliases, functions, etc: # # -------------------------------------------------------------------- COMD=/usr/local/etc export COMD # -------------------------------------------------------------------- # # Set a default PATH - this one is both user-level and OS dependent # NOTE - the superuser "root" should not add "dot" at the start of # the PATH. # # -------------------------------------------------------------------- PATH="" # -------------------------------------------------------------------- # # Define function "add_path" for adding onto the end of PATH # # -------------------------------------------------------------------- add_path() { if [ -z "$PATH" ] then PATH="$1" else if [ -n "$1" ] then PATH="$PATH:$1" fi fi } # -------------------------------------------------------------------- # Symbolically define any pathnames which tend to be different between # architectures: # -------------------------------------------------------------------- # X-stuff path(s): case $OSV in solaris) XP=/usr/openwin/bin:/usr/openwin/demo;; sunos | irix | hpux | linux) XP=/usr/bin/X11;; esac export XP # For root, contrib/bin must be later, and don't bother with $HOME/bin: if [ $UID -ne 0 ] then add_path /usr/contrib/bin add_path ${HOME}/bin fi add_path /usr/local/bin add_path /usr/local/etc add_path /usr/hosts # Main system binaries, with SVSV binaries before BSD add_path /bin add_path /usr/bin # BSD add_path /usr/sbin add_path /etc case $OSV in solaris | sunos) add_path /opt/gnu/bin add_path /usr/ucb add_path /usr/ccs/bin add_path /usr/5bin # SYSV ;; irix) add_path /usr/bsd add_path /usr/etc add_path /sbin ;; linux) add_path /sbin add_path /usr/local/sbin add_path /usr/X11R6/bin add_path /opt/kde/bin ;; sunos) add_path /usr/etc add_path /usr/5bin # SYSV ;; hpux) add_path /bin/posix add_path /usr/5bin # SYSV ;; esac # X stuff (may include Openwindows, etc): add_path $XP # SPARCworks compliler set and "cross" local/bin stuff: if [ $OSV = solaris ] then add_path /opt/SUNWspro/SC3.0.1/bin add_path /usr/ccs/bin add_path /usr/games add_path /usr/local/games add_path /usr/demo/SOUND add_path $TB fi # # GNU and PD utilities: # # UPT=/usr/local/unix_power_tools # add_path "$UPT/bin:$UPT/share/bin" #--------------- GLOBALS ----------------- # # Make all variabes global in this section # set -a # # Standard MAN places # case $OSV in solaris) MAIL=/var/mail/$LOGNAME XP=/usr/openwin/bin:/usr/openwin/demo MANPATH=/usr/local/man:/usr/share/man:/opt/hpnp/man # SPARCtools MAN places. The install book says they must go # before the "normal" entries. Not all are mentioned in the # book: SW=/opt/SUNWspro if [ -d /opt/SUNWspro ] then MANPATH=$SW/SC3.0.1/man:$SW/SPROutool/man:$SW/FileMerge/man:$SW/SW3.0.1/man:$SW/swmgr/man:$SW/FSF/sbtags/man:$MANPATH fi # SPARCtools license file. Leaving it to the default (which # should be the same anyway) gave me troubles. Set it # explicitly. See install book, p102 # LM_LICENSE_FILE=/opt/SUNWspro/license_dir/sunpro.lic,1 # CDE (Common Desktop Env): if [ -d /opt/dt ] then MANPATH=/opt/dt/man:$MANPATH fi # SPARCtools require an entry prior to $OPENWINHOME in the # variable LD_LIBRARY_PATH. # See Sparcworks/SparcCompiler install manual, p26 LD_LIBRARY_PATH="/opt/SUNWspro/SC3.0.1/lib:/usr/lib:/etc/" # Openwindows specific settings # # LD_LIBRARY_PATH is used by ld(1) for dynamic linking # MANPATH adds the OPENWINDOWS man entries # OPENWINHOME=/usr/openwin LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$OPENWINHOME/lib" MANPATH="$MANPATH:$OPENWINHOME/man" MANPATH="$MANPATH:/usr/demo/SOUND" ;; irix) MAIL=/usr/mail/$LOGNAME # Set TZ correctly for either the old or the new extended . /etc/TIMEZONE MSGVERB=text:action NOMSGLABEL=1 NOMSGSEVERITY=1 export MAIL MSGVERB NOMSGLABEL NOMSGSEVERITY MANPATH=/usr/share/catman/a_man:/usr/share/catman/g_man:/usr/share/catman/local:/usr/share/catman/p_man:/usr/share/catman/u_man:/usr/catman/local:/usr/share/catman:/usr/man:/usr/local/man REMOTEHOST=`uname -a | tr -s ' ' ' ' | cut -d ' ' -f2` # LM_LICENSE_FILE="/var/flexlm/license.dat" ;; sunos) MAIL=/var/spool/mail/$LOGNAME MANPATH=/usr/local/man:/usr/share/man:/usr/lang/man ;; hpux) MAIL=/usr/mail/$LOGNAME MANPATH=/usr/man:/usr/local/man ;; linux) MAIL=/var/spool/mail/$LOGNAME MANPATH=/usr/man:/usr/X11R6/man:/usr/local/man ;; esac if [ -d $UPT ] then MANPATH="$MANPATH:$UPT/share/man" fi #--------------- MISC ----------------- # # Misc machine related settings # XPATH="$PATH" # if you lose it, this is a backup copy OPSYS=`uname -s` MAILCHECK=600 # # Set editor related variables. A user may want to reset these # VISUAL=vi EDITOR=vi # end GLOBAL section HOSTNAME=`hostname | cut -d '.' -f1` MOTD=/usr/local/etc/motd.$HOSTNAME export HOSTNAME # # Set the Timezone variable TZ # case $OSV in solaris | sunos) STTY=/usr/5bin/stty TZ=Australia/Victoria ;; irix) STTY=/bin/stty ;; linux) STTY=/bin/stty TZ=Australia/Victoria ;; hpux) STTY=/bin/stty if [ -r /etc/src.sh ] then . /etc/src.sh # set the timezone unset SYSTEM_NAME else TZ=MST7MDT # change this for local time. export TZ fi # Ah well, quick and dirty - sneak in some more bit's for HP: trap "echo logout" 0 trap 1 2 3 # leave defaults in user environment. RTAPROOT=/usr/rtap; export RTAPROOT ;; *) STTY=/usr/5bin/stty TZ=Australia/Victoria ;; esac #------------------ TTY settings --------------- $STTY intr '^C' erase '^h' >/dev/null 2>&1 # Try to identify where the login is coming from: LINE=`who am i|cut -s -d '(' -f2|sed -e s'/ *//' -e s'/[.)].*$//'` #if [ -z "$LINE" ]; then LINE=$HOSTNAME; fi case $LINE in *[a-z]*) ;; *) LINE=$HOSTNAME ;; esac MSG=" Welcome, $LOGNAME. I assume you're on an ascii terminal at the moment, so I've set up your TERM environment as a 24 line vt100. " case $LINE in ss5*|octane*|o2*|gateway*|cdr*|mineng*|rat*|gateway*|tpm*) TERM=xterm; $STTY rows 40 > /dev/null 2>&1 LESS="-qcP\"line\ %lb\ of\ %L\"" ;; jxa1) if [ "$TERM" = "" ] # if term is not set, then # TERM=hp # default the terminal type fi ;; *) TERM=vt100; $STTY rows 24 LESS="-qch0P\"line\ %lb\ of\ %L\"" echo $MSG ;; esac PAGER=less export LESS PAGER # Any truly local paths must go last if root: if [ $UID -eq 0 ] then add_path /usr/contrib/bin fi set +a # #--------------- END GLOBALS ----------------- # # The following section is only executed for the first login for the day # from any particular machine. # if daily -f $HOME/.motd-${HOSTNAME}-${LINE} then if [ -r "$MOTD" -a $USER != root ] then cat $MOTD # # Simple check for any mail # # NB: This needs checking - doesn't work on Linux # if mail -e # then # echo "You have mail" # fi fi fi else INTERACTIVE=n fi #///////////////////////////////////////////////////////////////// # #echo end of /etc/profile