source: CONFIG/UNIFORM/v6/propagate_master_config.ksh @ 2234

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

Adapted script for special case IPSLCM6 without suffix _v6.

  • Property svn:executable set to *
File size: 2.1 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=v6
24ConfigList=`ls |grep ${ConfigFamily} |grep -v out`
25ConfigList=$ConfigList" IPSLCM6" 
26echo  All modifications in configuration $MasterConfig will copied to the other configurations $ConfigList .
27
28cd $BaseDir/$MasterConfig
29FileList=`ls -d GENERAL/DRIVER/* GENERAL/PARAM/* GENERAL/POST/* EXPERIMENTS/*/*/* EXPERIMENTS/*/*/*/*`
30
31cpfile=$BaseDir/cpfile
32
33echo "" > $cpfile
34cd $BaseDir
35
36for 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
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.