#!/bin/bash 
#==============================================================
#
#  Abs:  Script to setup Clear (unset) Environment
#
#  Name: UENVS.bash  (Development System)
#
#  Rem: Set path to default and clear environment variables
#       for a clean slate.
#
#  Usage: 
#
#  Facility: SLAC
#
#  Auth: 04-Apr-2013, K. Luchini       (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name  (USERNAME)
#--------------------------------------------------------------
#
#  Mod: (lastest to oldest)
#        21-Jun-2017, K. Luchini       (LUCHINI):
#          add FACILITY_ROOT and FACILITY_DATA
#
#==============================================================
#
# Set a default path
#export PATH="/bin:/usr/bin:/usr/etc:/usr/afsws/bin:/usr/afsws/etc:/usr/local/bin:/usr/bin/X11:."
#export LD_LIBRARY_PATH="/usr/X11R6/lib"

# First clear and set PATH and MANPATH using SCS's environ script.
# HEPiX environment is not supported!
if [ ! -z "$HEP_ENV" ];                 then  unset HEP_ENV; fi
if [ ! -z "$ENV" ];                     then  unset ENV; fi
if [ ! -z "$ENVIRONMENT" ];             then  unset ENVIRONMENT; fi
if [ ! -z "$ETC" ];                     then  unset ETC; fi
if [ ! -z "$CLUSTER_DIR" ];             then  unset CLUSTER; fi
if [ ! -z "$FACILITY_ROOT" ];           then  unset FACILITY_ROOT; fi 
if [ ! -z "$FACILITY_DATA" ];           then  unset FACILITY_DATA; fi 

# Unset test-facility production environment variables
if [ ! -z "$ACCTEST_ROOT" ];            then  unset ACCTEST_ROOT; fi       
if [ ! -z "$ACCTEST_DATA" ];            then  unset ACCTEST_DATA; fi 
if [ ! -z "$ACCTEST_WWW" ];             then  unset ACCTEST_WWW; fi 

# Unset lcls development environment variables
if [ ! -z "$LCLS_ROOT" ];               then  unset LCLS_ROOT; fi
if [ ! -z "$LCLS_DATA" ];               then  unset LCLS_DATA; fi
if [ ! -z "$LCLS_WWW" ];                then  unset LCLS_WWW; fi
if [ ! -z "$TOOLS" ];                   then  unset TOOLS; fi
if [ ! -z "$TOOLS_DATA" ];              then  unset TOOLS_DATA; fi
if [ ! -z "$PACKAGE_TOP" ];             then  unset PACKAGE_TOP; fi
if [ ! -z "$IOC_DATA" ];                then  unset IOC_DATA; fi
if [ ! -z "$IOC_SCREEN" ];              then  unset IOC_SCREEN; fi
if [ ! -z "$IOC" ];                     then  unset IOC; fi
if [ ! -z "$APP" ];                     then  unset APP; fi
if [ ! -z "$ALARMHANDLER" ];            then  unset ALARMHANDLER; fi
if [ ! -z "$PHYSICS_DATA" ];            then  unset PHYSICS_DATA; fi
if [ ! -z "$PHYSDATA" ];                then  unset PHYSDATA; fi
if [ ! -z "$PHYSICS_TOP" ];             then  unset PHYSICS_TOP; fi

# Unset EPICS specific environment variables 
if [ ! -z "$EPICS_IOCS" ];              then unset EPICS_IOCS; fi
if [ ! -z "$EPICS_SETUP" ];             then unset EPICS_SETUP; fi
if [ ! -z "$EPICS" ];                   then unset EPICS; fi;
if [ ! -z "$EPICS_BASE_RELEASE" ];      then unset EPICS_BASE_RELEASE; fi
if [ ! -z "$EPICS_TOP" ];               then unset EPICS_TOP; fi
if [ ! -z "$EPICS_BASE_TOP" ];          then unset EPICS_BASE_TOP; fi
if [ ! -z "$EPICS_EXTENSIONS" ];        then unset EPICS_EXTENSIONS; fi
if [ ! -z "$EPICS_MODULES_TOP" ];       then unset EPICS_MODULES_TOP; fi
if [ ! -z "$EPICS_IOC_TOP" ];           then unset EPICS_IOC_TOP; fi

if [ ! -z "$EPICS_DISPLAY_PATH" ];      then unset EPICS_DISPLAY_PATH; fi
if [ ! -z "$EPICS_PR_LIST" ];           then unset EPICS_PR_LIST; fi
if [ ! -z "$EPICS_CA_ADDR_LIST" ];      then unset EPICS_CA_ADDR_LIST; fi
if [ ! -z "$EPICS_WWW" ];               then unset EPICS_WWW; fi
if [ ! -z "$EPICS_DATA" ];              then unset EPICS_DATA; fi
if [ ! -z "$EPICS_HOST_ARCH" ];         then unset EPICS_HOST_ARCH; fi

if [ ! -z "$EPICS_VER" ];               then unset EPICS_VER; fi
if [ ! -z "$EPICS_BASE_VER" ];          then unset EPICS_BASE_VER; fi
if [ ! -z "$EPICS_EXTENSIONS_VER" ];    then unset EPICS_EXTENSIONS_VER; fi
if [ ! -z "$EPICS_MODULES_VER" ];       then unset EPICS_MODULES_VER; fi
if [ ! -z "$EPICS_IOC_VER" ];           then unset EPICS_IOC_VER; fi

# Unset EDM enviroment variables
if [ ! -z "$EDM" ];                     then  unset EDM; fi
if [ ! -z "$EDMACTIONS" ];              then  unset EDMACTIONS; fi
if [ ! -z "$EDMDATAFILES" ];            then  unset EDMDATAFILES; fi
if [ ! -z "$EDMDUMPFILES" ];            then  unset EDMDUMPFILES; fi
if [ ! -z "$EDMFILES" ];                then  unset EDMFILES; fi
if [ ! -z "$EDMFILTERS" ];              then  unset EDMFILTERS; fi
if [ ! -z "$EDMHELPFILES" ];            then  unset EDMHELPFILES; fi
if [ ! -z "$EDMOBJECTS" ];              then  unset EDMOBJECTS; fi
if [ ! -z "$EDMPVOBJECTS" ];            then  unset EDMPVOBJECTS; fi
if [ ! -z "$EDMUSERLIB" ];              then  unset EDMUSERLIB; fi
if [ ! -z "$EDMUSERS" ];                then  unset EDMUSERS; fi
if [ ! -z "$EDMWEBBROWSER" ];           then  unset EDMWEBBROWSER; fi
if [ ! -z "$EDM_DATA" ];                then  unset EDM_DATA; fi

# Unset Archiver environment variables
if [ ! -z "$ARCHCONFIGFILES" ];         then  unset ARCHCONFIGFILES; fi
if [ ! -z "$ARCHDATAFILES" ];           then  unset ARCHDATAFILES; fi
if [ ! -z "$ARCHNAME" ];                then  unset ARCHNAME; fi

# Unset other paths
if [ ! -z "$CLASSPATH" ];               then  unset CLASSPATH;  fi
if [ ! -z "$PYTHONPATH" ];              then  unset PYTHONPATH; fi
if [ ! -z "$MATLABPATH" ];              then  unset MATLABPATH; fi
if [ ! -z "$XFILESARCHPATH" ];          then  unset XFILESARCHPATH; fi
if [ ! -z "$STRIP_FILE_SEARCH_PATH" ];  then  unset STRIP_FILE_SERACH_PATH; fi

# Unset Aida 
if [ ! -z "$AIDA" ];                    then  unset AIDA; fi
if [ ! -z "$AIDA_MODE" ];               then  unset AIDA_MODE; fi
if [ ! -z "$AIDA_NAMESERVER_IOR_URL" ]; then  unset AIDA_NAMESERVER_IOR_URL; fi

# Unset CVS envirnoment variables
if [ ! -z "CVSROOT" ];                  then unset CVSROOT; fi
if [ ! -z "CVSIGNORE" ];                then unset CVSIGNORE; fi

# Unset third-party home direcorties and versions
if [ ! -z "$LIB1600" ];                 then  unset LIB1600; fi
if [ ! -z "$IFILE" ];                   then  unset IFILE; fi
if [ ! -z "$JAVA" ];                    then  unset JAVA; fi
if [ ! -z "$PYTHON" ];                  then  unset PYTHON; fi
if [ ! -z "$TCL" ];                     then  unset TCL; fi
if [ ! -z "$IMRDBDIR" ];                then  unset IMRDBDIR; fi
if [ ! -z "$CDEVTAGTABLE" ];            then  unset CDEVTAGTABLE; fi

if [ ! -z "$ORBACUS" ];                 then  unset ORBACUS; fi
if [ ! -z "$ORACLE_HOME" ];             then  unset ORACLE_HOME; fi
if [ ! -z "$OCTAVE_HOME" ];             then  unset OCTAVE_HOME; fi
if [ ! -z "$XLA_HOME" ];                then  unset XLA_HOME; fi

if [ ! -z "$MATLAB" ];                  then  unset MATLAB; fi
if [ ! -z "$MATLAB_ROOT" ];             then  unset MATLAB_ROOT; fi
if [ ! -z "$MATLABDATAFILES" ];         then  unset MATLABDATAFILES; fi
if [ ! -z "$LM_LICENSE_FILE" ];         then  unset LM_LICENSE_FILE; fi

if [ ! -z "$CMLOG" ];                   then  unset CMLOG; fi
if [ ! -z "$CMLOG_HOST_ARCH" ];         then  unset CMLOG_HOST_ARCH; fi
if [ ! -z "$CMLOG_PORT" ];              then  unset CMLOG_PORT; fi
if [ ! -z "$CMLOG_CONFIG" ];             then  unset CMLOG_CONFIG; fi
if [ ! -z "$STRIP_CONFIGFILES_DIR" ];   then  unset STRIP_CONFIGFILE_DIR; fi
if [ ! -z "$STRIPCONFIGFILES" ];        then  unset STRIPCONFIGFILES; fi

if [ ! -z "$JAVAVER" ];                 then  unset JAVAVER; fi
if [ ! -z "$PYTHON_VER" ];              then  unset PYTHON_VER; fi
if [ ! -z "$ORACLE_VER" ];              then  unset ORACLE_VER; fi
if [ ! -z "$MATLAB_VER" ];              then  unset MATLAB_VER; fi

# Unset other SLAC group or machine specific environment variabls 
if [ ! -z "$SPEAR_PRODUCTION" ];        then unset SPEAR_PRODUCTION; fi

hash -r
# End of script

