#!/bin/ksh #set -xv # # Use this script to propagated modifcations done to files in one configuration # into the all other configurations in the same directory. Files will be copied # only where they already exist. # # Syntax : # ./propagate_master_config MyConfig # Modifcations in MyConfig will be copied to the other configurations. # Josefine Ghattas IPSL if [ $# == 0 ] ; then echo "You need to specify the configuration from which the modifications will be propagted" echo "./propagate_master_config MyConfig" exit fi MasterConfig=$1 verbose=yes BaseDir=`pwd` ConfigFamily=v6 ConfigList=`ls |grep ${ConfigFamily} |grep -v out` ConfigList=$ConfigList" IPSLCM6" ConfigList="IPSLCM6 LMDZOR_v6" echo All modifications in configuration $MasterConfig will copied to the other configurations $ConfigList . cd $BaseDir/$MasterConfig FileList=`ls -d GENERAL/DRIVER/* GENERAL/PARAM/* GENERAL/POST/* EXPERIMENTS/*/*/* EXPERIMENTS/*/*/*/*` cpfile=$BaseDir/cpfile echo "" > $cpfile cd $BaseDir for conf in $ConfigList ; do # Only contiue if the config is not the MasterConfig if [ $conf != $MasterConfig ] ; then echo Do for conf= $conf and MasterConfig=$MasterConfig for file in $FileList ; do if [ -f ${conf}/${file} ] ; then cmp -s ${MasterConfig}/${file} ${conf}/${file} if [ $? -ne 0 ] ; then # Files are differents echo "cp ${MasterConfig}/${file} ${conf}/${file}" >> $cpfile if [ $verbose == yes ] ; then diff --brief ${MasterConfig}/${file} ${conf}/${file} diff ${MasterConfig}/${file} ${conf}/${file} fi fi fi done echo "" >> $cpfile fi done # Test if there is nothing to copy if [ $( grep cp $cpfile |wc -l ) -eq 0 ] ; then echo "Noting to be done. All files are the same." rm $cpfile exit fi # List files to copy and ask for permission to copy echo "" cat $cpfile echo "Would you like to do the actions listed above, answer yes/no ?" echo -n " Your answer : " read answer case ${answer} in yes|y) chmod +x $cpfile $cpfile echo "Copy has now been done." ;; no|n) echo "Nothing will be done" ;; *) echo "Bad answer. Nothing will be dnoe" ;; esac rm $cpfile exit