source: trunk/checkmain.sh @ 140

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

Consolidation of shell scripts

  • Property svn:executable set to *
File size: 5.1 KB
Line 
1#! /bin/sh
2#
3#+
4# .. program:: checkmain.sh
5#
6# ============
7# checkmain.sh
8# ============
9#
10# SYNOPSIS
11# ========
12#
13# ::
14#
15#  $ checkmain.sh [--debug] -i filein
16#
17# DESCRIPTION
18# ===========
19#
20# .. option:: -i <filein>
21#
22# Check SUPERBIB requirements in main.xml **filein** XML/DocBook.
23#
24# project
25#   Should be defined :samp:`//d:keyword[@xml:id='project']`
26#
27#   Is used for ++
28# title
29#   Should be defined :samp:`d:article/d:title`
30#
31#   Is used for ++
32# homepage
33#   Should be defined :samp:`//d:bibliosource[@xml:id='homepage']`
34#
35#   Is used for ++
36# contact
37#   Should be defined :samp:`/d:article/d:info/d:authorgroup/d:author[1]/d:email`
38#
39#   Is used by PHP pages to send emails.
40#
41# .. warning::
42#
43#    There is now check on email and homepage.
44#    They **must** be real to avoid black holes of mails and 404 HTPP errors.
45#
46# EXAMPLES
47# ========
48#
49# To check the SUPERBIB demo main file::
50#
51#   $ ./checkmain.sh -i data/maindemo1.xml
52#   Title : superbib Demo1
53#   Project : superbib demo1
54#   HOME page : http://forge.ipsl.jussieu.fr/superbib/
55#   Contact : Francoise.Pinsard@locean-ipsl.upmc.fr
56#
57# To check the NEMO demo main file::
58#
59#   $ ./checkmain.sh -i data/mainnemo.xml
60#   Title : NEMO survey
61#   Project : NEMO
62#   HOME page : http://www.nemo-ocean.eu/
63#   Contact : opatlod@locean-ipsl.upmc.fr
64#
65# SEE ALSO
66# ========
67#
68# :ref:`using`
69#
70# :ref:`components_db.xsl`
71# :ref:`form_db.xsl`
72# :ref:`main_html.xsl`
73# :ref:`main_rest.xsl`
74# :ref:`superbib01_html.xsl`
75# :ref:`superbib01_rest.xsl`
76# :ref:`superbib01_xml.xsl`
77# :ref:`superbib02_html.xsl`
78# :ref:`superbib02_xml.xsl`
79# :ref:`superbib03_xml.xsl`
80# :ref:`superbibmany01_html.xsl`
81# :ref:`superbibmany01_xml.xsl`
82# :ref:`superbibmany02_html.xsl`
83# :ref:`superbibmany02_xml.xsl`
84# :ref:`template_db.xsl`
85# :ref:`user_db.xsl`
86# :ref:`user_html.xsl`
87# :ref:`user_rest.xsl`
88#
89# TODO
90# ====
91#
92# improve description
93#
94# XML/Docbook compliant : pb with element form: Schemas validity error : Element '{http://www.w3.org/1999/xhtml}form': This element is not expected.
95# .. so as I do not know haox to get rid of this I comment this test (see XFORM and so one)
96#
97# check for news on DocBook realase (now 20110701 5.0)
98#
99#
100# EVOLUTIONS
101# ==========
102#
103# $URL$
104#
105# $Id$
106#
107# - fplod 20110701T113247Z cratos.locean-ipsl.upmc.fr (Linux)
108#
109#   * creation
110#
111#-
112system=$(uname)
113case "${system}" in
114   AIX|IRIX64)
115      echo "www : no specific posix checking"
116      date_cmd=date
117   ;;
118   Darwin)
119      set -o posix
120      date_cmd=gdate
121   ;;
122   Linux)
123      set -o posix
124      date_cmd=date
125   ;;
126   *)
127     set -o posix
128   ;;
129esac
130unset system
131#
132set -u
133#
134LANG=POSIX
135#
136command=$(basename ${0})
137#
138usage=" Usage : ${command} [--debug] -i filein "
139#
140hostname=$(hostname)
141#
142# default
143debug=0
144#
145minargcount=2
146if [ ${#} -lt ${minargcount} ]
147then
148   echo "${command} : eee : not enought arguments"
149   echo "${usage}"
150   exit 1
151fi
152#
153while [ ${#} -gt 0 ]
154do
155   case ${1} in
156      --debug)
157         debug=1
158      ;;
159      -i)
160         filein=${2}
161         shift
162      ;;
163      *)
164        # anything else
165        echo "${command} : eee : unknown option ${1}"
166        echo "${command} : eee : ${usage}"
167        exit 1
168      ;;
169   esac
170   # next flag
171   shift
172done
173#
174# check parameters
175#
176# check for filein
177if [ ! -f ${filein} ]
178then
179   echo "eee : ${filein} not found"
180   exit 1
181fi
182#
183# test if xml available
184tool=xml
185type ${tool} 1> /dev/null 2>&1
186status=${?}
187if [ ${status} -ne 0 ]
188then
189   echo "${command} : eee : ${tool} not found"
190   exit 1
191fi
192unset status
193unset tool
194#
195#++# check XML/DocBook conformity
196#++xml val --err \
197#++--xsd http://www.docbook.org/xml/5.0/xsd/docbook.xsd \
198#++${filein}
199#++status=${?}
200#++if [ ${status} -ne 0 ]
201#++then
202#++   echo "${command} : eee : ${filein} is not XML/DocBook compliant"
203#++   exit 1
204#++fi
205#++unset status
206#
207# title
208xpath="d:article/d:title"
209title=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein})
210if [ "${title}" = "" ]
211then
212   echo "${command} : www : title not defined"
213   echo "${command} : www : fix ${xpath}"
214   exit 1
215else
216   echo "Title : ${title}"
217fi
218unset title
219#
220#
221# project
222project_ok=0
223xpath="//d:keyword[@xml:id='project']"
224project=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein})
225if [ "${project}" = "" ]
226then
227   echo "${command} : www : project not defined"
228   echo "${command} : www : fix ${xpath}"
229else
230   echo "Project : ${project}"
231   project_ok=1
232fi
233unset project
234#
235# homepage
236homepage_ok=0
237xpath="//d:bibliosource[@xml:id='homepage']"
238homepage=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein})
239if [ "${homepage}" = "" ]
240then
241   echo "${command} : www : homepage not defined"
242   echo "${command} : www : fix ${xpath}"
243else
244   echo "HOME page : ${homepage}"
245   homepage_ok=1
246fi
247unset homepage
248#
249# contact
250contact_ok=0
251xpath="/d:article/d:info/d:authorgroup/d:author[1]/d:email"
252contact=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m ${xpath}" -v . ${filein})
253if [ "${contact}" = "" ]
254then
255   echo "${command} : www : contact not defined"
256   echo "${command} : www : fix ${xpath}"
257else
258   echo "Contact : ${contact}"
259   contact_ok=1
260fi
261unset contact
262#
263unset command
264unset hostname
265unset usage
266#
267# end
268#++set
269exit 0
Note: See TracBrowser for help on using the repository browser.