I have a complex structured profile - with a load of scripts being used. The main issue is boot-strapping the system across all the different environments where it is used - Solaris, Linux (misc h/w), HP-UX, AIX...
I use Korn shell - but the principles apply to bash (and it works fine with bash):
#!/bin/ksh
#
# @(#)$Id: profile,v 6.8 2007/09/24 18:20:26 jleffler Exp $
#
# Generic profile for Jonathan Leffler (JL)
#
# Copyright (C) JLSS 1989-93,1995-99,2002,2005,2007
#TABSTOP=4
# Set machine-specific environment
mc=`uname -n`
if [ -r $HOME/.$mc ]
then
. $HOME/.$mc
fi
unset mc
# Set basic environment
: ${INFORMIXDIR:=/usr/informix} ; export INFORMIXDIR
: ${REAL_HOME:=$HOME} ; export REAL_HOME
# Machine-configurable PATH setting
for mcsetpath in ${REAL_HOME}/bin/mcsetpath ${HOME}/bin/mcsetpath
do
if [ -r $mcsetpath ]
then
. $mcsetpath # Set PATH
break;
fi
done
unset mcsetpath
. libpath # Set LD_LIBRARY_PATH
. ttyset # Set STTY values
. kshrc # Set KSH environment
. cdpath # Set CDPATH
. exinit # Set EXINIT
. termset # Set TERM type
. ixenviron # Set INFORMIX environment
. ccenviron # Set ClearCase environment
. setprompt # Set prompt
. manpath # Set MANPATH
umask 022
# Set group-specific environment
group=`id | sed 's/.* gid=[0-9]*(\([^)]*\)).*/\1/'`
if [ -f "$REAL_HOME/.$group" ]
then
. $REAL_HOME/.$group
fi
# Set user-specific environment -- assume LOGNAME or USER set OK
# Beware Linux: by default, username = group name so things get done twice!
: ${LOGNAME:=${USER:-jleffler}}
export LOGNAME
if [ "$group" != "$LOGNAME" ] && [ -f "$REAL_HOME/.$LOGNAME" ]
then
. $REAL_HOME/.$LOGNAME
else
cd
case "$-" in
*c*) : OK;;
*) echo "User $LOGNAME logged in to `pwd` at `date`";;
esac
trap "clear; exit 0" 0
fi
unset group