#!/bin/bash
#==============================================================
#  Name:  lclshome
#
#  Rem:   This script launches camac_1718_status, which is 
#         a status display for MCC.
#         This file copied from lclshome script.
# 
#  Usage: lclshome
#
#  Auth:  04-Sep-2009, Sonya Hoobler   (sonya
#  Rev:   dd-mmm-yyyy,  Whoever    (user):
#--------------------------------------------------------------

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}/misc/camac_1718_status.edl ] ; then
    echo "ERROR: cannot find camac_1718_status.edl"
    exit 1
fi 

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

${cmdpath} -eolc ${mode} camac_1718_status

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

exit 0

