TEST_CHANNEL="EIB:running"
#
#7.5.2026  caget will crash  here when  LD_LIBRARY_PATH=/ioc/EIB/lib64 
#

unset LD_LIBRARY_PATH 

# for diagnostics: to see whether caget works.

# caget

# Now proceed

if caget $TEST_CHANNEL &> /dev/null
  then
     echo "!!! channel $TEST_CHANNEL is already available on an ioc !!!"
     echo "=> Do not start softIOC"
  else
     export EPICS_HOST_ARCH=linux-x86_64

#     6.5.2026: cannot bei in st.cmd becaus loading of eib is in the first line
#     5.5.2026: this is now included in st.cmd     
     export LD_LIBRARY_PATH=/ioc/EIB/lib64   

     echo "channel $TEST_CHANNEL is not yet available"
     echo "=> Ok to start softIOC"
     
     cd  /ioc/EIB/iocBoot/ioceib
     /ioc/EIB/iocBoot/ioceib/st.cmd
     
     echo "close this window in 1 s"
     sleep 1
     exit
fi

#echo "!!! Do not start a new ioc"
#read

echo
echo "wait 5 s before terminating this window"
sleep 5
