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