[82] | 1 | #! /bin/sh |
---|
| 2 | #+ |
---|
| 3 | # |
---|
[175] | 4 | # .. program:: project_profile.sh |
---|
[103] | 5 | # |
---|
[95] | 6 | # =================== |
---|
[175] | 7 | # project_profile.sh |
---|
[95] | 8 | # =================== |
---|
[82] | 9 | # |
---|
[93] | 10 | # SYNOPSIS |
---|
[82] | 11 | # ======== |
---|
| 12 | # |
---|
[325] | 13 | # On line usage: |
---|
[82] | 14 | # |
---|
[325] | 15 | # .. code-block:: sh |
---|
[82] | 16 | # |
---|
[325] | 17 | # ./project_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
[82] | 18 | # |
---|
[325] | 19 | # In :file:`${HOME}/.profile`, add the following line: |
---|
[82] | 20 | # |
---|
[325] | 21 | # .. code-block:: sh |
---|
| 22 | # |
---|
| 23 | # . project_profile.sh -d directory -i indir -o outdir -t tempdir |
---|
| 24 | # |
---|
[82] | 25 | # DESCRIPTION |
---|
| 26 | # =========== |
---|
| 27 | # |
---|
[352] | 28 | # .. option:: -d <directory> |
---|
| 29 | # .. option:: -i <indir> |
---|
| 30 | # .. option:: -o <outdir> |
---|
| 31 | # .. option:: -t <tempdir> |
---|
| 32 | # .. option:: -jv <jabref version> |
---|
| 33 | # .. option:: -j <jabref dir> |
---|
[108] | 34 | # |
---|
[93] | 35 | # define SUPERBIB environment |
---|
[82] | 36 | # |
---|
[175] | 37 | # ${PROJECT} is the base directory of tools. |
---|
[82] | 38 | # |
---|
[352] | 39 | # ${PROJECT_LOG} is the directory where log files will be written. |
---|
[82] | 40 | # |
---|
[175] | 41 | # ${PROJECT_ID} is the directory where input files must be. |
---|
[82] | 42 | # |
---|
[175] | 43 | # ${PROJECT_OD} is the directory where output files will be written. |
---|
[82] | 44 | # |
---|
| 45 | # MANPATH++ |
---|
| 46 | # |
---|
[347] | 47 | # :envvar:`${xmlcmd}` is set to either xml or xmlstarlet if one of these |
---|
| 48 | # is available. |
---|
| 49 | # |
---|
[82] | 50 | # EXAMPLES |
---|
| 51 | # ======== |
---|
| 52 | # |
---|
[352] | 53 | # For fplod, on cratos.locean-ipsl.upmc.fr: |
---|
[94] | 54 | # |
---|
[352] | 55 | # .. code-block:: bash |
---|
| 56 | # |
---|
| 57 | # cd /usr/home/fplod/src/superbib/superbib_ws/ |
---|
| 58 | # SUPERBIB=${HOME}/superbib_ws/ |
---|
| 59 | # export SUPERBIB |
---|
| 60 | # . ${SUPERBIB}/project_profile.sh \ |
---|
[214] | 61 | # -d ${SUPERBIB} \ |
---|
[82] | 62 | # -i /usr/temp/${LOGNAME}/superbib_d/ \ |
---|
| 63 | # -o /usr/temp/${LOGNAME}/superbib_d/ \ |
---|
[214] | 64 | # -t /usr/temp/${LOGNAME}/log/ \ |
---|
| 65 | # -jv 2.6 \ |
---|
| 66 | # -j /usr/home/incas/francoise/jabref-2.6_cratos/ |
---|
| 67 | # -b ++ |
---|
[82] | 68 | # |
---|
[94] | 69 | # TODO |
---|
| 70 | # ==== |
---|
[82] | 71 | # |
---|
| 72 | # ++ option bavarde |
---|
| 73 | # |
---|
[100] | 74 | # ++ machine dependant |
---|
| 75 | # |
---|
[352] | 76 | # ++ pas de MANPATH défini par défaut sur zeus |
---|
[82] | 77 | # |
---|
[352] | 78 | # réintégration de bibliolocean dans trunk ou projet bibliolocean à part |
---|
[214] | 79 | # |
---|
| 80 | # doc sur jabref dir bibtool |
---|
| 81 | # |
---|
[94] | 82 | # EVOLUTIONS |
---|
| 83 | # ========== |
---|
| 84 | # |
---|
[82] | 85 | # $Id$ |
---|
| 86 | # |
---|
[175] | 87 | # $URL$ |
---|
| 88 | # |
---|
[347] | 89 | # - fplod 20131010T113730Z callisto.locean-ipsl.upmc.fr (Linux) |
---|
| 90 | # |
---|
| 91 | # * dynamic xmlstarlet vs xml |
---|
| 92 | # |
---|
[321] | 93 | # - fplod 20130418T110932Z cratos.locean-ipsl.upmc.fr (Linux) |
---|
| 94 | # |
---|
| 95 | # * add PYTHONPATH (seems to be need be sphinx-apidoc + sphinx-build) |
---|
| 96 | # |
---|
[214] | 97 | # - fplod 20120629T120311Z cratos (Linux) |
---|
| 98 | # |
---|
| 99 | # * path with branches/bibliolocean/src |
---|
| 100 | # |
---|
[175] | 101 | # - fplod 20120405T085555Z cratos (Linux) |
---|
| 102 | # |
---|
| 103 | # * rename and replace SUPERBIB by PROJECT |
---|
| 104 | # |
---|
[101] | 105 | # - fplod 20100426T094821Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 106 | # |
---|
| 107 | # * improve PATH and MANPATH modification |
---|
| 108 | # |
---|
| 109 | # - fplod 20100423T144248Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 110 | # |
---|
| 111 | # * add error handling on mkdir |
---|
| 112 | # |
---|
[82] | 113 | # - fplod 2008-10-31T11:17:24Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 114 | # |
---|
| 115 | # * creation ++ pas encore en service |
---|
| 116 | # |
---|
| 117 | #- |
---|
| 118 | system=$(uname) |
---|
| 119 | case "${system}" in |
---|
[352] | 120 | AIX|IRIX64) |
---|
| 121 | echo " www : no specific posix checking" |
---|
| 122 | ;; |
---|
| 123 | *) |
---|
| 124 | set -o posix |
---|
| 125 | ;; |
---|
[82] | 126 | esac |
---|
[100] | 127 | unset system |
---|
[82] | 128 | # |
---|
[116] | 129 | set -u |
---|
| 130 | # |
---|
[82] | 131 | # as this script might be launch in .profile, command is forced. |
---|
[175] | 132 | command=project_profile.sh |
---|
[82] | 133 | # |
---|
[214] | 134 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir -jv jabrefversion -j jabrefdir -b bibtooldir" |
---|
[82] | 135 | # |
---|
[353] | 136 | pb=0 |
---|
[82] | 137 | # |
---|
[353] | 138 | minargcount=14 |
---|
| 139 | maxargcount=14 |
---|
| 140 | narg=${#} |
---|
| 141 | # |
---|
| 142 | if [ ${narg} -lt ${minargcount} ] |
---|
[82] | 143 | then |
---|
[353] | 144 | echo "eee : not enough arguments (${narg} vs ${minargcount})" |
---|
| 145 | echo "${usage}" |
---|
[352] | 146 | # nb : no exit because this file should be launched by login process |
---|
[353] | 147 | pb=1 |
---|
[82] | 148 | fi |
---|
[353] | 149 | unset minargcount |
---|
[82] | 150 | # |
---|
[353] | 151 | if [ ${narg} -gt ${maxargcount} ] |
---|
[82] | 152 | then |
---|
[353] | 153 | echo "eee : too many arguments (${narg} vs ${maxargcount})" |
---|
| 154 | echo "${usage}" |
---|
[352] | 155 | # nb : no exit because this file should be launched by login process |
---|
[353] | 156 | pb=1 |
---|
[82] | 157 | fi |
---|
[353] | 158 | unset maxargcount |
---|
| 159 | unset narg |
---|
[82] | 160 | # |
---|
[353] | 161 | if [ ${pb} -eq 0 ] |
---|
[82] | 162 | then |
---|
[353] | 163 | while [ ${#} -gt 0 ] |
---|
| 164 | do |
---|
| 165 | case ${1} in |
---|
| 166 | -d) |
---|
| 167 | # directory for application chosen by user |
---|
| 168 | # (see svn checkout command used) |
---|
| 169 | directory=${2} |
---|
| 170 | shift |
---|
| 171 | ;; |
---|
| 172 | -i) |
---|
| 173 | # directory for inputs chosen by user |
---|
| 174 | indir=${2} |
---|
| 175 | shift |
---|
| 176 | ;; |
---|
| 177 | -o) |
---|
| 178 | # directory for outputs chosen by user |
---|
| 179 | outdir=${2} |
---|
| 180 | shift |
---|
| 181 | ;; |
---|
| 182 | -t) |
---|
| 183 | # directory for temporary outputs chosen by user |
---|
| 184 | tempdir=${2} |
---|
| 185 | shift |
---|
| 186 | ;; |
---|
| 187 | -jv) |
---|
| 188 | jabrefversion=${2} |
---|
| 189 | shift |
---|
| 190 | ;; |
---|
| 191 | -j) |
---|
| 192 | jabrefdir=${2} |
---|
| 193 | shift |
---|
| 194 | ;; |
---|
| 195 | -b) |
---|
| 196 | bibtooldir=${2} |
---|
| 197 | shift |
---|
| 198 | ;; |
---|
| 199 | *) |
---|
| 200 | # other choice |
---|
| 201 | echo "eee : unknown option ${1}" |
---|
| 202 | echo "${usage}" |
---|
| 203 | # nb : no exit because this file should be launched by |
---|
| 204 | # login process |
---|
| 205 | ;; |
---|
| 206 | esac |
---|
| 207 | # next flag |
---|
| 208 | shift |
---|
| 209 | done |
---|
| 210 | unset usage |
---|
[82] | 211 | fi |
---|
| 212 | # |
---|
[353] | 213 | if [ ${pb} -eq 0 ] |
---|
[214] | 214 | then |
---|
[353] | 215 | # check for ${directory} |
---|
| 216 | if [ ! -d ${directory} ] |
---|
[352] | 217 | then |
---|
[353] | 218 | echo " eee : ${directory} not found" |
---|
[352] | 219 | # nb : no exit because this file should be launched by login process |
---|
[353] | 220 | fi |
---|
| 221 | # |
---|
| 222 | # check for permission on directory |
---|
| 223 | if [ ! -x ${directory} ] |
---|
| 224 | then |
---|
| 225 | echo " eee : ${directory} not reachable" |
---|
| 226 | # nb : no exit because this file should be launched by login process |
---|
| 227 | fi |
---|
| 228 | # |
---|
| 229 | PROJECT=${directory} |
---|
| 230 | export PROJECT |
---|
| 231 | # |
---|
| 232 | # add PROJECT tools to PATH |
---|
| 233 | # if not already done |
---|
| 234 | suppath=$(echo ${PROJECT} | tr -s "/") |
---|
| 235 | echo ${PATH} | grep -q "${suppath}:" |
---|
| 236 | test_path=${?} |
---|
| 237 | if [ ${test_path} -ne 0 ] |
---|
| 238 | then |
---|
| 239 | PATH=${suppath}:${PATH} |
---|
| 240 | export PATH |
---|
[352] | 241 | else |
---|
[353] | 242 | # option bavarde oui/non pas encore implantée ++ |
---|
| 243 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
[352] | 244 | fi |
---|
[353] | 245 | unset test_path |
---|
| 246 | unset suppath |
---|
| 247 | # |
---|
| 248 | suppath=$(echo ${PROJECT}/../branches/bibliolocean/src | tr -s "/") |
---|
| 249 | echo ${PATH} | grep -q "${suppath}:" |
---|
| 250 | test_path=${?} |
---|
| 251 | if [ ${test_path} -ne 0 ] |
---|
| 252 | then |
---|
| 253 | PATH=${suppath}:${PATH} |
---|
| 254 | export PATH |
---|
| 255 | else |
---|
| 256 | # option bavarde oui/non pas encore implantée ++ |
---|
| 257 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
| 258 | fi |
---|
| 259 | unset test_path |
---|
| 260 | # |
---|
| 261 | # add PROJECT tools to PYTHONPATH |
---|
| 262 | # if not already done |
---|
| 263 | suppath=$(echo ${PROJECT}/aeres/scripts/ | tr -s "/") |
---|
| 264 | echo ${PYTHONPATH} | grep -q "${suppath}:" |
---|
| 265 | test_path=${?} |
---|
| 266 | if [ ${test_path} -ne 0 ] |
---|
| 267 | then |
---|
| 268 | PYTHONPATH=${suppath}:${PYTHONPATH} |
---|
| 269 | export PYTHONPATH |
---|
| 270 | else |
---|
| 271 | # option bavarde oui/non pas encore implantée ++ |
---|
| 272 | echo "${command} : iii : ${suppath} already in \${PYTHONPATH}" |
---|
| 273 | fi |
---|
| 274 | unset test_path |
---|
| 275 | unset suppath |
---|
| 276 | # |
---|
| 277 | # add PROJECT tools to PYTHONPATH |
---|
| 278 | # if not already done |
---|
| 279 | suppath=$(echo ${PROJECT}/| tr -s "/") |
---|
| 280 | echo ${PYTHONPATH} | grep -q "${suppath}:" |
---|
| 281 | test_path=${?} |
---|
| 282 | if [ ${test_path} -ne 0 ] |
---|
| 283 | then |
---|
| 284 | PYTHONPATH=${suppath}:${PYTHONPATH} |
---|
| 285 | export PYTHONPATH |
---|
| 286 | else |
---|
| 287 | # option bavarde oui/non pas encore implantée ++ |
---|
| 288 | echo "${command} : iii : ${suppath} already in \${PYTHONPATH}" |
---|
| 289 | fi |
---|
| 290 | unset test_path |
---|
| 291 | unset suppath |
---|
| 292 | # |
---|
| 293 | # add PROJECT manuals to MANPATH |
---|
| 294 | # if not already done |
---|
| 295 | suppath=$(echo ${PROJECT}/doc/manuals/man | tr -s "/") |
---|
| 296 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
| 297 | test_manpath=${?} |
---|
| 298 | if [ ${test_manpath} -ne 0 ] |
---|
| 299 | then |
---|
| 300 | MANPATH=${suppath}:${MANPATH} |
---|
| 301 | export MANPATH |
---|
| 302 | else |
---|
| 303 | # option bavarde oui/non pas encore implantée ++ |
---|
| 304 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
| 305 | fi |
---|
| 306 | unset test_manpath |
---|
| 307 | unset suppath |
---|
| 308 | # |
---|
| 309 | PROJECT_LOG=${tempdir} |
---|
| 310 | export PROJECT_LOG |
---|
| 311 | unset tempdir |
---|
| 312 | if [ ! -d ${PROJECT_LOG} ] |
---|
| 313 | then |
---|
| 314 | mkdir -p ${PROJECT_LOG} |
---|
| 315 | status=${?} |
---|
| 316 | if [ ${status} -ne 0 ] |
---|
| 317 | then |
---|
| 318 | echo "${command} : eee : can not create \${PROJECT_LOG}" |
---|
| 319 | # nb : no exit because this file should be launched by login process |
---|
| 320 | else |
---|
| 321 | echo "${command} : iii : creation of \${PROJECT_LOG}" |
---|
| 322 | fi |
---|
| 323 | unset status |
---|
| 324 | fi |
---|
| 325 | # check for permission on PROJECT_LOG |
---|
| 326 | if [ ! -x ${PROJECT_LOG} ] |
---|
| 327 | then |
---|
| 328 | echo " eee : ${PROJECT_LOG} not reachable" |
---|
| 329 | # nb : no exit because this file should be launched by login process |
---|
| 330 | fi |
---|
| 331 | # |
---|
| 332 | # check for permission on PROJECT_LOG |
---|
| 333 | if [ ! -w ${PROJECT_LOG} ] |
---|
| 334 | then |
---|
| 335 | echo " eee : ${PROJECT_LOG} not writable" |
---|
| 336 | # nb : no exit because this file shouldreachable be launched |
---|
| 337 | # by login process |
---|
| 338 | fi |
---|
| 339 | # |
---|
| 340 | EDITOR=vi |
---|
| 341 | export EDITOR |
---|
| 342 | # |
---|
| 343 | # io directories |
---|
| 344 | PROJECT_ID=${indir} |
---|
| 345 | export PROJECT_ID |
---|
| 346 | unset indir |
---|
| 347 | if [ ! -d ${PROJECT_ID} ] |
---|
| 348 | then |
---|
| 349 | mkdir -p ${PROJECT_ID} |
---|
| 350 | echo "${command} : iii : creation of \${PROJECT_ID}" |
---|
| 351 | fi |
---|
| 352 | # check for permission on PROJECT_ID |
---|
| 353 | if [ ! -x ${PROJECT_ID} ] |
---|
| 354 | then |
---|
| 355 | echo " eee : ${PROJECT_ID} not reachable" |
---|
| 356 | # nb : no exit because this file should be launched by login process |
---|
| 357 | fi |
---|
| 358 | # |
---|
| 359 | PROJECT_OD=${outdir} |
---|
| 360 | export PROJECT_OD |
---|
| 361 | unset outdir |
---|
| 362 | if [ ! -d ${PROJECT_OD} ] |
---|
| 363 | then |
---|
| 364 | mkdir -p ${PROJECT_OD} |
---|
| 365 | echo "${command} : iii : creation of \${PROJECT_OD}" |
---|
| 366 | fi |
---|
| 367 | # check for permission on PROJECT_OD |
---|
| 368 | if [ ! -x ${PROJECT_OD} ] |
---|
| 369 | then |
---|
| 370 | echo " eee : ${PROJECT_OD} not reachable" |
---|
| 371 | # nb : no exit because this file should be launched by login process |
---|
| 372 | fi |
---|
| 373 | if [ ! -w ${PROJECT_OD} ] |
---|
| 374 | then |
---|
| 375 | echo " eee : ${PROJECT_OD} not writable" |
---|
| 376 | # nb : no exit because this file should be launched by login process |
---|
| 377 | fi |
---|
| 378 | # |
---|
| 379 | JABREF_DIR=${jabrefdir} |
---|
| 380 | export JABREF_DIR |
---|
| 381 | unset jabref_dir |
---|
| 382 | JABREF_VERSION=${jabrefversion} |
---|
| 383 | export JABREF_VERSION |
---|
| 384 | unset jabrefversion |
---|
| 385 | # |
---|
| 386 | BIBTOOL_DIR=${bibtooldir} |
---|
| 387 | export BIBTOOL_DIR |
---|
| 388 | unset bibtooldir |
---|
| 389 | PATH=${BIBTOOL_DIR}:${PATH} |
---|
| 390 | export PATH |
---|
| 391 | # |
---|
| 392 | # test if which xml is available xml or xmlstarlet |
---|
| 393 | tool=xml |
---|
[347] | 394 | type ${tool} 1> /dev/null 2>&1 |
---|
| 395 | status=${?} |
---|
| 396 | if [ ${status} -ne 0 ] |
---|
| 397 | then |
---|
[353] | 398 | #echo "${command} : www : tool ${tool} not found" |
---|
| 399 | tool=xmlstarlet |
---|
| 400 | type ${tool} 1> /dev/null 2>&1 |
---|
| 401 | status=${?} |
---|
| 402 | if [ ${status} -ne 0 ] |
---|
| 403 | then |
---|
| 404 | echo "${command} : eee : tool ${tool} not found" |
---|
| 405 | else |
---|
| 406 | xmlcmd=xmlstarlet |
---|
| 407 | fi |
---|
[347] | 408 | else |
---|
[353] | 409 | xmlcmd=xml |
---|
[347] | 410 | fi |
---|
[353] | 411 | export xmlcmd |
---|
| 412 | # |
---|
| 413 | unset status |
---|
| 414 | unset tool |
---|
[347] | 415 | fi |
---|
[353] | 416 | unset pb |
---|
[82] | 417 | # end |
---|
[100] | 418 | unset command |
---|
[82] | 419 | # nb : no exit because this file should be launched by login process |
---|