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