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

Last change on this file since 2015 was 1743, checked in by jgipsl, 13 years ago

Change variables UserSpec? into ExpType? in config.card due to previous change in directory name.

  • Property svn:executable set to *
File size: 2.0 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}' )
24ConfigList=`ls |grep ${ConfigFamily} |grep -v out |grep -v $MasterConfig`
25
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    for file in $FileList ; do
38        if [ -f ${conf}/${file} ] ; then
39            cmp -s ${MasterConfig}/${file}  ${conf}/${file}
40            if [ $? -ne 0 ] ; then
41            # Files are differents
42                echo "cp ${MasterConfig}/${file} ${conf}/${file}" >> $cpfile
43                if [ $verbose == yes ] ; then
44                    diff  --brief ${MasterConfig}/${file}  ${conf}/${file}
45                    diff  ${MasterConfig}/${file}  ${conf}/${file}
46                fi         
47            fi
48        fi
49    done
50echo "" >> $cpfile
51done
52
53# Test if there is nothing to copy
54if [ $( grep cp $cpfile |wc -l ) -eq 0 ] ; then
55    echo "Noting to be done. All files are the same."
56    rm $cpfile
57    exit
58fi
59
60# List files to copy and ask for permission to copy
61echo ""
62cat $cpfile
63
64echo "Would you like to do the actions listed above, answer yes/no ?"
65echo -n " Your answer : "
66read answer
67
68case ${answer} in
69yes|y)
70chmod +x $cpfile
71$cpfile
72echo "Copy has now been done."
73;;
74no|n)
75echo "Nothing will be done"
76;;
77*)
78echo "Bad answer. Nothing will be dnoe"
79;;
80esac
81rm $cpfile
82
83exit
Note: See TracBrowser for help on using the repository browser.