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 | |
---|
14 | if [ $# == 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 |
---|
18 | fi |
---|
19 | |
---|
20 | MasterConfig=$1 |
---|
21 | verbose=yes |
---|
22 | BaseDir=`pwd` |
---|
23 | ConfigFamily=v6 |
---|
24 | ConfigList=`ls |grep ${ConfigFamily} |grep -v out` |
---|
25 | ConfigList=$ConfigList" IPSLCM6" |
---|
26 | echo All modifications in configuration $MasterConfig will copied to the other configurations $ConfigList . |
---|
27 | |
---|
28 | cd $BaseDir/$MasterConfig |
---|
29 | FileList=`ls -d GENERAL/DRIVER/* GENERAL/PARAM/* GENERAL/POST/* EXPERIMENTS/*/*/* EXPERIMENTS/*/*/*/*` |
---|
30 | |
---|
31 | cpfile=$BaseDir/cpfile |
---|
32 | |
---|
33 | echo "" > $cpfile |
---|
34 | cd $BaseDir |
---|
35 | |
---|
36 | for conf in $ConfigList ; do |
---|
37 | # Only contiue if the config is not the MasterConfig |
---|
38 | if [ $conf != $MasterConfig ] ; then |
---|
39 | echo Do for conf= $conf and MasterConfig=$MasterConfig |
---|
40 | for file in $FileList ; do |
---|
41 | if [ -f ${conf}/${file} ] ; then |
---|
42 | cmp -s ${MasterConfig}/${file} ${conf}/${file} |
---|
43 | if [ $? -ne 0 ] ; then |
---|
44 | # Files are differents |
---|
45 | echo "cp ${MasterConfig}/${file} ${conf}/${file}" >> $cpfile |
---|
46 | if [ $verbose == yes ] ; then |
---|
47 | diff --brief ${MasterConfig}/${file} ${conf}/${file} |
---|
48 | diff ${MasterConfig}/${file} ${conf}/${file} |
---|
49 | fi |
---|
50 | fi |
---|
51 | fi |
---|
52 | done |
---|
53 | echo "" >> $cpfile |
---|
54 | fi |
---|
55 | done |
---|
56 | |
---|
57 | # Test if there is nothing to copy |
---|
58 | if [ $( grep cp $cpfile |wc -l ) -eq 0 ] ; then |
---|
59 | echo "Noting to be done. All files are the same." |
---|
60 | rm $cpfile |
---|
61 | exit |
---|
62 | fi |
---|
63 | |
---|
64 | # List files to copy and ask for permission to copy |
---|
65 | echo "" |
---|
66 | cat $cpfile |
---|
67 | |
---|
68 | echo "Would you like to do the actions listed above, answer yes/no ?" |
---|
69 | echo -n " Your answer : " |
---|
70 | read answer |
---|
71 | |
---|
72 | case ${answer} in |
---|
73 | yes|y) |
---|
74 | chmod +x $cpfile |
---|
75 | $cpfile |
---|
76 | echo "Copy has now been done." |
---|
77 | ;; |
---|
78 | no|n) |
---|
79 | echo "Nothing will be done" |
---|
80 | ;; |
---|
81 | *) |
---|
82 | echo "Bad answer. Nothing will be dnoe" |
---|
83 | ;; |
---|
84 | esac |
---|
85 | rm $cpfile |
---|
86 | |
---|
87 | exit |
---|