updateAmda 3.83 KB
#!/bin/bash

# --install | -i ; --update-internal | -u ; --with-remote | -r ; --generate-param-args | -a ; -update-param-args | -p ;
# --spase-synchro | -s ; --clean-new-meta | -c ; --help | -h;

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

	for option in $@
	do
		case $option in
			--install | -i)  INSTALL=1
			;;
			--update-internal | -u)  UPDATE=1
			;;
			--with-remote | -r)  REMOTE=1 
			;;
			--generate-param-args | -a) PARAM_INFO=1
												 CLEAN_ARGS=1
			;;
			--update-param-args | -p) PARAM_INFO=1											  
			;;
			--spase-synchro | -s) SYNCHRO=1
			;;
			--clean-new-meta | -c) CLEAN_NEWMETA=1
			;;
			--help | -h) echo "updateAmda --install | -i ; --update-internal | -u ; --with-remote | -r ; --generate-param-args | -a ; -update-param-args | -p ; --spase-synchro | -s ; --clean-new-meta | -c ; --help | -h;"							
							 exit
			;;
			*) echo "Invalid option" $option
				exit
			;;
		esac
	done
		
	#Please export DDUSER and DDPASS in the shell !!!!
	if  [ $PARAM_INFO ] && [[ -z ${DDUSER+x}  || -z ${DDPASS+x} ]]
		then 
			echo "Warning : DDUSER and DDPASS should be defined to generate params info"
			echo "No params info generation will be done!!!" 
			unset PARAM_INFO
			#export DDUSER=XXXX
			#export DDPASS=XXXX
	fi
	
	# In the case of SPASE synchro export SPASEUSER
	if [ -z ${SPASEUSER+x} ] && [ $SYNCHRO ]
		then
			echo "SPASEUSER should be defined to SYNCHRO SPASE Registry"
			echo "No SYNHRO wil be done!!!" 
			#export SPASEUSER=XXXX
			unset SYNCHRO 
	fi 
	
	if [ $CLEAN_NEWMETA ]
		then 
			echo "cleaning in NEWMETA.."
			# cleanNewMetaLight
			$UPDATEDIR/cleanNewMetaLight
			$UPDATEDIR/cleanNewMetaParamInfo
			echo "clean in NEWMETA : done"
			exit
	fi
		
	if [ $INSTALL ] 
		then
			echo "Installing...."
			
			echo "cleaning in NEWMETA.."
			$UPDATEDIR/cleanNewMetaLight
			echo "clean in NEWMETA : done"
			
			echo "cleaning in AMDA_IHM/generic_data ..."
			$UPDATEDIR/cleanExistingInstallation 
			echo "clean in AMDA_IHM/generic_data : done"
			
			echo "making Amda From Spase..."
			if [ $SYNCHRO ]
				then 
					php $AMDA_SPASE_INTERFACE/makeAmdaFromSpase.php "synchro"
				else 
					php $AMDA_SPASE_INTERFACE/makeAmdaFromSpase.php
			fi			
			echo "make Amda From Spase : done"
			
			echo "making Tree..."
			php $UPDATEDIR/makeTree.php
			echo "make Tree : done"
			
			echo "copying 2 amda..."
			$UPDATEDIR/cp2amda
			echo "copy 2 amda : done"	
			
			echo "making Orbits..."
			$UPDATEDIR/makeOrbits
			echo "make Orbits : done"
			
			echo "copy DDBASE Remote Params descriptions"
			if [ -d $RemoteData/PARAMS ]; then
				cp $RemoteData/PARAMS/* $PARAMS_LOCALDB_DIR/
			fi 
	fi
		# Update StartStop only	
	if [ $UPDATE ]
		then
			echo "Updating...."
			
			if [ $SYNCHRO ]
				then 
					php $AMDA_SPASE_INTERFACE/updateStartStop.php 'synchro'
				else 
					php $AMDA_SPASE_INTERFACE/updateStartStop.php	 
			fi
			
			echo 'update in NEWMETA/dd_missions: done'
			
			echo "making Tree..."
			php $UPDATEDIR/makeTree.php
			echo "make Tree : done"
 
			if [ -d $LocalData ] && [ -e ./LocalParams.xml ]
			then
				mv ./LocalParams.xml $LocalData
			fi
			echo 'copy 2 amda : done'
			
			echo "updating OrbitsInfo..."
			php $AMDA_IHM/php/RemoteDataCenter/makeOrbitsInfo.php
			echo "update OrbitsInfo : done" 
	fi
	
	if [ $PARAM_INFO ] 
		then
			echo "Generating param info...."
			
			if [ $CLEAN_ARGS ]; then 
				$UPDATEDIR/cleanNewMetaParamInfo
			fi
			
			generate_param_info
			# copy info for parameter arguments
			if [ ! -d $PARAMS_LOCALINFO_DIR ]; then
				mkdir $PARAMS_LOCALINFO_DIR
			fi 
			
			if [ -d $NEWMETA/ParamInfo ] 
			then 
				cp $NEWMETA/ParamInfo/info*.xml $PARAMS_LOCALINFO_DIR
			fi 
			
			echo "generate info for arguments : done"								
	fi
		 	
	if [ $REMOTE ] 
		then
			echo "making Remote"
			$UPDATEDIR/makeRemote
			echo "make Remote : done"
	fi