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

Last change on this file since 2053 was 2052, checked in by jgipsl, 12 years ago

Adapted script to allow configuration names with extension after family name (v5). All configurations must contain the family name. For exmple now ok : LMDZOR_v5.2, LMDZOR_v52, LMDZOR_v5-2

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