#!/bin/bash # This script will: # - deliver the DeployUnitName, the according FEC on which the class will run and the according DeviceNames into the FESA 2.10 Database # Script written by Alexander Schwinn - 15.06.2011 #Define command to leave this script if [ ${BASH_SOURCE[0]} == $0 ]; then #script is called from within another script. Means we have to use exit to leave LEAVE_DB_DELIVER_SCRIPT=exit else #script is sourced (called from a console) means we need to use return (exit would close the console) LEAVE_DB_DELIVER_SCRIPT=return fi # Check Parameters if [ $# -ne 3 ];then echo "" echo "Error: Wrong number of parameters" echo "Use: ./deliver.script [DeploymentUnitName] [FEC] [DeviceName] to run this script" echo "" echo "[DeploymentUnitName] Name of the DeploymentUnit you want to add to the Database (MAX_NAME_LEANGTH=20)" echo "[FEC] The front end, on which the class will run" echo "[DeviceName] Name of the Device you want to add to the Database for this DeploymentUnit.(MAX_NAME_LEANGTH=30)" echo " Please note that a DeviceName needs to be unique through all classes in the database" echo "" ${LEAVE_DB_DELIVER_SCRIPT} 1 fi DEPLOY_UNIT_NAME=$1 FEC=$2 DEVICE_NAME=$3 #SQL Settings USERNAME=FESA PASS=NOPASSWORD DATABASE_NAME=AccDbT echo Delivering DeployUnitName and DeviceName to Database: ${DATABASE_NAME} sqlplus -s -l $USERNAME/$PASS@$DATABASE_NAME << EOF insert into fesa_deviceclasses (classname) values ('${DEPLOY_UNIT_NAME}'); insert into fesa_classversions (classname, version, class_type, description, framework_version) values ('${DEPLOY_UNIT_NAME}', 0,'standard-class','Trivial template','3.0'); Insert into abc_devices (DEVICE_ID,DEVICENAME,ALIAS,ACCELERATOR,SUBSYSTEM,FECNAME,BUSTYPE, SERVERNAME,CLASSNAME,DEVICETYPE,PPM,ALARMS,DESCRIPTION,GM_MBNO,SL_FAMILY, SL_MEMNUMBER,SL_ACCESSTYPE,SL_EQUIPMENTSORT,SL_MEMHISTID,SL_LOCALEDU,SL_FIELD5, SL_FIELD6,SL_FIELD7,SL_FIELD8,SL_FIELD9,SL_FIELD10,DERIVED1,DERIVED2,DERIVED3, DERIVED4,DERIVED5,DERIVED6,DERIVED7,DERIVED8,DERIVED9,DERIVED10,INSTALL_CLASSVERSION, INSTALL_GM_CLASSNO,TEMPORARY,SL_USERNAME,SL_DATETIME,UPDATED,UPDATER,TIMING_DOMAIN,REFIMPL,CLASS_ID) values (ABC_DEVICE_ID_SEQ.nextval,'${DEVICE_NAME}',null,'GSI_TEST',null,'${FEC}',null, '${DEPLOY_UNIT_NAME}.${FEC}','${DEPLOY_UNIT_NAME}',null,null,null,'SQL test device',null,null,null,null,null, null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1, null,null,null,null,null,null,'NONE','DIR',null); exit EOF echo Delivering finished. Please note that unique-constraint errors may indicate, that your DeploymentUnit, or your Device does already exist in the Database! errorCode=$? # checks if the last operation (sqlplus) was completed successfully or not if [ ${errorCode} -ne 0 ] then echo "SQLPlus was unable to connect the DB with the supplied credentials" exit ${LEAVE_DB_DELIVER_SCRIPT} 1 fi ${LEAVE_DB_DELIVER_SCRIPT} 0