#!/bin/bash
#==============================================================
#  Name:  lclshome
#
#  Rem:   This script launches lcls_main_1718dev, which is 
#         lclshome but with NEH1, FEH1 replaced with LI17,LI18.
#         This file copied from lclshome script.
# 
#  Usage: lclshome
#
#  Auth:  03-Sep-2009, Sonya Hoobler  (sonya)
#  Rev:   04-Sep-2009, Sonya Hoobler  (sonya):
#                      Add ioc-li17-cv01, ioc-li18-cv01, lcls-dev2 
#                      to CA ADDR_LIST
#--------------------------------------------------------------

export EPICS_CA_ADDR_LIST="ioc-li17-cv01:5066 ioc-li18-cv01:5066 lcls-dev2:5066"

CMD="edm"
ACCLIST="laci physics acclegr eoicdesk linac mccops1 lclsops1 lclsops2 lclsops3 lclsops4 lclsops5"

if [ `uname -s` != "Linux" ] ; then
    echo "Please run $0 on a public Linux machine"
    exit 1
fi

if [ -z "${EDM}" ] ; then
#    . /usr/local/lcls/epics/setup/epicsReset.bash
    . ~/.bashrc
fi

cmdpath=`which ${CMD}`
if [ ! -x "${cmdpath}" ] ; then
    echo "ERROR: cannot find ${CMD}"
    exit 1
fi

if [ ! -f ${EDM}/lcls/lcls_main_1718dev.edl ] ; then
    echo "ERROR: cannot find lcls_main_1718dev.edl"
    exit 1
fi 

USER=`whoami` 
INLIST=`echo ${ACCLIST} | grep ${USER}`
mode="-x"
if [ -n "${INLIST}" ]; then  
    mode="-x -noedit"
fi

${cmdpath} -eolc ${mode} lcls_main_1718dev

if [ $? -ne 0 ]; then
    echo "ERROR: $0 failed" 
    exit 1
fi

exit 0

