source: trunk/before.sh @ 140

Last change on this file since 140 was 116, checked in by pinsard, 13 years ago

Consolidation of shell scripts

  • 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#
93set -u
94#
95command=$(basename ${0})
96log_date=$(date -u +"%Y%m%dT%H%M%SZ")
97log=/tmp/$(basename ${command} .sh).log.${log_date}
98#
99usage=" Usage : ${command} -p product -s dirsrc -w dirwww -l lang -mono|-multi -m nmany"
100#
101minargcount=9
102#echo " narg ${#}"
103if [ ${#} -lt ${minargcount} ]
104then
105   echo "eee : not enought arguments (${#} vs ${minargcount})"
106   echo "${usage}"
107   exit 1
108fi
109unset minargcount
110#
111# default
112nmany=0
113#
114while [ ${#} -gt 0 ]
115do
116   case ${1} in
117      -p)
118         product=${2}
119         shift
120      ;;
121      -s)
122         dirsrc=${2}
123         shift
124      ;;
125      -w)
126         dirwww=${2}
127         shift
128      ;;
129      -l)
130         lang=${2}
131         shift
132      ;;
133      -mono)
134         monolingual=1
135       ;;
136      -multi)
137         monolingual=0
138      ;;
139      -m)
140         nmany=${2}
141         shift
142      ;;
143   esac
144   # next flag
145   shift
146done
147unset usage
148#
149# destruction of previous installation
150/bin/rm -r ${dirwww}/ 2> /dev/null
151#
152# building of directories
153if [ -d ${dirsrc}/images/ ]
154then
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
160fi
161#
162if [ -d ${dirsrc}/documents/ ]
163then
164   mkdir -p ${dirwww}/documents/
165fi
166#
167list_php="${dirsrc}/phpversion.php ${dirsrc}/server.php ${dirsrc}/timestamp.php"
168ls ${list_php} 1> /dev/null 2> /dev/null
169exist_php=${?}
170if [ ${exist_php} -eq 0 ]
171then
172   mkdir -p ${dirwww}/php/
173fi
174#
175if [ ${monolingual} -eq 0 ]
176then
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
188else
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
199fi
200#
201if [ ${exist_php} -eq 0 ]
202then
203   for file_php in ${list_php}
204   do
205      cp ${file_php} ${dirwww}/php/
206   done
207fi
208unset exist_php
209#
210if [ -d ${dirsrc}/images/ ]
211then
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
217fi
218#
219# copy of documents
220if [ -d ${dirsrc}/documents/ ]
221then
222   cp ${dirsrc}/documents/* ${dirwww}/documents/
223fi
224#
225# copy of CSS
226ls ${dirsrc}/*.css 1> /dev/null 2> /dev/null
227exist_css=${?}
228if [ ${exist_css} -eq 0 ]
229then
230   cp ${dirsrc}/*.css ${dirwww}/
231fi
232unset exist_css
233if [ ${nmany} -gt 0 ]
234then
235   cp ${dirsrc}/*.css ${dirwww}/${lang}/ # ++ parce que un niveau de plus que d'haibitude dans les chunck
236fi
237#
238# modification of directory time in order to trigger the generation of HTML
239# files
240find ${dirwww}/ -type d -exec touch -t 199912310000 {} \;
241#
242# end
243exit 0
Note: See TracBrowser for help on using the repository browser.