source: CONFIG/UNIFORM/u1/propagate_master_config.ksh @ 1698

Last change on this file since 1698 was 1698, checked in by jgipsl, 10 years ago

Propagated modifications done in two previsous commit in LMDZORINCA_u1 configuration to all other configs in u1 family. See commit rev 1696 and 1697.

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