[82] | 1 | #! /bin/sh |
---|
| 2 | #+ |
---|
| 3 | # |
---|
[103] | 4 | # .. _superbib_profile.sh: |
---|
| 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 | # |
---|
| 97 | # as this script might be launch in .profile, command is forced. |
---|
| 98 | command=superbib_profile.sh |
---|
| 99 | # |
---|
| 100 | usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" |
---|
| 101 | # |
---|
[102] | 102 | set +u |
---|
| 103 | while [ ! -z "${1}" ] |
---|
[82] | 104 | do |
---|
[100] | 105 | case ${1} in |
---|
[101] | 106 | -d) |
---|
| 107 | # directory for application choosen by user (see svn checkout command used) |
---|
[100] | 108 | directory=${2} |
---|
| 109 | shift |
---|
| 110 | ;; |
---|
[101] | 111 | -i) |
---|
| 112 | # directory for inputs choosen by user |
---|
[100] | 113 | indir=${2} |
---|
| 114 | shift |
---|
| 115 | ;; |
---|
[101] | 116 | -o) |
---|
| 117 | # directory for outputs choosen by user |
---|
[100] | 118 | outdir=${2} |
---|
| 119 | shift |
---|
| 120 | ;; |
---|
[101] | 121 | -t) |
---|
| 122 | # directory for temporary outputs choosen by user |
---|
[100] | 123 | tempdir=${2} |
---|
| 124 | shift |
---|
| 125 | ;; |
---|
[101] | 126 | *) |
---|
| 127 | # other choice |
---|
[100] | 128 | echo "eee : unknown option ${1}" |
---|
| 129 | echo "${usage}" |
---|
| 130 | # nb : no exit because this file should be launched by login process |
---|
| 131 | ;; |
---|
| 132 | esac |
---|
[101] | 133 | # next flag |
---|
| 134 | shift |
---|
[82] | 135 | done |
---|
[100] | 136 | unset usage |
---|
[82] | 137 | # |
---|
| 138 | # check for ${directory} |
---|
| 139 | if [ ! -d ${directory} ] |
---|
| 140 | then |
---|
[100] | 141 | echo " eee : ${directory} not found" |
---|
| 142 | # nb : no exit because this file should be launched by login process |
---|
[82] | 143 | fi |
---|
| 144 | # |
---|
| 145 | # check for permission on directory |
---|
| 146 | if [ ! -x ${directory} ] |
---|
| 147 | then |
---|
[100] | 148 | echo " eee : ${directory} not reachable" |
---|
| 149 | # nb : no exit because this file should be launched by login process |
---|
[82] | 150 | fi |
---|
| 151 | # |
---|
| 152 | SUPERBIB=${directory} |
---|
| 153 | export SUPERBIB |
---|
| 154 | # |
---|
| 155 | # add SUPERBIB tools to PATH |
---|
| 156 | # if not already done |
---|
[101] | 157 | suppath=$(echo ${SUPERBIB} | tr -s "/") |
---|
| 158 | echo ${PATH} | grep -q "${suppath}:" |
---|
[82] | 159 | test_path=${?} |
---|
| 160 | if [ ${test_path} -ne 0 ] |
---|
| 161 | then |
---|
[101] | 162 | PATH=${suppath}:${PATH} |
---|
[82] | 163 | export PATH |
---|
| 164 | else |
---|
| 165 | # option bavarde oui/non pas encore implantée ++ |
---|
[101] | 166 | echo "${command} : iii : ${suppath} already in \${PATH}" |
---|
[82] | 167 | fi |
---|
[100] | 168 | unset test_path |
---|
[101] | 169 | unset suppath |
---|
[82] | 170 | # |
---|
| 171 | # add SUPERBIB manuals to MANPATH |
---|
| 172 | # if not already done |
---|
[101] | 173 | suppath=$(echo ${SUPERBIB}/doc/manuals/man | tr -s "/") |
---|
| 174 | echo ${MANPATH} | grep -q "${suppath}:" |
---|
[82] | 175 | test_manpath=${?} |
---|
| 176 | if [ ${test_manpath} -ne 0 ] |
---|
| 177 | then |
---|
[101] | 178 | MANPATH=${suppath}:${MANPATH} |
---|
[82] | 179 | export MANPATH |
---|
| 180 | else |
---|
| 181 | # option bavarde oui/non pas encore implantée ++ |
---|
[101] | 182 | echo "${command} : iii : ${suppath} already in \${MANPATH}" |
---|
[82] | 183 | fi |
---|
[100] | 184 | unset test_manpath |
---|
[101] | 185 | unset suppath |
---|
[82] | 186 | # |
---|
[83] | 187 | SUPERBIB_LOG=${tempdir} |
---|
| 188 | export SUPERBIB_LOG |
---|
[100] | 189 | unset tempdir |
---|
| 190 | if [ ! -d ${SUPERBIB_LOG} ] |
---|
[82] | 191 | then |
---|
[100] | 192 | mkdir -p ${SUPERBIB_LOG} |
---|
[101] | 193 | status=${?} |
---|
| 194 | if [ ${status} -ne 0 ] |
---|
| 195 | then |
---|
| 196 | echo "${command} : eee : can not create \${SUPERBIB_LOG}" |
---|
| 197 | # nb : no exit because this file should be launched by login process |
---|
| 198 | else |
---|
| 199 | echo "${command} : iii : creation of \${SUPERBIB_LOG}" |
---|
| 200 | fi |
---|
| 201 | unset status |
---|
[100] | 202 | fi |
---|
[83] | 203 | # check for permission on SUPERBIB_LOG |
---|
| 204 | if [ ! -x ${SUPERBIB_LOG} ] |
---|
[82] | 205 | then |
---|
[101] | 206 | echo " eee : ${SUPERBIB_LOG} not reachable" |
---|
| 207 | # nb : no exit because this file should be launched by login process |
---|
[82] | 208 | fi |
---|
| 209 | # |
---|
[83] | 210 | # check for permission on SUPERBIB_LOG |
---|
| 211 | if [ ! -w ${SUPERBIB_LOG} ] |
---|
[82] | 212 | then |
---|
[100] | 213 | echo " eee : ${SUPERBIB_LOG} not writable" |
---|
| 214 | # nb : no exit because this file shouldreachable be launched by login process |
---|
[82] | 215 | fi |
---|
| 216 | # |
---|
| 217 | EDITOR=vi |
---|
| 218 | export EDITOR |
---|
| 219 | # |
---|
| 220 | # io directories |
---|
| 221 | SUPERBIB_ID=${indir} |
---|
| 222 | export SUPERBIB_ID |
---|
[100] | 223 | unset indir |
---|
| 224 | if [ ! -d ${SUPERBIB_ID} ] |
---|
[82] | 225 | then |
---|
[100] | 226 | mkdir -p ${SUPERBIB_ID} |
---|
| 227 | echo "${command} : iii : creation of \${SUPERBIB_ID}" |
---|
| 228 | fi |
---|
[82] | 229 | # check for permission on SUPERBIB_ID |
---|
| 230 | if [ ! -x ${SUPERBIB_ID} ] |
---|
| 231 | then |
---|
[100] | 232 | echo " eee : ${SUPERBIB_ID} not reachable" |
---|
| 233 | # nb : no exit because this file should be launched by login process |
---|
[82] | 234 | fi |
---|
| 235 | # |
---|
| 236 | SUPERBIB_OD=${outdir} |
---|
| 237 | export SUPERBIB_OD |
---|
[100] | 238 | unset outdir |
---|
[82] | 239 | if [ ! -d ${SUPERBIB_OD} ] |
---|
| 240 | then |
---|
[100] | 241 | mkdir -p ${SUPERBIB_OD} |
---|
| 242 | echo "${command} : iii : creation of \${SUPERBIB_OD}" |
---|
[82] | 243 | fi |
---|
| 244 | # check for permission on SUPERBIB_OD |
---|
| 245 | if [ ! -x ${SUPERBIB_OD} ] |
---|
| 246 | then |
---|
[100] | 247 | echo " eee : ${SUPERBIB_OD} not reachable" |
---|
| 248 | # nb : no exit because this file should be launched by login process |
---|
[82] | 249 | fi |
---|
| 250 | if [ ! -w ${SUPERBIB_OD} ] |
---|
| 251 | then |
---|
[100] | 252 | echo " eee : ${SUPERBIB_OD} not writable" |
---|
| 253 | # nb : no exit because this file should be launched by login process |
---|
[82] | 254 | fi |
---|
| 255 | # |
---|
| 256 | # end |
---|
[100] | 257 | unset command |
---|
[82] | 258 | # nb : no exit because this file should be launched by login process |
---|