1 | #!/bin/ksh |
---|
2 | # $Id$ |
---|
3 | #--------------------------------------------------------------------- |
---|
4 | #- Installation de scripts de lancement d experiences propres a un environnement |
---|
5 | #--------------------------------------------------------------------- |
---|
6 | d_n=$(dirname ${0}); b_n=$(basename ${0}); |
---|
7 | |
---|
8 | #- Saisie et validation des options |
---|
9 | x_v='silencious'; |
---|
10 | x_d='normal'; |
---|
11 | x_t=""; |
---|
12 | x_n=""; |
---|
13 | |
---|
14 | while getopts :hvd:t:n: V |
---|
15 | do |
---|
16 | case $V in |
---|
17 | (h) echo "Usage : "${b_n} \ |
---|
18 | " [-h] [-v] [-d] [-t h] [-n f]"; |
---|
19 | echo " -h : help"; |
---|
20 | echo " -v : verbose mode"; |
---|
21 | echo " -d : debug mode"; |
---|
22 | echo " -t h : target host_name"; |
---|
23 | echo " -n f : Name"; |
---|
24 | echo "Defaults : -t local_host"; |
---|
25 | exit 0;; |
---|
26 | (v) x_v='verbose';; |
---|
27 | (d) x_d='debug';; |
---|
28 | (t) x_t=${OPTARG};; |
---|
29 | (n) x_n=${OPTARG};; |
---|
30 | (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; |
---|
31 | exit 2;; |
---|
32 | (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; |
---|
33 | exit 2;; |
---|
34 | esac |
---|
35 | done |
---|
36 | shift $(($OPTIND-1)); |
---|
37 | #- Traitement des options |
---|
38 | #- REAL precision |
---|
39 | #- Target_Host Name |
---|
40 | if [ '\?'${x_t} = '\?' ]; then |
---|
41 | x_t=`${d_n}/w_i_h`; |
---|
42 | if [ $? -ne 0 ]; then |
---|
43 | echo "Bad installation : w_i_h/uname unreachable" 1>&2; |
---|
44 | exit 1; |
---|
45 | elif [ "$x_t" = "Unknown" ]; then |
---|
46 | echo "Local_Host not supported" 1>&2; |
---|
47 | exit 1; |
---|
48 | fi; |
---|
49 | fi; |
---|
50 | |
---|
51 | if [ "$x_t" = "sx8brodie" ]; then |
---|
52 | b_n_atlas=$(basename $HOME) |
---|
53 | d_n_atlas=$(dirname $HOME | sed 's/home/u/') |
---|
54 | elif [ "$x_t" = "aix" ]; then |
---|
55 | b_n_atlas=$LOGIN |
---|
56 | d_n_atlas="/u/"$(dirname $HOME | awk -F\/ '{print $3"/"$4}') |
---|
57 | elif [ "$x_t" = "fjvpp" ]; then |
---|
58 | b_n_atlas=$(basename $DMFDIR) |
---|
59 | d_n_atlas=\/$(dirname $DMFDIR | awk -F\/ '{print $4}') |
---|
60 | elif [ "$x_t" = "sx6nec" ]; then |
---|
61 | b_n_atlas=$(basename $DMFDIR) |
---|
62 | d_n_atlas=$(dirname $DMFDIR) |
---|
63 | elif [ "$x_t" = "sx8mercure" ]; then |
---|
64 | b_n_atlas=$(basename $DMFDIR) |
---|
65 | d_n_atlas=$(dirname $DMFDIR) |
---|
66 | else |
---|
67 | echo " !!! WARNING !!!" |
---|
68 | echo " The path for the output files on the storage server," |
---|
69 | echo " needed for the descriptor files, is not automaticaly set." |
---|
70 | echo " Please specify manually this path by replacing the AAAAAAA" |
---|
71 | echo " string in the Output Job with the desired path." |
---|
72 | echo " !!! WARNING !!!" |
---|
73 | fi |
---|
74 | |
---|
75 | case ${x_t} in |
---|
76 | ( aix | cray | fjvpp | linux | lxiv7 | lxiv8 | osf1 | \ |
---|
77 | solaris | t3e | sx8brodie | sx6nec | sx8mercure | unix ) ;; |
---|
78 | (*) |
---|
79 | echo "Target_Host "${x_t}" not supported" 1>&2; |
---|
80 | exit 1;; |
---|
81 | esac |
---|
82 | #- |
---|
83 | x_m=$( (cd $d_n ; pwd) | sed -e "s,/util,," ) |
---|
84 | |
---|
85 | if [ ${x_v} = 'verbose' ]; then |
---|
86 | echo '--- Mode : '${x_v}; |
---|
87 | echo '--- Compilation : '${x_d}; |
---|
88 | echo '--- Target : '${x_t}; |
---|
89 | echo '--- Name : '${x_n}; |
---|
90 | echo '--- MODIPSL directory : '${x_m}; |
---|
91 | fi; |
---|
92 | #- |
---|
93 | #- |
---|
94 | l_rep=`find ${d_n}/.. -name AA_job -print` |
---|
95 | #- |
---|
96 | W_OS=${x_t}; |
---|
97 | # |
---|
98 | if [ ${W_OS} = "sx8brodie" ]; then |
---|
99 | format='\s' |
---|
100 | elif [ ${W_OS} = "aix" ]; then |
---|
101 | format='\s' |
---|
102 | elif [ ${W_OS} = "fjvpp" ]; then |
---|
103 | format='\d' |
---|
104 | elif [ ${W_OS} = "sx6nec" ]; then |
---|
105 | format='\s' |
---|
106 | elif [ ${W_OS} = "sx8mercure" ]; then |
---|
107 | format='\s' |
---|
108 | else |
---|
109 | echo " !!! WARNING !!!" |
---|
110 | echo " The display format of numbers," |
---|
111 | echo " needed for the dates, is not automaticaly set." |
---|
112 | echo " Please specify manually this format by replacing the PPPPPPP" |
---|
113 | echo " string in the Output Job with the desired format." |
---|
114 | echo " !!! WARNING !!!" |
---|
115 | fi |
---|
116 | echo " "; |
---|
117 | echo "Installation of simple execution jobs for $W_OS"; |
---|
118 | echo " "; |
---|
119 | #- |
---|
120 | for i in $l_rep |
---|
121 | do |
---|
122 | j=${i%/AA_job} |
---|
123 | MKTR="$j"'/AA_job' |
---|
124 | Job_name=`( grep '#-Q- '${W_OS}' #@$-r' ${MKTR} || grep '#-Q- '${W_OS}' #PBS -N' ${MKTR} || grep '#-Q- '${W_OS}' #@job_name' ${MKTR} ) | awk -F: '{print $3}'` |
---|
125 | JN2=`( grep '#-Q- '${W_OS}' #@$-r' ${MKTR} || grep '#-Q- '${W_OS}' #PBS -N' ${MKTR} || grep '#-Q- '${W_OS}' #@job_name' ${MKTR} ) | awk -F: '{print $2}'` |
---|
126 | JN4=`( grep '#-Q- '${W_OS}' #@$-r' ${MKTR} || grep '#-Q- '${W_OS}' #PBS -N' ${MKTR} || grep '#-Q- '${W_OS}' #@job_name' ${MKTR} ) | awk -F: '{print $4}'` |
---|
127 | r=$( (cd $j ; pwd) ) |
---|
128 | echo "Installation in directory : $(cd $j ; pwd) "; |
---|
129 | sed -e "s,MMMMMMM,${x_m}," -e "s,RRRRRRR,${r}," -e "s,AAAAAAA,${d_n_atlas}\/${b_n_atlas},g" ${MKTR} > jb1.$$ |
---|
130 | W_XX='#-Q- '$W_OS |
---|
131 | FILE_NAME=""; |
---|
132 | |
---|
133 | if [ '\?'${x_n} = '\?' ] && [ '\?'${Job_name} = '\?' ]; then |
---|
134 | FILE_NAME="$j/Job" |
---|
135 | elif [ '\?'${x_n} = '\?' ] && [ -n "${Job_name}" ] && [ ${Job_name} = XXX ]; then |
---|
136 | FILE_NAME="$j/Job_LO1" |
---|
137 | elif [ '\?'${x_n} != '\?' ] && [ ${Job_name} = XXX ]; then |
---|
138 | FILE_NAME="$j/Job_${x_n}" |
---|
139 | elif [ '\?'${x_n} = '\?' ] && [ -n "${Job_name}" ] && [ ${Job_name} != XXX ]; then |
---|
140 | FILE_NAME="$j/Job_${Job_name}" |
---|
141 | elif [ '\?'${x_n} != '\?' ] && [ ${Job_name} != XXX ]; then |
---|
142 | FILE_NAME="$j/Job_${x_n}" |
---|
143 | fi |
---|
144 | |
---|
145 | if [ ! -f "${FILE_NAME}" ]; then |
---|
146 | case ${FILE_NAME} in |
---|
147 | "$j/Job") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,JJJJJJJ,Job," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};; |
---|
148 | "$j/Job_LO1") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,XXXXXXX,LO1," -e "s,JJJJJJJ,Job_LO1," -e "s,:${JN2}:,," -e "s,${Job_name},LO1.1," -e "s,:${JN4}:,," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};; |
---|
149 | "$j/Job_${x_n}") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,XXXXXXX,${x_n}," -e "s,JJJJJJJ,Job_${x_n}," -e "s,:${JN2}:,," -e "s,${Job_name},${x_n}.1," -e "s,:${JN4}:,," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};; |
---|
150 | "$j/Job_${Job_name}") sed -e "s,PPPPPPP,${format},g" -e "s,^$W_XX *,," -e "s,XXXXXXX,${Job_name}," -e "s,JJJJJJJ,Job_${Job_name}," -e "s,:${JN2}:,," -e "s,${Job_name},${Job_name}.1," -e "s,:${JN4}:,," jb1.$$ | grep -v '^#-Q- ' > ${FILE_NAME};; |
---|
151 | esac |
---|
152 | chmod 755 ${FILE_NAME} |
---|
153 | else |
---|
154 | echo " " |
---|
155 | echo "WARNING : The file ${FILE_NAME} already exists, " |
---|
156 | echo "WARNING : installation was not completed correctly " |
---|
157 | echo "WARNING : !!! NO FILE REPLACED !!!" |
---|
158 | echo "WARNING : use parameter -n new_name to obtain Job_new_name script file" |
---|
159 | echo "WARNING : for example : ins_script -n LP1 " |
---|
160 | echo " " |
---|
161 | rm -f jb1.$$ |
---|
162 | exit 0; |
---|
163 | fi |
---|
164 | echo "Installation in file : `echo ${FILE_NAME} | sed -e 's,/.*/,,' ` "; |
---|
165 | |
---|
166 | #-$$ Introduire ici la selection de la technique de communication |
---|
167 | #-$$ pour OASIS (prefixe #-C- ) |
---|
168 | done |
---|
169 | #- |
---|
170 | rm -f jb1.$$ |
---|
171 | #- |
---|
172 | #-$$ launch ins_post if at least one post-processing utility exists |
---|
173 | #-$$ |
---|
174 | OK_POST=`find ${d_n}/.. -name da2st` |
---|
175 | if [ -n "$OK_POST" ]; then |
---|
176 | ${d_n}/ins_post -t ${x_t} |
---|
177 | fi |
---|
178 | exit 0; |
---|