source: trunk/before.sh

Last change on this file was 353, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo

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