source: trunk/before.sh @ 110

Last change on this file since 110 was 109, checked in by pinsard, 14 years ago

usage of program directive

  • Property svn:keywords set to Id
File size: 4.5 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# ::
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 deployement) 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#
46# EXAMPLES
47# ========
48#
49# TODO
50# ====
51#
52# il faudrait autoriser plusieurs fois :option:`-l` et utiliser un tableau de
53# langues pour créer autant de répertoires qu'il faut.
54#
55# EVOLUTIONS
56# ==========
57#
58# $Id$
59#
60# - fplod 2008-09-16T15:19:59Z aedon.locean-ipsl.upmc.fr (Darwin)
61#
62#   * comments in ReStructured Text
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#
82system=$(uname)
83case "${system}" in
84   AIX|IRIX64)
85      echo " www : no specific posix checking"
86   ;;
87   *)
88      set -o posix
89   ;;
90esac
91unset system
92#
93command=$(basename ${0})
94log_date=$(date -u +"%Y%m%dT%H%M%SZ")
95log=/tmp/$(basename ${command} .sh).log.${log_date}
96#
97usage=" Usage : ${command} -p product -s dirsrc -w dirwww -l lang -mono|-multi -m nmany"
98#
99minargcount=9
100#echo " narg ${#}"
101if [ ${#} -lt ${minargcount} ]
102then
103   echo "eee : not enought arguments (${#} vs ${minargcount})"
104   echo "${usage}"
105   exit 1
106fi
107unset minargcount
108#
109# default
110nmany=0
111#
112set +u
113while [ ! -z "${1}" ]
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#
148set -u
149#
150# destruction of previous installation
151/bin/rm -r ${dirwww}/ 2> /dev/null
152#
153# building of directories
154if [ -d ${dirsrc}/images/ ]
155then
156   mkdir -p ${dirwww}/images/
157   if [ ${nmany} -gt 0 ]
158   then
159      mkdir -p ${dirwww}/${lang}/images/ # ++ parce que un niveau de plus que d'haibitude dans les chunck
160   fi
161fi
162#
163if [ -d ${dirsrc}/documents/ ]
164then
165   mkdir -p ${dirwww}/documents/
166fi
167#
168list_php="${dirsrc}/phpversion.php ${dirsrc}/server.php ${dirsrc}/timestamp.php"
169ls ${list_php} 1> /dev/null 2> /dev/null
170exist_php=${?}
171if [ ${exist_php} -eq 0 ]
172then
173   mkdir -p ${dirwww}/php/
174fi
175#
176if [ ${monolingual} -eq 0 ]
177then
178   mkdir -p ${dirwww}/${lang}/one/
179   if [ ${nmany} -gt 0 ]
180   then
181      mkdir -p ${dirwww}/${lang}/many/
182      imany=1
183      while [ ${imany} -le ${nmany} ]
184      do
185         mkdir -p ${dirwww}/${lang}/many/${product}$(printf "%2.2d" ${imany})/
186         imany=$(( ${imany} + 1 ))
187      done
188   fi
189else
190   mkdir -p ${dirwww}/one/
191   if [ ${nmany} -gt 0 ]
192   then
193      mkdir -p ${dirwww}/many/
194      imany=1
195      while [ ${imany} -le ${nmany} ]
196      do
197         mkdir -p ${dirwww}/many/${product}$(printf "%2.2d" ${imany})/
198      done
199   fi
200fi
201#
202if [ ${exist_php} -eq 0 ]
203then
204   for file_php in ${list_php}
205   do
206      cp ${file_php} ${dirwww}/php/
207   done
208fi
209unset exist_php
210#
211if [ -d ${dirsrc}/images/ ]
212then
213   cp ${dirsrc}/images/* ${dirwww}/images/
214   if [ ${nmany} -gt 0 ]
215   then
216      cp ${dirsrc}/images/* ${dirwww}/${lang}/images/ # ++ parce que un niveau de plus que d'habitude dans les chunck
217   fi
218fi
219#
220# copy of documents
221if [ -d ${dirsrc}/documents/ ]
222then
223   cp ${dirsrc}/documents/* ${dirwww}/documents/
224fi
225#
226# copy of CSS
227ls ${dirsrc}/*.css 1> /dev/null 2> /dev/null
228exist_css=${?}
229if [ ${exist_css} -eq 0 ]
230then
231   cp ${dirsrc}/*.css ${dirwww}/
232fi
233unset exist_css
234if [ ${nmany} -gt 0 ]
235then
236   cp ${dirsrc}/*.css ${dirwww}/${lang}/ # ++ parce que un niveau de plus que d'haibitude dans les chunck
237fi
238#
239# modification of directory time in order to trigger the generation of HTML
240# files
241find ${dirwww}/ -type d -exec touch -t 199912310000 {} \;
242#
243# end
244exit 0
Note: See TracBrowser for help on using the repository browser.