[27] | 1 | #! /bin/sh |
---|
[2] | 2 | #+ |
---|
[67] | 3 | # |
---|
[82] | 4 | # .. _ircaam_profile.sh: |
---|
| 5 | # |
---|
[72] | 6 | # ================= |
---|
| 7 | # ircaam_profile.sh |
---|
| 8 | # ================= |
---|
[2] | 9 | # |
---|
[72] | 10 | # ------------------------- |
---|
| 11 | # define IRCAAM environment |
---|
| 12 | # ------------------------- |
---|
[2] | 13 | # |
---|
[60] | 14 | # SYNOPSIS |
---|
[2] | 15 | # ======== |
---|
| 16 | # |
---|
[75] | 17 | # Online usage:: |
---|
[71] | 18 | # |
---|
[75] | 19 | # $ . ./ircaam_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
[2] | 20 | # |
---|
[85] | 21 | # In :file:`${HOME}/.profile`, add the following line:: |
---|
[2] | 22 | # |
---|
[75] | 23 | # . ./ircaam_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
[71] | 24 | # |
---|
[2] | 25 | # DESCRIPTION |
---|
| 26 | # =========== |
---|
| 27 | # |
---|
[60] | 28 | # define IRCAAM environment |
---|
[2] | 29 | # |
---|
[55] | 30 | # ${IRCAAM} is the source base directory of tools. |
---|
[2] | 31 | # |
---|
[12] | 32 | # ${IRCAAM_LOG} is the directory where log files will be written. |
---|
[2] | 33 | # |
---|
[12] | 34 | # ${IRCAAM_ID} is the directory where input files must be. |
---|
[2] | 35 | # |
---|
[12] | 36 | # ${IRCAAM_OD} is the directory where output files will be written. |
---|
[2] | 37 | # |
---|
[55] | 38 | # ${IRCAAM}/../bin/ is added to PATH. |
---|
| 39 | # |
---|
[12] | 40 | # SEE ALSO |
---|
| 41 | # ======== |
---|
| 42 | # |
---|
| 43 | # for matlab/octave environment : |
---|
| 44 | # |
---|
[82] | 45 | # :ref:`ircaam_startup.m` |
---|
[12] | 46 | # |
---|
[2] | 47 | # EXAMPLES |
---|
| 48 | # ======== |
---|
| 49 | # |
---|
[75] | 50 | # For fplod, on aedon.locean-ipsl.upmc.fr:: |
---|
[2] | 51 | # |
---|
[75] | 52 | # $ cd /usr/home/fplod/incas/ircaam/ircaam_ws/ |
---|
| 53 | # $ . ./src/ircaam_profile.sh \ |
---|
[2] | 54 | # -d $(pwd) \ |
---|
| 55 | # -i /usr/temp/${LOGNAME}/ircaam_d/ \ |
---|
| 56 | # -o /usr/temp/${LOGNAME}/ircaam_d/ \ |
---|
| 57 | # -t /usr/temp/${LOGNAME}/log/ |
---|
| 58 | # |
---|
[75] | 59 | # For fplod on zeus.locean-ipsl.umpc.fr:: |
---|
[2] | 60 | # |
---|
[75] | 61 | # $ cd ${HOME}/incas/ircaam/ircaam_ws/ |
---|
| 62 | # $ . ./src/ircaam_profile.sh \ |
---|
[2] | 63 | # -d $(pwd) \ |
---|
| 64 | # -i /usr/temp/${LOGNAME}/ircaam_d/ \ |
---|
| 65 | # -o /usr/temp/${LOGNAME}/ircaam_d/ \ |
---|
| 66 | # -t /usr/temp/${LOGNAME}/log/ |
---|
| 67 | # |
---|
[7] | 68 | # TODO |
---|
| 69 | # ==== |
---|
| 70 | # |
---|
[2] | 71 | # ++ option bavarde |
---|
| 72 | # |
---|
| 73 | # ++ machine dependant |
---|
| 74 | # |
---|
| 75 | # ++ besoin de posix |
---|
| 76 | # |
---|
| 77 | # ++ pas de MANPATH defini par défaut sur zeus |
---|
| 78 | # |
---|
| 79 | # ++ climserv |
---|
| 80 | # |
---|
[72] | 81 | # EVOLUTIONS |
---|
| 82 | # ========== |
---|
| 83 | # |
---|
[2] | 84 | # $Id$ |
---|
| 85 | # |
---|
[80] | 86 | # - fplod 20100426T094821Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 87 | # |
---|
| 88 | # * improve PATH and MANPATH modification |
---|
| 89 | # |
---|
| 90 | # - fplod 20100423T143244Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 91 | # |
---|
| 92 | # * add error handling on mkdir |
---|
| 93 | # |
---|
[59] | 94 | # - fplod 2009-02-17T11:59:35Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 95 | # |
---|
[80] | 96 | # * more unset statements |
---|
[59] | 97 | # |
---|
[55] | 98 | # - fplod 2009-02-04T13:35:30Z zeus.locean-ipsl.upmc.fr (Linux) |
---|
| 99 | # |
---|
[80] | 100 | # * ${IRCAAM}/../bin/ is added to PATH. |
---|
[55] | 101 | # |
---|
[2] | 102 | # - fplod 2008-08-14T12:28:16Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 103 | # |
---|
[80] | 104 | # * move all \*.sh and \*.pro files to src/ |
---|
[2] | 105 | # |
---|
| 106 | # - fplod 2008-07-21T10:58:47Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 107 | # |
---|
| 108 | # * creation |
---|
| 109 | # |
---|
| 110 | #- |
---|
| 111 | system=$(uname) |
---|
| 112 | case "${system}" in |
---|
[77] | 113 | AIX|IRIX64) |
---|
| 114 | echo " www : no specific posix checking" |
---|
| 115 | ;; |
---|
| 116 | *) |
---|
| 117 | set -o posix |
---|
| 118 | ;; |
---|
[2] | 119 | esac |
---|
[59] | 120 | unset system |
---|
[2] | 121 | # |
---|
[88] | 122 | set -u |
---|
| 123 | # |
---|
[67] | 124 | LANG=C |
---|
[60] | 125 | # |
---|
[2] | 126 | # as this script might be launch in .profile, command is forced. |
---|
| 127 | command=ircaam_profile.sh |
---|
| 128 | # |
---|
| 129 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" |
---|
| 130 | # |
---|
[88] | 131 | while [ ${#} -gt 0 ] |
---|
[2] | 132 | do |
---|
[77] | 133 | case ${1} in |
---|
[80] | 134 | -d) |
---|
| 135 | # directory for application choosen by user (see svn checkout command used) |
---|
[77] | 136 | directory=${2} |
---|
| 137 | shift |
---|
| 138 | ;; |
---|
[80] | 139 | -i) |
---|
| 140 | # directory for inputs choosen by user |
---|
[77] | 141 | indir=${2} |
---|
| 142 | shift |
---|
| 143 | ;; |
---|
[80] | 144 | -o) |
---|
| 145 | # directory for outputs choosen by user |
---|
[77] | 146 | outdir=${2} |
---|
| 147 | shift |
---|
| 148 | ;; |
---|
[80] | 149 | -t) |
---|
| 150 | # directory for temporary outputs choosen by user |
---|
[77] | 151 | tempdir=${2} |
---|
| 152 | shift |
---|
| 153 | ;; |
---|
[80] | 154 | *) |
---|
| 155 | # other choice |
---|
[77] | 156 | echo "eee : unknown option ${1}" |
---|
| 157 | echo "${usage}" |
---|
| 158 | # nb : no exit because this file should be launched by login process |
---|
| 159 | ;; |
---|
| 160 | esac |
---|
[80] | 161 | # next flag |
---|
| 162 | shift |
---|
[2] | 163 | done |
---|
[59] | 164 | unset usage |
---|
| 165 | # |
---|
[2] | 166 | # check for ${directory} |
---|
| 167 | if [ ! -d ${directory} ] |
---|
| 168 | then |
---|
[77] | 169 | echo " eee : ${directory} not found" |
---|
| 170 | # nb : no exit because this file should be launched by login process |
---|
[2] | 171 | fi |
---|
| 172 | # |
---|
| 173 | # check for permission on directory |
---|
| 174 | if [ ! -x ${directory} ] |
---|
| 175 | then |
---|
[77] | 176 | echo " eee : ${directory} not reachable" |
---|
| 177 | # nb : no exit because this file should be launched by login process |
---|
[2] | 178 | fi |
---|
| 179 | # |
---|
| 180 | IRCAAM=${directory} |
---|
| 181 | export IRCAAM |
---|
[59] | 182 | unset directory |
---|
[2] | 183 | # |
---|
| 184 | # add IRCAAM tools to PATH |
---|
| 185 | # if not already done |
---|
[80] | 186 | suppath=$(echo ${IRCAAM} | tr -s "/") |
---|
| 187 | echo ${PATH} | grep -q "${suppath}:" |
---|
[2] | 188 | test_path=${?} |
---|
| 189 | if [ ${test_path} -ne 0 ] |
---|
| 190 | then |
---|
[80] | 191 | PATH=${suppath}:${PATH} |
---|
[2] | 192 | export PATH |
---|
| 193 | else |
---|
| 194 | # option bavarde oui/non pas encore implantée ++ |
---|
[80] | 195 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
[2] | 196 | fi |
---|
[59] | 197 | unset test_path |
---|
[80] | 198 | unset suppath |
---|
[2] | 199 | # |
---|
[55] | 200 | # add ${IRCAAM}/../bin tools to PATH |
---|
| 201 | # if not already done |
---|
[80] | 202 | suppath=$(echo ${IRCAAM}/../bin | tr -s "/") |
---|
| 203 | echo ${PATH} | grep -q "${suppath}:" |
---|
[55] | 204 | test_path=${?} |
---|
| 205 | if [ ${test_path} -ne 0 ] |
---|
| 206 | then |
---|
[80] | 207 | PATH=${suppath}:${PATH} |
---|
[55] | 208 | export PATH |
---|
| 209 | else |
---|
| 210 | # option bavarde oui/non pas encore implantée ++ |
---|
[80] | 211 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
[55] | 212 | fi |
---|
[59] | 213 | unset test_path |
---|
[81] | 214 | unset suppath |
---|
[55] | 215 | # |
---|
[75] | 216 | # add IRCAAM manuals to MANPATH |
---|
| 217 | # if not already done |
---|
[80] | 218 | suppath=$(echo ${IRCAAM}/doc/manuals/man | tr -s "/") |
---|
| 219 | echo ${MANPATH} | grep -q ${suppath} |
---|
[75] | 220 | test_manpath=${?} |
---|
| 221 | if [ ${test_manpath} -ne 0 ] |
---|
| 222 | then |
---|
[80] | 223 | MANPATH=${suppath}:${MANPATH} |
---|
[75] | 224 | export MANPATH |
---|
| 225 | else |
---|
| 226 | # option bavarde oui/non pas encore implantée ++ |
---|
[80] | 227 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
[75] | 228 | fi |
---|
| 229 | unset test_manpath |
---|
[80] | 230 | unset suppath |
---|
[75] | 231 | # |
---|
[7] | 232 | IRCAAM_LOG=${tempdir} |
---|
| 233 | export IRCAAM_LOG |
---|
[59] | 234 | unset tempdir |
---|
[12] | 235 | if [ ! -d ${IRCAAM_LOG} ] |
---|
[2] | 236 | then |
---|
[80] | 237 | mkdir -p ${IRCAAM_LOG} |
---|
| 238 | status=${?} |
---|
| 239 | if [ ${status} -ne 0 ] |
---|
| 240 | then |
---|
| 241 | echo "${command} : eee : can not create \${IRCAAM_LOG}" |
---|
| 242 | # nb : no exit because this file should be launched by login process |
---|
| 243 | else |
---|
| 244 | echo "${command} : iii : creation of \${IRCAAM_LOG}" |
---|
| 245 | fi |
---|
| 246 | unset status |
---|
[12] | 247 | fi |
---|
[7] | 248 | # check for permission on IRCAAM_LOG |
---|
| 249 | if [ ! -x ${IRCAAM_LOG} ] |
---|
[2] | 250 | then |
---|
[77] | 251 | echo " eee : ${IRCAAM_LOG} not reachable" |
---|
| 252 | # nb : no exit because this file should be launched by login process |
---|
[2] | 253 | fi |
---|
| 254 | # |
---|
[7] | 255 | # check for permission on IRCAAM_LOG |
---|
| 256 | if [ ! -w ${IRCAAM_LOG} ] |
---|
[2] | 257 | then |
---|
[77] | 258 | echo " eee : ${IRCAAM_LOG} not writable" |
---|
| 259 | # nb : no exit because this file shouldreachable be launched by login process |
---|
[2] | 260 | fi |
---|
| 261 | # |
---|
| 262 | EDITOR=vi |
---|
| 263 | export EDITOR |
---|
| 264 | # |
---|
| 265 | # io directories |
---|
| 266 | IRCAAM_ID=${indir} |
---|
| 267 | export IRCAAM_ID |
---|
[59] | 268 | unset indir |
---|
[12] | 269 | if [ ! -d ${IRCAAM_ID} ] |
---|
[2] | 270 | then |
---|
| 271 | mkdir -p ${IRCAAM_ID} |
---|
| 272 | echo "${command} : iii : creation of \${IRCAAM_ID}" |
---|
[12] | 273 | fi |
---|
[2] | 274 | # check for permission on IRCAAM_ID |
---|
| 275 | if [ ! -x ${IRCAAM_ID} ] |
---|
| 276 | then |
---|
[77] | 277 | echo " eee : ${IRCAAM_ID} not reachable" |
---|
| 278 | # nb : no exit because this file should be launched by login process |
---|
[2] | 279 | fi |
---|
| 280 | # |
---|
| 281 | IRCAAM_OD=${outdir} |
---|
| 282 | export IRCAAM_OD |
---|
[59] | 283 | unset outdir |
---|
[2] | 284 | if [ ! -d ${IRCAAM_OD} ] |
---|
| 285 | then |
---|
[77] | 286 | mkdir -p ${IRCAAM_OD} |
---|
| 287 | echo "${command} : iii : creation of \${IRCAAM_OD}" |
---|
[2] | 288 | fi |
---|
| 289 | # check for permission on IRCAAM_OD |
---|
| 290 | if [ ! -x ${IRCAAM_OD} ] |
---|
| 291 | then |
---|
| 292 | echo " eee : ${IRCAAM_OD} not reachable" |
---|
| 293 | # nb : no exit because this file should be launched by login process |
---|
| 294 | fi |
---|
| 295 | if [ ! -w ${IRCAAM_OD} ] |
---|
| 296 | then |
---|
| 297 | echo " eee : ${IRCAAM_OD} not writable" |
---|
| 298 | # nb : no exit because this file should be launched by login process |
---|
| 299 | fi |
---|
| 300 | # |
---|
[75] | 301 | # end |
---|
[59] | 302 | unset command |
---|
| 303 | # |
---|
[2] | 304 | # nb : no exit because this file should be launched by login process |
---|