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 | ConfigList="LMDZOR_v6 LMDZORINCA_v6" |
---|
27 | echo All modifications in configuration $MasterConfig will copied to the other configurations $ConfigList . |
---|
28 | |
---|
29 | cd $BaseDir/$MasterConfig |
---|
30 | FileList=`ls -d GENERAL/DRIVER/* GENERAL/PARAM/* GENERAL/POST/* EXPERIMENTS/*/*/* EXPERIMENTS/*/*/*/*` |
---|
31 | |
---|
32 | cpfile=$BaseDir/cpfile |
---|
33 | |
---|
34 | echo "" > $cpfile |
---|
35 | cd $BaseDir |
---|
36 | |
---|
37 | for conf in $ConfigList ; do |
---|
38 | # Only contiue if the config is not the MasterConfig |
---|
39 | if [ $conf != $MasterConfig ] ; then |
---|
40 | echo Do for conf= $conf and MasterConfig=$MasterConfig |
---|
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 |
---|
54 | echo "" >> $cpfile |
---|
55 | fi |
---|
56 | done |
---|
57 | |
---|
58 | # Test if there is nothing to copy |
---|
59 | if [ $( grep cp $cpfile |wc -l ) -eq 0 ] ; then |
---|
60 | echo "Noting to be done. All files are the same." |
---|
61 | rm $cpfile |
---|
62 | exit |
---|
63 | fi |
---|
64 | |
---|
65 | # List files to copy and ask for permission to copy |
---|
66 | echo "" |
---|
67 | cat $cpfile |
---|
68 | |
---|
69 | echo "Would you like to do the actions listed above, answer yes/no ?" |
---|
70 | echo -n " Your answer : " |
---|
71 | read answer |
---|
72 | |
---|
73 | case ${answer} in |
---|
74 | yes|y) |
---|
75 | chmod +x $cpfile |
---|
76 | $cpfile |
---|
77 | echo "Copy has now been done." |
---|
78 | ;; |
---|
79 | no|n) |
---|
80 | echo "Nothing will be done" |
---|
81 | ;; |
---|
82 | *) |
---|
83 | echo "Bad answer. Nothing will be dnoe" |
---|
84 | ;; |
---|
85 | esac |
---|
86 | rm $cpfile |
---|
87 | |
---|
88 | exit |
---|