source: CONFIG/UNIFORM/v5/propagate_master_config.ksh @ 2106

Last change on this file since 2106 was 2106, checked in by jgipsl, 11 years ago

Bug fix : corrected bad behaviour if the master config was LMDZOR_v5.2

  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/bin/ksh
2#set -xv
3#
4# Use this script to propagated modifcations done to files in one configuration
5# into the all other configurations in the same directory. Files will be copied
6# only where they already exist.
7#
8# Syntax :
9# ./propagate_master_config MyConfig
10# Modifcations in MyConfig will be copied to the other configurations.
11
12# Josefine Ghattas IPSL
13
14if [ $# == 0 ] ; then
15    echo "You need to specify the configuration from which the modifications will be propagted"
16    echo "./propagate_master_config MyConfig"
17    exit
18fi
19
20MasterConfig=$1
21verbose=yes
22BaseDir=`pwd`
23ConfigFamily=$( echo $MasterConfig | awk -F"_" '{print $2}' | awk -F"." '{print $1}' )
24echo ConfigFamily=$ConfigFamily
25
26# ConfigListOther : all configurations except MasterConfig. The configurations must contain ConfigFamily in the name
27ConfigListOther=`ls |grep ${ConfigFamily} |grep -v out |grep -vx $MasterConfig`
28
29echo  All modifications in configuration $MasterConfig will copied to the other configurations :
30echo  $ConfigListOther
31
32cd $BaseDir/$MasterConfig
33FileList=`ls -d GENERAL/DRIVER/* GENERAL/PARAM/* GENERAL/POST/* EXPERIMENTS/*/*/* EXPERIMENTS/*/*/*/*`
34
35cpfile=$BaseDir/cpfile
36
37echo "" > $cpfile
38cd $BaseDir
39
40for conf in $ConfigListOther ; do
41    for file in $FileList ; do
42        if [ -f ${conf}/${file} ] ; then
43            cmp -s ${MasterConfig}/${file}  ${conf}/${file}
44            if [ $? -ne 0 ] ; then
45            # Files are differents
46                echo "cp ${MasterConfig}/${file} ${conf}/${file}" >> $cpfile
47                if [ $verbose == yes ] ; then
48                    diff  --brief ${MasterConfig}/${file}  ${conf}/${file}
49                    diff  ${MasterConfig}/${file}  ${conf}/${file}
50                fi         
51            fi
52        fi
53    done
54echo "" >> $cpfile
55done
56
57# Test if there is nothing to copy
58if [ $( grep cp $cpfile |wc -l ) -eq 0 ] ; then
59    echo "Noting to be done. All files are the same."
60    rm $cpfile
61    exit
62fi
63
64# List files to copy and ask for permission to copy
65echo ""
66cat $cpfile
67
68echo "Would you like to do the actions listed above, answer yes/no ?"
69echo -n " Your answer : "
70read answer
71
72case ${answer} in
73yes|y)
74chmod +x $cpfile
75$cpfile
76echo "Copy has now been done."
77;;
78no|n)
79echo "Nothing will be done"
80;;
81*)
82echo "Bad answer. Nothing will be dnoe"
83;;
84esac
85rm $cpfile
86
87exit
Note: See TracBrowser for help on using the repository browser.