generate_param_info 2.68 KB
#!/bin/bash

SCRIPT=$(readlink -f "$0")
export UPDATEDIR=$(dirname "$SCRIPT")
. $UPDATEDIR/updateEnv.sh

if [[ -z ${NEWMETA+x} || -z ${AMDA_KERNEL_DIR+x} ]]; then 
  echo "[ERROR] check if NEWMETA & AMDA_KERNEL_DIR env variables are defined"
  exit
fi 
   
CRT_PWD=`pwd`

cd $AMDA_KERNEL_DIR/app-generate-paraminfo
 
export PATH=$AMDA_KERNEL_DIR/build/${KERNEL_BUILD_TYPE}/bin:$PATH
export DDPATH=$AMDA_KERNEL_DIR/app-generate-paraminfo

PARAM_INFO_PATH=$NEWMETA/ParamInfo
if [ ! -d "$PARAM_INFO_PATH" ]; then
	mkdir "$PARAM_INFO_PATH"
fi

# if predefined param info exists - copy it to NEWMETA/ParamInfo 
# to avoid not needed calculations

if  [ -d $AMDAINTERNALDIR/PARAM_INFO_PREDEFINED ]; then
	cp $AMDAINTERNALDIR/PARAM_INFO_PREDEFINED/info*.xml $PARAM_INFO_PATH
fi

for param_file in $NEWMETA/final/*.xml
do
    param_filename=$(basename "${param_file%.*}")    
    info_file=info_${param_filename}.xml
    
    if [ -e $PARAM_INFO_PATH/$info_file ]
     then
       #echo ${param_filename} exists
       temp=a
     else
      echo "Generate info file for ${param_filename}"           
      php $UPDATEDIR/preprocessInfo.php ${param_filename}         
    fi
done

#modif in app.properties
if [ ! -e ./app.properties ]; then
	echo "No app.properties file !!!"
	exit
fi

if [ -e ./app.properties.temp ]; then
	rm ./app.properties.temp
fi

while read line  
	do
		
		if [[ $line == app.param.path* ]]; then
			line="app.param.path="$NEWMETA"final/"
		fi
		
		if [[ $line == app.dataSetInfo.path* ]]; then
			line="app.dataSetInfo.path="$NEWMETA"datasets/"
		fi
		
		if [[ $line == app.user.name* ]]; then
			line="app.user.name="$DDUSER
		fi
		
		if [[ $line == app.plugin* ]]; then
			line="app.plugin=./../build/"$KERNEL_BUILD_TYPE"/plugin/"
		fi	
		
		if [[ $line == app.process.LIB* ]]; then
			line="app.process.LIB=-L../build/"$KERNEL_BUILD_TYPE"/lib/ -lParameters"
		fi	
		
		echo $line >> ./app.properties.temp
	
	done < <(cat $AMDA_KERNEL_DIR/app-generate-paraminfo/app.properties)
	
cp  ./app.properties.temp $AMDA_KERNEL_DIR/app-generate-paraminfo/app.properties
#fi 
   
   
DDLogin $DDUSER $DDPASS

for param_file in $NEWMETA/final/*.xml
do
    param_filename=$(basename "${param_file%.*}")    
    info_file=info_${param_filename}.xml
    
    if [ -e $NEWMETA/ParamInfo/$info_file ]
     then
       # echo ${param_filename} exists
       temp=a
     else
      echo "Generate info file for ${param_filename}"
      amdaParameterInfo -p ${param_filename}
      if [ $? -eq 0 ]; then
         mv $info_file  $PARAM_INFO_PATH
      fi
    fi
done

# copy info for parameter arguments
if [ ! -d $PARAMS_LOCALINFO_DIR ]; then
	mkdir $PARAMS_LOCALINFO_DIR
fi 

cp $PARAM_INFO_PATH/info*.xml $PARAMS_LOCALINFO_DIR

cd ${CRT_PWD}