updateAmda 3.87 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;
 
	export UPDATEDIR=`pwd`/$(dirname "$0")
	. $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 AMDA_Kernel/config..."
			$UPDATEDIR/cleanExistingInstallation 
			echo "clean in AMDA_IHM/generic_data AMDA_Kernel/config : 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"
	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 $AMDAINSTALLATION/AMDA_IHM/generic_data/LocalData ] && [ -e ./LocalParams.xml ]
			then
				mv ./LocalParams.xml $AMDAINSTALLATION/AMDA_IHM/generic_data/LocalData
			fi
			echo 'copy 2 amda : done'
			
			echo "updating OrbitsInfo..."
			php $AMDAINSTALLATION/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 $AMDAINSTALLATION/AMDA_IHM/generic_data/ParamInfo ]; then
				mkdir $AMDAINSTALLATION/AMDA_IHM/generic_data/ParamInfo
			fi 
			
			if [ -d $NEWMETA/ParamInfo ] 
			then 
				cp $NEWMETA/ParamInfo/info*.xml $AMDAINSTALLATION/AMDA_IHM/generic_data/ParamInfo
			fi 
			
			echo "generate info for arguments : done"								
	fi
		 	
	if [ $REMOTE ] 
		then
			echo "making Remote"
			$UPDATEDIR/makeRemote
			echo "make Remote : done"
	fi