#!/bin/bash -e # # Install one system if [ "$#" -ne 2 ];then echo "Please specify the name of the system to install and the source code directory." >&2 exit 1 else system=$1 srcdir=$2 fi if ! test -e target/${system}epics/${system}epics; then echo "Please make $system first." >&2 exit 1 fi site="${SITE}" ifo="${IFO}" if [ -z "$site" ] || [ -z "$ifo" ] ; then echo "Could not determine site or ifo." >&2 exit 1 fi site=${site^^*} ifo=${ifo^^*} site_letter=${ifo:0:1} upper_system=`echo $system | tr a-z A-Z` targetcpu=`grep TARGET_CPU src/include/${system}.h | head -1 | awk '{print $3}'` cur_date=`date +%y%m%d_%H%M%S` RTCDS=/opt/rtcds/${site,,*}/${ifo,,*} TARGET=$RTCDS/target/${system} ARCHIVE=$RTCDS/target_archive/${system}/${system}_$cur_date echo "Installing system=$system site=$site ifo=$ifo" mkdir -p $TARGET ########## echo "Installing channel file..." mkdir -p $RTCDS/chans/filter_archive/$system chmod 775 $RTCDS/chans/filter_archive/$system if test -e $RTCDS/chans/${upper_system}.txt; then cp $RTCDS/chans/${upper_system}.txt $RTCDS/chans/filter_archive/$system/${upper_system}_${cur_date}_install.txt || exit 1 head -4 build/${system}epics/config/${ifo}${upper_system}.txt > $RTCDS/chans/${upper_system}.txt grep '^# MODULES' build/${system}epics/config/${ifo}${upper_system}.txt >> $RTCDS/chans/${upper_system}.txt tail -n +5 $RTCDS/chans/filter_archive/$system/${upper_system}_${cur_date}_install.txt | grep -v '^# MODULES' >> $RTCDS/chans/${upper_system}.txt else cp -p build/${system}epics/config/${ifo}${upper_system}.txt $RTCDS/chans/${upper_system}.txt fi ########## echo "Installing EPICS sequencer..." if test -e $TARGET; then mkdir -p $RTCDS/target_archive/${system} mv -f $TARGET $RTCDS/target_archive/${system}/${system}_$cur_date || exit 2 fi mkdir -p $TARGET/{bin,scripts,logs} chmod 775 $TARGET/logs mkdir -p $RTCDS/chans/tmp chmod 775 $RTCDS/chans/tmp mkdir -p $TARGET/${system}epics/burt chmod 775 $TARGET/${system}epics/burt if [ -e $RTCDS/target_archive/${system}/${system}_$cur_date/${system}epics/burt ]; then cp -pr $RTCDS/target_archive/${system}/${system}_$cur_date/${system}epics/burt $TARGET/${system}epics fi cp -pr target/${system}epics $TARGET mv -f $TARGET/${system}epics/src $TARGET chmod -R a-w $TARGET/src if test -e $TARGET/${system}epics/db/*/autoBurt.req; then mv -f $TARGET/${system}epics/db/*/autoBurt.req $TARGET/${system}epics || exit 3 fi ########## echo "Installing EPICS screens..." if test -e $RTCDS/medm/${system}; then mkdir -p $RTCDS/medm/archive cp -a $RTCDS/medm/${system} $RTCDS/medm/archive/${system}_${cur_date} || exit 1 fi mkdir -p $RTCDS/medm/${system} (cd build/${system}epics/medm; find . -name "*.adl" | xargs -r cp --parents -r -t $RTCDS/medm/${system}) (cd build/${system}epics/medm; find . -name "*.ui" | xargs -r cp --parents -r -t $RTCDS/medm/${system}) ########## echo "Installing RT components..." if test -e $TARGET/bin/${system}.ko; then mv -f $TARGET/bin/${system}.ko $TARGET/archive/${system}fe_${cur_date}.ko || exit 4 fi if test -e src/fe/${system}/${system}.ko; then cp -fp src/fe/${system}/${system}.ko $TARGET/bin/ fi if test -e src/fe/${system}_usp/${system}; then cp -fp src/fe/${system}_usp/${system} $TARGET/bin/ fi if test -e $TARGET/bin/${system}; then echo 'taskset -c '$targetcpu $TARGET/bin/${system} '-m ' ${system} ' > '$TARGET/logs/log.txt ' 2>& 1 &' > $TARGET/scripts/startup${ifo}usp chmod +x $TARGET/scripts/startup${ifo}usp fi ########## gds_node=`grep rmid build/${system}epics/${system}.par | head -1 | sed 's/[^0-9]*\([0-9]*\)/\1/'` if [ x$gds_node != "x" ]; then echo "Installing GDS components..." datarate=`grep datarate build/${system}epics/${system}.par | head -1 | sed 's/[^0-9]*\([0-9]*\)/\1/'` targethost=`grep TARGET_HOST_NAME src/include/${system}.h | head -1 | awk '{print $3}'` if test ${datarate} -lt 16384; then datarate_mult=`expr ${datarate} / 2048` else datarate_mult=`expr ${datarate} / 16384 ` fi mkdir -p $RTCDS/target/gds/ edcu_name=`echo ${upper_system} | sed s/^${ifo}//g` edcu_name=${ifo}EDCU_${edcu_name} mkdir -p $RTCDS/target/gds/param/ mkdir -p $RTCDS/target/gds/param/archive ########## echo "Updating testpoint config file..." if [[ $gds_node -lt 256 ]] && test -e src/fe/${system}/${system}.ko; then if test -e $RTCDS/target/gds/param/testpoint.par; then mv -f $RTCDS/target/gds/param/testpoint.par $RTCDS/target/gds/param/archive/testpoint_${cur_date}.par || exit 1 testpoint_par_infname=$RTCDS/target/gds/param/archive/testpoint_${cur_date}.par else testpoint_par_infname=/dev/null fi ($srcdir/src/epics/util/updateTestpointPar.pl -par_file=${testpoint_par_infname} -gds_node=${gds_node} -site_letter=${site_letter} -system=${system} -host=${targethost} > $RTCDS/target/gds/param/testpoint.par || (cp $RTCDS/target/gds/param/archive/testpoint_${cur_date}.par $RTCDS/target/gds/param/testpoint.par && exit 1)) || exit 1 fi ########## echo "Installing GDS node config file..." if test -e $RTCDS/target/gds/param/tpchn_${system}.par; then mv -f $RTCDS/target/gds/param/tpchn_${system}.par $RTCDS/target/gds/param/archive/tpchn_${system}_${cur_date}.par || exit 1 fi cp -p build/${system}epics/${system}.par $RTCDS/target/gds/param/tpchn_${system}.par mkdir -p $TARGET/param cp -p build/${system}epics/${system}.par $TARGET/param/tpchn_${system}.par mkdir -p $RTCDS/chans/adc cp -p build/${system}epics/config/adcListSorted.txt $RTCDS/chans/adc/${system}_adclist.txt if test ${datarate_mult} -gt 1; then datarate_mult_flag=-${datarate_mult} else datarate_mult_flag= fi echo "Installing auto-generated DAQ config file..." mkdir -p $RTCDS/chans/daq mkdir -p $RTCDS/chans/daq/archive if test -e $RTCDS/chans/daq/${upper_system}.ini; then mv -f $RTCDS/chans/daq/${upper_system}.ini $RTCDS/chans/daq/archive/${upper_system}_${cur_date}.ini || exit 2 # # Do not update anything now, file is generated from the model #echo $srcdir/src/epics/util/updateDaqConfig1.pl -daq_old=$RTCDS/chans/daq/archive/${upper_system}_${cur_date}.ini -old=$RTCDS/target/gds/param/archive/tpchn_${system}.par -new=build/${system}epics/${system}.par -daq=build/${system}epics/${system}.ini # $srcdir/src/epics/util/updateDaqConfig1.pl -daq_old=$RTCDS/chans/daq/archive/${upper_system}_${cur_date}.ini -old=$RTCDS/target/gds/param/archive/tpchn_${system}_${cur_date}.par -new=build/${system}epics/${system}.par -daq=build/${system}epics/${system}.ini > $RTCDS/chans/daq/${upper_system}.ini #else # cp -p build/${system}epics/${system}.ini $RTCDS/chans/daq/${upper_system}.ini fi cp -p build/${system}epics/${system}.ini $RTCDS/chans/daq/${upper_system}.ini cp $RTCDS/chans/daq/${upper_system}.ini $TARGET/param/${upper_system}.ini #echo Installing EDCU ini file #if test -e $RTCDS/chans/daq/${edcu_name}.ini #then # mv -f $RTCDS/chans/daq/${edcu_name}.ini $RTCDS/chans/daq/archive/${edcu_name}_${cur_date}.ini || exit 2 #fi #cp -p target/${system}epics/db/${ifo}/auto.ini $RTCDS/chans/daq/${edcu_name}.ini #echo $RTCDS/chans/daq/${edcu_name}.ini fi ########## if [ -e $srcdir/src/epics/util/post_build_script.py ]; then echo "Running post-build script..." $srcdir/src/epics/util/post_build_script.py -q ${system} fi