#!/bin/bash
#==============================================================
# luKlystronSupportRestart
#
# ARGUMENTS:
#
# OPTION:     
#
# Facility:  SLAC/LCLS
#
# Restart the Linac Upgrade Klystron Support soft ioc
#
# Usage: luKlystronSupportRestart <location>
#
# Arguments: 
#            loca: ioc location name, for example li28
#            $2: mode, 0 if going to SLC Mode, non-zero if going to EPICS mode
# 
#----------------------------------------------------------------------------
# Mod:
#        
#==============================================================

LOCA=`echo $1 | tr '[:lower:]' '[:upper:]'`

echo ${LOCA}
echo $2

if [ $2 = 0 ]; then

    if [ "${LOCA}" = "LI20" ]; then
	perl -pi -e 's/^IOC-LI20-CV01/#IOC-LI20-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI21" ]; then
	perl -pi -e 's/^IOC-LI21-CV01/#IOC-LI21-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI22" ]; then
	perl -pi -e 's/^IOC-LI22-CV01/#IOC-LI22-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI23" ]; then
	perl -pi -e 's/^IOC-LI23-CV01/#IOC-LI23-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI24" ]; then
	perl -pi -e 's/^IOC-LI24-CV01/#IOC-LI24-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI25" ]; then
	perl -pi -e 's/^IOC-LI25-CV01/#IOC-LI25-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI26" ]; then
	perl -pi -e 's/^IOC-LI26-CV01/#IOC-LI26-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI27" ]; then
	perl -pi -e 's/^IOC-LI27-CV01/#IOC-LI27-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI28" ]; then
	perl -pi -e 's/^IOC-LI28-CV01/#IOC-LI28-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI29" ]; then
	perl -pi -e 's/^IOC-LI29-CV01/#IOC-LI29-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI30" ]; then
	perl -pi -e 's/^IOC-LI30-CV01/#IOC-LI30-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi

else

    if [ "${LOCA}" = "LI20" ]; then
	perl -pi -e 's/^#IOC-LI20-CV01/IOC-LI20-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI21" ]; then
	perl -pi -e 's/^#IOC-LI21-CV01/IOC-LI21-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI22" ]; then
	perl -pi -e 's/^#IOC-LI22-CV01/IOC-LI22-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI23" ]; then
	perl -pi -e 's/^#IOC-LI23-CV01/IOC-LI23-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI24" ]; then
	perl -pi -e 's/^#IOC-LI24-CV01/IOC-LI24-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI25" ]; then
	perl -pi -e 's/^#IOC-LI25-CV01/IOC-LI25-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI26" ]; then
	perl -pi -e 's/^#IOC-LI26-CV01/IOC-LI26-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI27" ]; then
	perl -pi -e 's/^#IOC-LI27-CV01/IOC-LI27-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI28" ]; then
	perl -pi -e 's/^#IOC-LI28-CV01/IOC-LI28-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI29" ]; then
	perl -pi -e 's/^#IOC-LI29-CV01/IOC-LI29-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
    if [ "${LOCA}" = "LI30" ]; then
	perl -pi -e 's/^#IOC-LI30-CV01/IOC-LI30-CV01/' $TOOLS/ChannelWatcher/config/Master.CV
    fi
fi

ssh laci@lcls-daemon2 /etc/init.d/st.cwCV restart

exit 0

