[2] | 1 | #! /bin/sh |
---|
[80] | 2 | #+ |
---|
[2] | 3 | # |
---|
[109] | 4 | # .. program:: before.sh |
---|
[103] | 5 | # |
---|
[95] | 6 | # ========= |
---|
| 7 | # before.sh |
---|
| 8 | # ========= |
---|
[75] | 9 | # |
---|
[95] | 10 | # -------------------------------- |
---|
| 11 | # preparation of results directory |
---|
| 12 | # -------------------------------- |
---|
[75] | 13 | # |
---|
[93] | 14 | # SYNOPSIS |
---|
[75] | 15 | # ======== |
---|
| 16 | # |
---|
| 17 | # :: |
---|
| 18 | # |
---|
| 19 | # $ before.sh -p product -s dirsrc -w dirwww -l lang -mono|-multi -m nmany |
---|
| 20 | # |
---|
| 21 | # DESCRIPTION |
---|
| 22 | # =========== |
---|
| 23 | # |
---|
[23] | 24 | # preparation of temporary (before deployement) of superbib results directory |
---|
[75] | 25 | # - tree; |
---|
| 26 | # - copy of constant images copie des images; |
---|
| 27 | # - copy of CSS style sheet; |
---|
| 28 | # - etc. |
---|
[2] | 29 | # |
---|
[108] | 30 | # .. option:: -s <source directory> |
---|
| 31 | # .. option:: -w <output directory> |
---|
| 32 | # .. option:: -l <language> |
---|
| 33 | # .. option:: -mono |
---|
[83] | 34 | # |
---|
[108] | 35 | # +todo+ |
---|
| 36 | # |
---|
| 37 | # .. option:: -multi |
---|
| 38 | # |
---|
| 39 | # +todo+ |
---|
| 40 | # |
---|
| 41 | # .. option:: -m |
---|
| 42 | # |
---|
| 43 | # +todo+ |
---|
| 44 | # |
---|
| 45 | # |
---|
[75] | 46 | # EXAMPLES |
---|
| 47 | # ======== |
---|
| 48 | # |
---|
[87] | 49 | # TODO |
---|
| 50 | # ==== |
---|
| 51 | # |
---|
[108] | 52 | # il faudrait autoriser plusieurs fois :option:`-l` et utiliser un tableau de |
---|
[87] | 53 | # langues pour créer autant de répertoires qu'il faut. |
---|
[101] | 54 | # |
---|
[75] | 55 | # EVOLUTIONS |
---|
| 56 | # ========== |
---|
| 57 | # |
---|
[23] | 58 | # $Id$ |
---|
[2] | 59 | # |
---|
[75] | 60 | # - fplod 2008-09-16T15:19:59Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
[2] | 61 | # |
---|
[82] | 62 | # * comments in ReStructured Text |
---|
[75] | 63 | # |
---|
| 64 | # - fplod 2008-06-16T09:48:22Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 65 | # |
---|
| 66 | # * add copy of documents |
---|
| 67 | # |
---|
| 68 | # - fplod 2007-10-17T12:22:57Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 69 | # |
---|
| 70 | # * parametrisation of number of "many" presentation |
---|
| 71 | # |
---|
| 72 | # - fplod 2007-09-28T08:43:10Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 73 | # |
---|
| 74 | # * parametrisation and translation |
---|
| 75 | # |
---|
| 76 | # - fplod 2007-03-30T09:55:49Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 77 | # |
---|
| 78 | # * création |
---|
| 79 | # |
---|
| 80 | #- |
---|
| 81 | # |
---|
| 82 | system=$(uname) |
---|
| 83 | case "${system}" in |
---|
[100] | 84 | AIX|IRIX64) |
---|
| 85 | echo " www : no specific posix checking" |
---|
| 86 | ;; |
---|
| 87 | *) |
---|
| 88 | set -o posix |
---|
| 89 | ;; |
---|
[75] | 90 | esac |
---|
[100] | 91 | unset system |
---|
[75] | 92 | # |
---|
[116] | 93 | set -u |
---|
| 94 | # |
---|
[79] | 95 | command=$(basename ${0}) |
---|
[93] | 96 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
| 97 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
[2] | 98 | # |
---|
[29] | 99 | usage=" Usage : ${command} -p product -s dirsrc -w dirwww -l lang -mono|-multi -m nmany" |
---|
[23] | 100 | # |
---|
| 101 | minargcount=9 |
---|
[25] | 102 | #echo " narg ${#}" |
---|
[23] | 103 | if [ ${#} -lt ${minargcount} ] |
---|
| 104 | then |
---|
[100] | 105 | echo "eee : not enought arguments (${#} vs ${minargcount})" |
---|
| 106 | echo "${usage}" |
---|
| 107 | exit 1 |
---|
[23] | 108 | fi |
---|
[100] | 109 | unset minargcount |
---|
[23] | 110 | # |
---|
[29] | 111 | # default |
---|
[52] | 112 | nmany=0 |
---|
[29] | 113 | # |
---|
[116] | 114 | while [ ${#} -gt 0 ] |
---|
[23] | 115 | do |
---|
[100] | 116 | case ${1} in |
---|
[101] | 117 | -p) |
---|
[100] | 118 | product=${2} |
---|
| 119 | shift |
---|
| 120 | ;; |
---|
[101] | 121 | -s) |
---|
[100] | 122 | dirsrc=${2} |
---|
| 123 | shift |
---|
| 124 | ;; |
---|
[101] | 125 | -w) |
---|
[100] | 126 | dirwww=${2} |
---|
| 127 | shift |
---|
| 128 | ;; |
---|
[101] | 129 | -l) |
---|
[100] | 130 | lang=${2} |
---|
| 131 | shift |
---|
| 132 | ;; |
---|
[101] | 133 | -mono) |
---|
[100] | 134 | monolingual=1 |
---|
| 135 | ;; |
---|
[101] | 136 | -multi) |
---|
[100] | 137 | monolingual=0 |
---|
| 138 | ;; |
---|
| 139 | -m) |
---|
| 140 | nmany=${2} |
---|
| 141 | shift |
---|
| 142 | ;; |
---|
| 143 | esac |
---|
[101] | 144 | # next flag |
---|
| 145 | shift |
---|
[23] | 146 | done |
---|
[100] | 147 | unset usage |
---|
[23] | 148 | # |
---|
[2] | 149 | # destruction of previous installation |
---|
[23] | 150 | /bin/rm -r ${dirwww}/ 2> /dev/null |
---|
[2] | 151 | # |
---|
| 152 | # building of directories |
---|
[26] | 153 | if [ -d ${dirsrc}/images/ ] |
---|
| 154 | then |
---|
[100] | 155 | mkdir -p ${dirwww}/images/ |
---|
| 156 | if [ ${nmany} -gt 0 ] |
---|
| 157 | then |
---|
| 158 | mkdir -p ${dirwww}/${lang}/images/ # ++ parce que un niveau de plus que d'haibitude dans les chunck |
---|
| 159 | fi |
---|
[26] | 160 | fi |
---|
| 161 | # |
---|
[74] | 162 | if [ -d ${dirsrc}/documents/ ] |
---|
| 163 | then |
---|
[100] | 164 | mkdir -p ${dirwww}/documents/ |
---|
[74] | 165 | fi |
---|
| 166 | # |
---|
[26] | 167 | list_php="${dirsrc}/phpversion.php ${dirsrc}/server.php ${dirsrc}/timestamp.php" |
---|
| 168 | ls ${list_php} 1> /dev/null 2> /dev/null |
---|
| 169 | exist_php=${?} |
---|
| 170 | if [ ${exist_php} -eq 0 ] |
---|
| 171 | then |
---|
[100] | 172 | mkdir -p ${dirwww}/php/ |
---|
[26] | 173 | fi |
---|
| 174 | # |
---|
[52] | 175 | if [ ${monolingual} -eq 0 ] |
---|
[23] | 176 | then |
---|
[100] | 177 | mkdir -p ${dirwww}/${lang}/one/ |
---|
| 178 | if [ ${nmany} -gt 0 ] |
---|
| 179 | then |
---|
| 180 | mkdir -p ${dirwww}/${lang}/many/ |
---|
| 181 | imany=1 |
---|
| 182 | while [ ${imany} -le ${nmany} ] |
---|
| 183 | do |
---|
| 184 | mkdir -p ${dirwww}/${lang}/many/${product}$(printf "%2.2d" ${imany})/ |
---|
| 185 | imany=$(( ${imany} + 1 )) |
---|
| 186 | done |
---|
| 187 | fi |
---|
[23] | 188 | else |
---|
[100] | 189 | mkdir -p ${dirwww}/one/ |
---|
| 190 | if [ ${nmany} -gt 0 ] |
---|
| 191 | then |
---|
| 192 | mkdir -p ${dirwww}/many/ |
---|
| 193 | imany=1 |
---|
| 194 | while [ ${imany} -le ${nmany} ] |
---|
| 195 | do |
---|
| 196 | mkdir -p ${dirwww}/many/${product}$(printf "%2.2d" ${imany})/ |
---|
| 197 | done |
---|
| 198 | fi |
---|
[23] | 199 | fi |
---|
[2] | 200 | # |
---|
[26] | 201 | if [ ${exist_php} -eq 0 ] |
---|
| 202 | then |
---|
[100] | 203 | for file_php in ${list_php} |
---|
| 204 | do |
---|
| 205 | cp ${file_php} ${dirwww}/php/ |
---|
| 206 | done |
---|
[26] | 207 | fi |
---|
[100] | 208 | unset exist_php |
---|
[2] | 209 | # |
---|
[74] | 210 | if [ -d ${dirsrc}/images/ ] |
---|
[23] | 211 | then |
---|
[100] | 212 | cp ${dirsrc}/images/* ${dirwww}/images/ |
---|
| 213 | if [ ${nmany} -gt 0 ] |
---|
| 214 | then |
---|
| 215 | cp ${dirsrc}/images/* ${dirwww}/${lang}/images/ # ++ parce que un niveau de plus que d'habitude dans les chunck |
---|
| 216 | fi |
---|
[23] | 217 | fi |
---|
[2] | 218 | # |
---|
[74] | 219 | # copy of documents |
---|
[75] | 220 | if [ -d ${dirsrc}/documents/ ] |
---|
[74] | 221 | then |
---|
[100] | 222 | cp ${dirsrc}/documents/* ${dirwww}/documents/ |
---|
[74] | 223 | fi |
---|
| 224 | # |
---|
[2] | 225 | # copy of CSS |
---|
[74] | 226 | ls ${dirsrc}/*.css 1> /dev/null 2> /dev/null |
---|
[51] | 227 | exist_css=${?} |
---|
| 228 | if [ ${exist_css} -eq 0 ] |
---|
| 229 | then |
---|
[100] | 230 | cp ${dirsrc}/*.css ${dirwww}/ |
---|
[51] | 231 | fi |
---|
[100] | 232 | unset exist_css |
---|
[52] | 233 | if [ ${nmany} -gt 0 ] |
---|
[29] | 234 | then |
---|
[100] | 235 | cp ${dirsrc}/*.css ${dirwww}/${lang}/ # ++ parce que un niveau de plus que d'haibitude dans les chunck |
---|
[29] | 236 | fi |
---|
[2] | 237 | # |
---|
[23] | 238 | # modification of directory time in order to trigger the generation of HTML |
---|
| 239 | # files |
---|
| 240 | find ${dirwww}/ -type d -exec touch -t 199912310000 {} \; |
---|
[2] | 241 | # |
---|
[23] | 242 | # end |
---|
[2] | 243 | exit 0 |
---|