[115] | 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 | #- |
---|
| 112 | system=$(uname) |
---|
| 113 | case "${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 | ;; |
---|
| 129 | esac |
---|
| 130 | unset system |
---|
| 131 | # |
---|
[116] | 132 | set -u |
---|
| 133 | # |
---|
[115] | 134 | LANG=POSIX |
---|
| 135 | # |
---|
| 136 | command=$(basename ${0}) |
---|
| 137 | # |
---|
| 138 | usage=" Usage : ${command} [--debug] -i filein " |
---|
| 139 | # |
---|
| 140 | hostname=$(hostname) |
---|
| 141 | # |
---|
| 142 | # default |
---|
| 143 | debug=0 |
---|
| 144 | # |
---|
| 145 | minargcount=2 |
---|
| 146 | if [ ${#} -lt ${minargcount} ] |
---|
| 147 | then |
---|
| 148 | echo "${command} : eee : not enought arguments" |
---|
| 149 | echo "${usage}" |
---|
| 150 | exit 1 |
---|
| 151 | fi |
---|
| 152 | # |
---|
[116] | 153 | while [ ${#} -gt 0 ] |
---|
[115] | 154 | do |
---|
| 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 |
---|
| 172 | done |
---|
| 173 | # |
---|
| 174 | # check parameters |
---|
| 175 | # |
---|
| 176 | # check for filein |
---|
| 177 | if [ ! -f ${filein} ] |
---|
| 178 | then |
---|
| 179 | echo "eee : ${filein} not found" |
---|
| 180 | exit 1 |
---|
| 181 | fi |
---|
| 182 | # |
---|
| 183 | # test if xml available |
---|
| 184 | tool=xml |
---|
| 185 | type ${tool} 1> /dev/null 2>&1 |
---|
| 186 | status=${?} |
---|
| 187 | if [ ${status} -ne 0 ] |
---|
| 188 | then |
---|
| 189 | echo "${command} : eee : ${tool} not found" |
---|
| 190 | exit 1 |
---|
| 191 | fi |
---|
| 192 | unset status |
---|
| 193 | unset 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 |
---|
| 208 | xpath="d:article/d:title" |
---|
| 209 | title=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein}) |
---|
| 210 | if [ "${title}" = "" ] |
---|
| 211 | then |
---|
| 212 | echo "${command} : www : title not defined" |
---|
| 213 | echo "${command} : www : fix ${xpath}" |
---|
| 214 | exit 1 |
---|
| 215 | else |
---|
| 216 | echo "Title : ${title}" |
---|
| 217 | fi |
---|
| 218 | unset title |
---|
| 219 | # |
---|
| 220 | # |
---|
| 221 | # project |
---|
| 222 | project_ok=0 |
---|
| 223 | xpath="//d:keyword[@xml:id='project']" |
---|
| 224 | project=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein}) |
---|
| 225 | if [ "${project}" = "" ] |
---|
| 226 | then |
---|
| 227 | echo "${command} : www : project not defined" |
---|
| 228 | echo "${command} : www : fix ${xpath}" |
---|
| 229 | else |
---|
| 230 | echo "Project : ${project}" |
---|
| 231 | project_ok=1 |
---|
| 232 | fi |
---|
| 233 | unset project |
---|
| 234 | # |
---|
| 235 | # homepage |
---|
| 236 | homepage_ok=0 |
---|
| 237 | xpath="//d:bibliosource[@xml:id='homepage']" |
---|
| 238 | homepage=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m "${xpath}" -v . ${filein}) |
---|
| 239 | if [ "${homepage}" = "" ] |
---|
| 240 | then |
---|
| 241 | echo "${command} : www : homepage not defined" |
---|
| 242 | echo "${command} : www : fix ${xpath}" |
---|
| 243 | else |
---|
| 244 | echo "HOME page : ${homepage}" |
---|
| 245 | homepage_ok=1 |
---|
| 246 | fi |
---|
| 247 | unset homepage |
---|
| 248 | # |
---|
| 249 | # contact |
---|
| 250 | contact_ok=0 |
---|
| 251 | xpath="/d:article/d:info/d:authorgroup/d:author[1]/d:email" |
---|
| 252 | contact=$(xml sel -N d="http://docbook.org/ns/docbook" -t -m ${xpath}" -v . ${filein}) |
---|
| 253 | if [ "${contact}" = "" ] |
---|
| 254 | then |
---|
| 255 | echo "${command} : www : contact not defined" |
---|
| 256 | echo "${command} : www : fix ${xpath}" |
---|
| 257 | else |
---|
| 258 | echo "Contact : ${contact}" |
---|
| 259 | contact_ok=1 |
---|
| 260 | fi |
---|
| 261 | unset contact |
---|
| 262 | # |
---|
| 263 | unset command |
---|
| 264 | unset hostname |
---|
| 265 | unset usage |
---|
| 266 | # |
---|
| 267 | # end |
---|
| 268 | #++set |
---|
| 269 | exit 0 |
---|