epics
script installation script - Compact - Just the code
# epics script installation
# ----------------------------------------
# Create Directory
[ -d ${%EPICS_ALL_EPICS_TOP_DIR_NAME%:?"undefined"} ] && %MKDIR_CMD% -p ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin || %DIE_CMD%
# Allow use of EPICS installations (to deny: comment out with leading '#')
export ALLOW_USE_OF_EPICS_GSI_INSTALL=true;
# Definitions:
[ 'true' == "$ALLOW_USE_OF_EPICS_GSI_INSTALL" ] && export GSI_EPICS_INSTALLATIONS_TOP_DIR=~epics
# Change to directory ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin
%CD_CMD% ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin || %DIE_CMD%;
# define list of scripts to be looked for
list=epics
# Process for each item in list
%FOR_CMD% item in ${list}
do
# Does a valid item already exist in ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin ?
# if yes, do nothing
# if no then
# 1) check if there is an invalid symbolic link
# yes) remove it
# 2) download it to %EPICS_DOWNLOAD_DIR%/bin
# 3) check if you can already resolve it via '%WHICH_CMD%'
# yes) compare this with
%IF_CMD% [ ! -e ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin/${item} ];
%THEN_CMD%
# Does item is an invalid symbolic link in ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin?
%IF_CMD% [ -L ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin/${item} ]
%THEN_CMD%
echo removing invalid link ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin/${item}:
echo " "$(%LS_CMD% -l ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin/${item})
%RM_CMD% ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin/${item}
%FI_CMD%
# Allow use of GSI EPICS tools ?
# true) create symbolic links to gsi epics installations
%IF_CMD% [ 'true' = "$ALLOW_USE_OF_EPICS_GSI_INSTALL" ]
%THEN_CMD%
%IF_CMD% [ -f %GSI_EPICS_INSTALLATIONS_TOP_DIRECTORY_VAR%/bin/${item} ];
%THEN_CMD%
%LN_CMD% %GSI_EPICS_INSTALLATIONS_TOP_DIRECTORY_VAR%/bin/${item};
%FI_CMD%
%FI_CMD%
%FI_CMD%
# check once again:
# Does a valid item already exist in ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin ?
# if not then
# 1) download it to %EPICS_DOWNLOAD_DIR%/bin
# 2) check if you can already resolve it via '%WHICH_CMD%'
# yes) compare this with the download:
# identical) create another symbolic link to it
# else) copy download to ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin
%IF_CMD% [ ! -e ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin/${item} ];
%THEN_CMD%
%MKDIR_CMD% %EPICS_DOWNLOAD_DIR%/bin &&
%CD_CMD% %EPICS_DOWNLOAD_DIR%/bin &&
%WGET_CMD% https://wiki.gsi.de/pub/Epics/EpicsInstallationsAtGsiBaseEpicsScriptInstallationScriptMainCode/${item} || die "something went wrong"
doLocalCopy=false;
lookup=$(%WHICH_CMD% ${item})
%IF_CMD% [ ! -z "${lookup}" ]
%THEN_CMD%
%DIFF_CMD% %EPICS_DOWNLOAD_DIR%/bin/${item} ${lookup} > /dev/null
%IF_CMD% [ 0 -eq $? ]
%THEN_CMD%
%LN_CMD% ${lookup}
doLocalCopy=false
%FI_CMD%
%ELSE_CMD%
doLocalCopy=true;
%FI_CMD%
%IF_CMD% [ "true" = "$doLocalCopy" ]
%THEN_CMD%
%CP_CMD% %EPICS_DOWNLOAD_DIR%/bin/${item} ${%EPICS_ALL_EPICS_TOP_DIR_NAME%}/bin
%FI_CMD%
%FI_CMD%
done
%UNSET_CMD% item lookup list doLocalCopy
%CD_CMD% %EPICSBASE_MYHOMEDIR% || %DIE_CMD%;