#==============================================================
#
#  Abs:  Common startup script for Linux IOCs
#
#  Name: st.cmd
#
#  Rem:  Upon entry we expect to be at location TOP
#        and the following macros must be defined.
#        Note that all other environment variables 
#        used within this file are defined in envPaths.
#
#           EPICS_IOCS - Top level boot dir for all iocs
#           IOC_NAME   - IOC Device name   (ie. SIOC:SYS0:FB00)
#           LOCATION   - Rack location
#           FACILITY   - Machine facility  (ie. lcls,testfac,facet)
#           ACF_INIT   - Access Control File with path  
#
#         Upon exit, this script will leave the ioc sitting
#         at the application TOP directory.
#
#         WARNING!!!
#         The TOP environment variable is defined in
#         envPaths, however in development (afs), the 
#         definitionmay include "slac.stanford.edu", which is
#         not understood by linuxRT. However, when "cram" is used
#         to release to production,"slac" is substituted for
#         "slac.stanford.edu", which fixes the problem.  
#
#  Facility: SLAC Feedback Support Controls
#
#  Auth: 31-Aug-2007, Diane Fairley   (DFAIRLEY)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        04-May-2023, K. Luchini      (LUCHINI):
#          extract from st.cmd files
#          load CA security file         
#
#==============================================================
#
# Set environment variables
< envPaths

# Get current iocBoot directory path so we can return easily
epicsEnvSet("IOC_BOOT" ,"${EPICS_IOC_APP}")

# iocAdmin environment variables
# the environment variable LOCATION must
# be defined upon entry.
epicsEnvSet("ENGINEER" ,"Jeremy Mock")
epicsEnvSet("STARTUP"  ,"${EPICS_IOCS}/${IOC}")
epicsEnvSet("ST_CMD"   ,"startup.cmd")

# Define subsystem, used by iocLogPrefix
epicsEnvSet("SUBSYS","fbck"))

#==============================================================
# Load standard databases
#==============================================================
#
cd ${TOP}

# Load EPICS Database
dbLoadDatabase("dbd/fbckSupport.dbd")
fbckSupport_registerRecordDeviceDriver(pdbbase)

# Load database to support IOC Health and monitoring
dbLoadRecords("db/iocAdminSoft.db"   ,"IOC=${IOC_NAME}")
dbLoadRecords("db/iocAdminScanMon.db","IOC=${IOC_NAME}")

# The following database is a result of a python parser
# which looks at RELEASE_SITE and RELEASE to discover
# versions of software your IOC is referencing
# The python parser is part of iocAdmin
dbLoadRecords("db/iocRelease.db","IOC=${IOC_NAME}")

# Load sequence admin
dbLoadRecords("db/devSeqCar.db","SIOC=${IOC_NAME}")

#==============================================================
# Update archive pv list in the data area
#==============================================================
system("cp archive/${IOC}.arConfig  ${IOC_DATA}/${IOC}/archive/${IOC}.archive")

#==============================================================
#  Load Channe Access Security if configuration file exists
#==============================================================
< ${ACF_INIT}

#==============================================================
# Start IOC Log Client
#==============================================================
< ${LOG_INIT}

# End of script






