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