source: trunk/before.sh @ 323

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

Consolidation of shell scripts

  • Property svn:keywords set to Id
File size: 4.5 KB
RevLine 
[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#
82system=$(uname)
83case "${system}" in
[100]84   AIX|IRIX64)
85      echo " www : no specific posix checking"
86   ;;
87   *)
88      set -o posix
89   ;;
[75]90esac
[100]91unset system
[75]92#
[116]93set -u
94#
[79]95command=$(basename ${0})
[93]96log_date=$(date -u +"%Y%m%dT%H%M%SZ")
97log=/tmp/$(basename ${command} .sh).log.${log_date}
[2]98#
[29]99usage=" Usage : ${command} -p product -s dirsrc -w dirwww -l lang -mono|-multi -m nmany"
[23]100#
101minargcount=9
[25]102#echo " narg ${#}"
[23]103if [ ${#} -lt ${minargcount} ]
104then
[100]105   echo "eee : not enought arguments (${#} vs ${minargcount})"
106   echo "${usage}"
107   exit 1
[23]108fi
[100]109unset minargcount
[23]110#
[29]111# default
[52]112nmany=0
[29]113#
[116]114while [ ${#} -gt 0 ]
[23]115do
[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]146done
[100]147unset 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]153if [ -d ${dirsrc}/images/ ]
154then
[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]160fi
161#
[74]162if [ -d ${dirsrc}/documents/ ]
163then
[100]164   mkdir -p ${dirwww}/documents/
[74]165fi
166#
[26]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
[100]172   mkdir -p ${dirwww}/php/
[26]173fi
174#
[52]175if [ ${monolingual} -eq 0 ]
[23]176then
[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]188else
[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]199fi
[2]200#
[26]201if [ ${exist_php} -eq 0 ]
202then
[100]203   for file_php in ${list_php}
204   do
205      cp ${file_php} ${dirwww}/php/
206   done
[26]207fi
[100]208unset exist_php
[2]209#
[74]210if [ -d ${dirsrc}/images/ ]
[23]211then
[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]217fi
[2]218#
[74]219# copy of documents
[75]220if [ -d ${dirsrc}/documents/ ]
[74]221then
[100]222   cp ${dirsrc}/documents/* ${dirwww}/documents/
[74]223fi
224#
[2]225# copy of CSS
[74]226ls ${dirsrc}/*.css 1> /dev/null 2> /dev/null
[51]227exist_css=${?}
228if [ ${exist_css} -eq 0 ]
229then
[100]230   cp ${dirsrc}/*.css ${dirwww}/
[51]231fi
[100]232unset exist_css
[52]233if [ ${nmany} -gt 0 ]
[29]234then
[100]235   cp ${dirsrc}/*.css ${dirwww}/${lang}/ # ++ parce que un niveau de plus que d'haibitude dans les chunck
[29]236fi
[2]237#
[23]238# modification of directory time in order to trigger the generation of HTML
239# files
240find ${dirwww}/ -type d -exec touch -t 199912310000 {} \;
[2]241#
[23]242# end
[2]243exit 0
Note: See TracBrowser for help on using the repository browser.