updateAmda 3.15 KB
#!/bin/bash

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

. updateEnv.sh

	for option in $@
	do
		case $option in
			--install | -i)  INSTALL=1
			;;
			--with-remote | -r)  REMOTE=1 
			;;
			--generate-param-args | -a) PARAM_INFO=1
			;;
			--spase-synchro | -s) SYNCHRO=1
			;;
			--clean-new-meta | -c) CLEAN_NEWMETA=1
			;;
			--help | -h) echo "updateAmda --install | -i ; --with-remote | -r ; --generate-param-args | -a ; --spase-synchro | -s ; --clean-new-meta | -c ; --help | -h;"
							 echo "updateAmda without args : update only"
							 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
			echo "clean in NEWMETA LIGHT : done"
			exit
	fi
	
	
	if [ $INSTALL ] 
		then
			echo "Installing...."
			
			echo "cleaning in NEWMETA.."
			cleanNewMetaLight
			echo "clean in NEWMETA : done"
			
			echo "cleaning in AMDA_IHM/generic_data AMDA_Kernel/config..."
			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 $AMDA_SPASE_INTERFACE/makeTree.php
			echo "make Tree : done"
			
			echo "copying 2 amda..."
			cp2amda
			echo "copy 2 amda : done"	
			
			echo "making Orbits..."
			makeOrbits
			echo "make Orbits : done"
		# Update StartStop only	
		else
			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 $AMDA_SPASE_INTERFACE/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...."
			
			cleanNewMetaAll
			generate_param_info
			
			echo "generate info for arguments : done"			
	fi
		 	
	if [ $REMOTE ] 
		then
			echo "making Remote"
			makeRemote
			echo "make Remote : done"
	fi