diff --git a/configure.ac b/configure.ac index 49aa3b123..3584af6f3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,955 +1,956 @@ ## This file is part of Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## This is Invenio main configure.ac file. If you change this ## file, then please run "autoreconf" to regenerate the "configure" ## script. ## Initialize autoconf and automake: AC_INIT([invenio],[m4_esyscmd(./git-version-gen .tarball-version)],[info@invenio-software.org]) AM_INIT_AUTOMAKE([tar-ustar]) ## By default we shall install into /opt/invenio. (Do not use ## AC_PREFIX_DEFAULT for this, because it would not work well with ## the localstatedir hack below.) test "${prefix}" = NONE && prefix=/opt/invenio ## Remove eventual trailing slashes from the prefix value: test "${prefix%/}" != "" && prefix=${prefix%/} ## Check for install: AC_PROG_INSTALL ## Check for gettext support: AM_GNU_GETTEXT(external) AM_GNU_GETTEXT_VERSION(0.14.4) ## Check for MySQL client: AC_MSG_CHECKING(for mysql) AC_ARG_WITH(mysql, AS_HELP_STRING([--with-mysql],[path to a specific MySQL binary (optional)]), MYSQL=${withval}) if test -n "$MYSQL"; then AC_MSG_RESULT($MYSQL) else AC_PATH_PROG(MYSQL, mysql) if test -z "$MYSQL"; then AC_MSG_ERROR([ MySQL command-line client was not found in your PATH. Please install it first. Available from <http://mysql.com/>.]) fi fi ## Check for Python: AC_MSG_CHECKING(for python) AC_ARG_WITH(python, AS_HELP_STRING([--with-python],[path to a specific Python binary (optional)]), PYTHON=${withval}) if test -n "$PYTHON"; then AC_MSG_RESULT($PYTHON) else AC_PATH_PROG(PYTHON, python) if test -z "$PYTHON"; then AC_MSG_ERROR([ Python was not found in your PATH. Please either install it in your PATH or specify --with-python configure option. Python is available from <http://python.org/>.]) fi fi ## Check for OpenOffice.org Python binary: AC_MSG_CHECKING(for OpenOffice.org Python binary) AC_ARG_WITH(openoffice-python, AS_HELP_STRING([--with-openoffice-python],[path to a specific OpenOffice.org Python binary (optional)]), OPENOFFICE_PYTHON=`which ${withval}`) if test -z "$OPENOFFICE_PYTHON"; then OPENOFFICE_PYTHON=`locate -l 1 -r "o.*office/program/python$"` OPENOFFICE_PYTHON="$PYTHON $OPENOFFICE_PYTHON" if test -n "$OPENOFFICE_PYTHON" && ($OPENOFFICE_PYTHON -c "import uno" 2> /dev/null); then AC_MSG_RESULT($OPENOFFICE_PYTHON) else AC_MSG_WARN([ You have not specified the path ot the OpenOffice.org Python binary. OpenOffice.org and Microsoft Office document conversion and fulltext indexing will not be available. We recommend you to install OpenOffice.org first and to rerun the configure script. OpenOffice.org is available from <http://www.openoffice.org/>.]) fi elif ($OPENOFFICE_PYTHON -c "import uno" 2> /dev/null); then AC_MSG_RESULT($OPENOFFICE_PYTHON) else AC_MSG_ERROR([ The specified OpenOffice.org Python binary is not correctly configured. Please specify the correct path to the specific OpenOffice Python binary (OpenOffice.org is available from <http://www.openoffice.org/>).]) fi ## Check for Python version and modules: AC_MSG_CHECKING(for required Python modules) $PYTHON ${srcdir}/configure-tests.py if test $? -ne 0; then AC_MSG_ERROR([Please fix the above Python problem before continuing.]) fi AC_MSG_RESULT(found) ## Check for PHP: AC_PATH_PROG(PHP, php) ## Check for gzip: AC_PATH_PROG(GZIP, gzip) if test -z "$GZIP"; then AC_MSG_WARN([ Gzip was not found in your PATH. It is used in the WebSubmit module to compress the data submitted in an archive. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Gzip is available from <http://www.gzip.org/>.]) fi ## Check for gunzip: AC_PATH_PROG(GUNZIP, gunzip) if test -z "$GUNZIP"; then AC_MSG_WARN([ Gunzip was not found in your PATH. It is used in the WebSubmit module to correctly deal with submitted compressed files. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Gunzip is available from <http://www.gzip.org/>.]) fi ## Check for tar: AC_PATH_PROG(TAR, tar) if test -z "$TAR"; then AC_MSG_WARN([ Tar was not found in your PATH. It is used in the WebSubmit module to pack the submitted data into an archive. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Tar is available from <ftp://prep.ai.mit.edu/pub/gnu/tar/>.]) fi ## Check for wget: AC_PATH_PROG(WGET, wget) if test -z "$WGET"; then AC_MSG_WARN([ wget was not found in your PATH. It is used for the fulltext file retrieval. You can continue without it but we recomend you to install it first and to rerun the configure script. wget is available from <http://www.gnu.org/software/wget/>.]) fi ## Check for md5sum: AC_PATH_PROG(MD5SUM, md5sum) if test -z "$MD5SUM"; then AC_MSG_WARN([ md5sum was not found in your PATH. It is used for the fulltext file checksum verification. You can continue without it but we recomend you to install it first and to rerun the configure script. md5sum is available from <http://www.gnu.org/software/coreutils/>.]) fi ## Check for ps2pdf: AC_PATH_PROG(PS2PDF, ps2pdf) if test -z "$PS2PDF"; then AC_MSG_WARN([ ps2pdf was not found in your PATH. It is used in the WebSubmit module to convert submitted PostScripts into PDF. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. ps2pdf is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdflatex: AC_PATH_PROG(PDFLATEX, pdflatex) if test -z "$PDFLATEX"; then AC_MSG_WARN([ pdflatex was not found in your PATH. It is used in the WebSubmit module to stamp PDF files. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script.]) fi ## Check for tiff2pdf: AC_PATH_PROG(TIFF2PDF, tiff2pdf) if test -z "$TIFF2PDF"; then AC_MSG_WARN([ tiff2pdf was not found in your PATH. It is used in the WebSubmit module to convert submitted TIFF file into PDF. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. tiff2pdf is available from <http://www.remotesensing.org/libtiff/>.]) fi ## Check for gs: AC_PATH_PROG(GS, gs) if test -z "$GS"; then AC_MSG_WARN([ gs was not found in your PATH. It is used in the WebSubmit module to convert submitted PostScripts into PDF. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. gs is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdftotext: AC_PATH_PROG(PDFTOTEXT, pdftotext) if test -z "$PDFTOTEXT"; then AC_MSG_WARN([ pdftotext was not found in your PATH. It is used for the fulltext indexation of PDF files. You can continue without it but you may miss fulltext searching capability of Invenio. We recomend you to install it first and to rerun the configure script. pdftotext is available from <http://www.foolabs.com/xpdf/home.html>. ]) fi ## Check for pdftotext: AC_PATH_PROG(PDFINFO, pdfinfo) if test -z "$PDFINFO"; then AC_MSG_WARN([ pdfinfo was not found in your PATH. It is used for gathering information on PDF files. You can continue without it but you may miss this feature of Invenio. We recomend you to install it first and to rerun the configure script. pdftotext is available from <http://www.foolabs.com/xpdf/home.html>. ]) fi ## Check for pdftk: AC_PATH_PROG(PDFTK, pdftk) if test -z "$PDFTK"; then AC_MSG_WARN([ pdftk was not found in your PATH. It is used for the fulltext file stamping. You can continue without it but you may miss this feature of Invenio. We recomend you to install it first and to rerun the configure script. pdftk is available from <http://www.accesspdf.com/pdftk/>. ]) fi ## Check for pdf2ps: AC_PATH_PROG(PDF2PS, pdf2ps) if test -z "$PDF2PS"; then AC_MSG_WARN([ pdf2ps was not found in your PATH. It is used in the WebSubmit module to convert submitted PDFs into PostScript. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdf2ps is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdftops: AC_PATH_PROG(PDFTOPS, pdftops) if test -z "$PDFTOPS"; then AC_MSG_WARN([ pdftops was not found in your PATH. It is used in the WebSubmit module to convert submitted PDFs into PostScript. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdftops is available from <http://poppler.freedesktop.org/>.]) fi ## Check for pdfopt: AC_PATH_PROG(PDFOPT, pdfopt) if test -z "$PDFOPT"; then AC_MSG_WARN([ pdfopt was not found in your PATH. It is used in the WebSubmit module to linearized submitted PDFs. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdfopt is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>.]) fi ## Check for pdfimages: AC_PATH_PROG(PDFTOPPM, pdftoppm) if test -z "$PDFTOPPM"; then AC_MSG_WARN([ pdftoppm was not found in your PATH. It is used in the WebSubmit module to extract images from PDFs for OCR. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pdftoppm is available from <http://poppler.freedesktop.org/>.]) fi ## Check for pdfimages: AC_PATH_PROG(PAMFILE, pdftoppm) if test -z "$PAMFILE"; then AC_MSG_WARN([ pamfile was not found in your PATH. It is used in the WebSubmit module to retrieve the size of images extracted from PDFs for OCR. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. pamfile is available as part of the netpbm utilities from: <http://netpbm.sourceforge.net/>.]) fi ## Check for ocroscript: AC_PATH_PROG(OCROSCRIPT, ocroscript) if test -z "$OCROSCRIPT"; then AC_MSG_WARN([ If you plan to run OCR on your PDFs, then please install ocroscript now. Otherwise you can safely continue. You have also an option to install ocroscript later and edit invenio-local.conf to let Invenio know the path to ocroscript. ocroscript is available as part of OCROpus from <http://code.google.com/p/ocropus/>. NOTE: Since OCROpus is being actively developed and its api is continuosly changing, please install relase 0.3.1]) fi ## Check for pstotext: AC_PATH_PROG(PSTOTEXT, pstotext) if test -z "$PSTOTEXT"; then AC_MSG_WARN([ pstotext was not found in your PATH. It is used for the fulltext indexation of PDF and PostScript files. Please install pstotext. Otherwise you can safely continue. You have also an option to install pstotext later and edit invenio-local.conf to let Invenio know the path to pstotext. pstotext is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>. ]) fi ## Check for ps2ascii: AC_PATH_PROG(PSTOASCII, ps2ascii) if test -z "$PSTOASCII"; then AC_MSG_WARN([ ps2ascii was not found in your PATH. It is used for the fulltext indexation of PostScript files. Please install ps2ascii. Otherwise you can safely continue. You have also an option to install ps2ascii later and edit invenio-local.conf to let Invenio know the path to ps2ascii. ps2ascii is available from <http://www.cs.wisc.edu/~ghost/doc/AFPL/>. ]) fi ## Check for any2djvu: AC_PATH_PROG(ANY2DJVU, any2djvu) if test -z "$ANY2DJVU"; then AC_MSG_WARN([ any2djvu was not found in your PATH. It is used in the WebSubmit module to convert documents to DJVU. Please install any2djvu. Otherwise you can safely continue. You have also an option to install any2djvu later and edit invenio-local.conf to let Invenio know the path to any2djvu. any2djvu is available from <http://djvu.sourceforge.net/>.]) fi ## Check for DJVUPS: AC_PATH_PROG(DJVUPS, djvups) if test -z "$DJVUPS"; then AC_MSG_WARN([ djvups was not found in your PATH. It is used in the WebSubmit module to convert documents from DJVU. Please install djvups. Otherwise you can safely continue. You have also an option to install djvups later and edit invenio-local.conf to let Invenio know the path to djvups. djvups is available from <http://djvu.sourceforge.net/>.]) fi ## Check for DJVUTXT: AC_PATH_PROG(DJVUTXT, djvutxt) if test -z "$DJVUTXT"; then AC_MSG_WARN([ djvutxt was not found in your PATH. It is used in the WebSubmit module to extract text from DJVU documents. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. djvutxt is available from <http://djvu.sourceforge.net/>.]) fi ## Check for file: AC_PATH_PROG(FILE, file) if test -z "$FILE"; then AC_MSG_WARN([ File was not found in your PATH. It is used in the WebSubmit module to check the validity of the submitted files. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. File is available from <ftp://ftp.astron.com/pub/file/>.]) fi ## Check for convert: AC_PATH_PROG(CONVERT, convert) if test -z "$CONVERT"; then AC_MSG_WARN([ Convert was not found in your PATH. It is used in the WebSubmit module to create an icon from a submitted picture. You can continue without it but you will miss some Invenio functionality. We recommend you to install it first and to rerun the configure script. Convert is available from <http://www.imagemagick.org/>.]) fi ## Check for CLISP: AC_MSG_CHECKING(for clisp) AC_ARG_WITH(clisp, AS_HELP_STRING([--with-clisp],[path to a specific CLISP binary (optional)]), CLISP=${withval}) if test -n "$CLISP"; then AC_MSG_RESULT($CLISP) else AC_PATH_PROG(CLISP, clisp) if test -z "$CLISP"; then AC_MSG_WARN([ GNU CLISP was not found in your PATH. It is used by the WebStat module to produce statistics about Invenio usage. (Alternatively, SBCL or CMUCL can be used instead of CLISP.) You can continue without it but you will miss this feature. We recommend you to install it first (if you don't have neither CMUCL nor SBCL) and to rerun the configure script. GNU CLISP is available from <http://clisp.cons.org/>.]) fi fi ## Check for CMUCL: AC_MSG_CHECKING(for cmucl) AC_ARG_WITH(cmucl, AS_HELP_STRING([--with-cmucl],[path to a specific CMUCL binary (optional)]), CMUCL=${withval}) if test -n "$CMUCL"; then AC_MSG_RESULT($CMUCL) else AC_PATH_PROG(CMUCL, cmucl) if test -z "$CMUCL"; then AC_MSG_CHECKING(for lisp) # CMUCL can also be installed under `lisp' exec name AC_PATH_PROG(CMUCL, lisp) fi if test -z "$CMUCL"; then AC_MSG_WARN([ CMUCL was not found in your PATH. It is used by the WebStat module to produce statistics about Invenio usage. (Alternatively, CLISP or SBCL can be used instead of CMUCL.) You can continue without it but you will miss this feature. We recommend you to install it first (if you don't have neither CLISP nor SBCL) and to rerun the configure script. CMUCL is available from <http://www.cons.org/cmucl/>.]) fi fi ## Check for SBCL: AC_MSG_CHECKING(for sbcl) AC_ARG_WITH(sbcl, AS_HELP_STRING([--with-sbcl],[path to a specific SBCL binary (optional)]), SBCL=${withval}) if test -n "$SBCL"; then AC_MSG_RESULT($SBCL) else AC_PATH_PROG(SBCL, sbcl) if test -z "$SBCL"; then AC_MSG_WARN([ SBCL was not found in your PATH. It is used by the WebStat module to produce statistics about Invenio usage. (Alternatively, CLISP or CMUCL can be used instead of SBCL.) You can continue without it but you will miss this feature. We recommend you to install it first (if you don't have neither CLISP nor CMUCL) and to rerun the configure script. SBCL is available from <http://sbcl.sourceforge.net/>.]) fi fi ## Check for gnuplot: AC_PATH_PROG(GNUPLOT, gnuplot) if test -z "$GNUPLOT"; then AC_MSG_WARN([ Gnuplot was not found in your PATH. It is used by the BibRank module to produce graphs about download and citation history. You can continue without it but you will miss these graphs. We recommend you to install it first and to rerun the configure script. Gnuplot is available from <http://www.gnuplot.info/>.]) fi ## Check for ffmpeg: AC_PATH_PROG(FFMPEG, ffmpeg) AC_PATH_PROG(FFPROBE, ffprobe) if test -z "$FFMPEG"; then AC_MSG_WARN([ FFmpeg was not found in your PATH. It is used by the BibEncode module to for video encoding. You can continue without but you will not be able to use BibEncode and no video submission workflows are thereby possible. We recommend you to install it first if you would like to support video submissions and to rerun the configure script. FFmpeg is available from <http://www.ffmpeg.org/>.]) fi ## Check for mediainfo: AC_PATH_PROG(MEDIAINFO, mediainfo) if test -z "$MEDIAINFO"; then AC_MSG_WARN([ Mediainfo was not found in your PATH. It is used by the BibEncode module to for video encoding and media metadata handling. You can continue without but you will not be able to use BibEncode and no video submission workflows are thereby possible. We recommend you to install it first if you would like to support video submissions and to rerun the configure script. Mediainfo is available from <http://mediainfo.sourceforge.net/>.]) fi ## Check for ffmpeg ## Substitute variables: AC_SUBST(VERSION) AC_SUBST(OPENOFFICE_PYTHON) AC_SUBST(MYSQL) AC_SUBST(PYTHON) AC_SUBST(GZIP) AC_SUBST(GUNZIP) AC_SUBST(TAR) AC_SUBST(WGET) AC_SUBST(MD5SUM) AC_SUBST(PS2PDF) AC_SUBST(GS) AC_SUBST(PDFTOTEXT) AC_SUBST(PDFTK) AC_SUBST(PDF2PS) AC_SUBST(PDFTOPS) AC_SUBST(PDFOPT) AC_SUBST(PDFTOPPM) AC_SUBST(OCROSCRIPT) AC_SUBST(PSTOTEXT) AC_SUBST(PSTOASCII) AC_SUBST(ANY2DJVU) AC_SUBST(DJVUPS) AC_SUBST(DJVUTXT) AC_SUBST(FILE) AC_SUBST(CONVERT) AC_SUBST(GNUPLOT) AC_SUBST(CLISP) AC_SUBST(CMUCL) AC_SUBST(SBCL) AC_SUBST(CACHEDIR) AC_SUBST(FFMPEG) AC_SUBST(MEDIAINFO) AC_SUBST(FFPROBE) AC_SUBST(localstatedir, `eval echo "${localstatedir}"`) ## Define output files: AC_CONFIG_FILES([config.nice \ Makefile \ po/Makefile.in \ config/Makefile \ config/invenio-autotools.conf \ modules/Makefile \ modules/webauthorprofile/Makefile \ modules/webauthorprofile/lib/Makefile \ modules/webauthorprofile/bin/Makefile \ modules/webauthorprofile/bin/webauthorprofile \ modules/bibauthorid/Makefile \ modules/bibauthorid/bin/Makefile \ modules/bibauthorid/bin/bibauthorid \ modules/bibauthorid/doc/Makefile \ modules/bibauthorid/doc/admin/Makefile \ modules/bibauthorid/doc/hacking/Makefile \ modules/bibauthorid/lib/Makefile \ modules/bibauthorid/etc/Makefile \ modules/bibauthorid/etc/name_authority_files/Makefile \ modules/bibauthorid/web/Makefile \ modules/bibcatalog/Makefile \ modules/bibcatalog/doc/Makefile \ modules/bibcatalog/doc/admin/Makefile \ modules/bibcatalog/doc/hacking/Makefile modules/bibcatalog/lib/Makefile \ modules/bibcheck/Makefile \ modules/bibcheck/doc/Makefile \ modules/bibcheck/doc/admin/Makefile \ modules/bibcheck/doc/hacking/Makefile \ modules/bibcheck/etc/Makefile \ modules/bibcheck/web/Makefile \ modules/bibcheck/web/admin/Makefile \ modules/bibcirculation/Makefile \ modules/bibcirculation/bin/Makefile \ modules/bibcirculation/bin/bibcircd \ modules/bibcirculation/doc/Makefile \ modules/bibcirculation/doc/admin/Makefile \ modules/bibcirculation/doc/hacking/Makefile modules/bibcirculation/lib/Makefile \ modules/bibcirculation/web/Makefile \ modules/bibcirculation/web/admin/Makefile \ modules/bibclassify/Makefile \ modules/bibclassify/bin/Makefile \ modules/bibclassify/bin/bibclassify \ modules/bibclassify/doc/Makefile \ modules/bibclassify/doc/admin/Makefile \ modules/bibclassify/doc/hacking/Makefile \ modules/bibclassify/etc/Makefile \ modules/bibclassify/lib/Makefile \ modules/bibconvert/Makefile \ modules/bibconvert/bin/Makefile \ modules/bibconvert/bin/bibconvert \ modules/bibconvert/doc/Makefile \ modules/bibconvert/doc/admin/Makefile \ modules/bibconvert/doc/hacking/Makefile \ modules/bibconvert/etc/Makefile \ modules/bibconvert/lib/Makefile \ modules/bibdocfile/Makefile \ modules/bibdocfile/bin/bibdocfile \ modules/bibdocfile/bin/Makefile \ modules/bibdocfile/doc/Makefile \ modules/bibdocfile/doc/hacking/Makefile \ modules/bibdocfile/lib/Makefile \ modules/bibrecord/Makefile \ modules/bibrecord/bin/Makefile \ modules/bibrecord/bin/xmlmarc2textmarc \ modules/bibrecord/bin/textmarc2xmlmarc \ modules/bibrecord/bin/xmlmarclint \ modules/bibrecord/doc/Makefile \ modules/bibrecord/doc/admin/Makefile \ modules/bibrecord/doc/hacking/Makefile \ modules/bibrecord/etc/Makefile \ modules/bibrecord/lib/Makefile \ modules/bibedit/Makefile \ modules/bibedit/bin/Makefile \ modules/bibedit/bin/bibedit \ modules/bibedit/doc/Makefile \ modules/bibedit/doc/admin/Makefile \ modules/bibedit/doc/hacking/Makefile \ modules/bibedit/etc/Makefile \ modules/bibedit/lib/Makefile \ modules/bibedit/web/Makefile \ modules/bibencode/Makefile \ modules/bibencode/bin/Makefile \ modules/bibencode/bin/bibencode \ modules/bibencode/lib/Makefile \ modules/bibencode/etc/Makefile \ modules/bibencode/www/Makefile \ modules/bibexport/Makefile \ modules/bibexport/bin/Makefile \ modules/bibexport/bin/bibexport \ modules/bibexport/doc/Makefile \ modules/bibexport/doc/admin/Makefile \ modules/bibexport/doc/hacking/Makefile modules/bibexport/etc/Makefile \ modules/bibexport/lib/Makefile \ modules/bibexport/web/Makefile \ modules/bibexport/web/admin/Makefile \ modules/bibformat/Makefile \ modules/bibformat/bin/Makefile \ modules/bibformat/bin/bibreformat \ modules/bibformat/doc/Makefile \ modules/bibformat/doc/admin/Makefile \ modules/bibformat/doc/hacking/Makefile \ modules/bibformat/etc/Makefile \ modules/bibformat/etc/templates/Makefile \ modules/bibformat/etc/format_templates/Makefile \ modules/bibformat/etc/output_formats/Makefile \ modules/bibformat/lib/Makefile \ modules/bibformat/lib/elements/Makefile \ modules/bibformat/web/Makefile \ modules/bibformat/web/admin/Makefile \ modules/oaiharvest/Makefile \ modules/oaiharvest/bin/Makefile \ modules/oaiharvest/bin/oaiharvest \ modules/oaiharvest/doc/Makefile \ modules/oaiharvest/doc/admin/Makefile \ modules/oaiharvest/doc/hacking/Makefile \ modules/oaiharvest/lib/Makefile \ modules/oaiharvest/web/Makefile \ modules/oaiharvest/web/admin/Makefile \ modules/oairepository/Makefile \ modules/oairepository/bin/Makefile \ modules/oairepository/bin/oairepositoryupdater \ modules/oairepository/doc/Makefile \ modules/oairepository/doc/admin/Makefile \ modules/oairepository/doc/hacking/Makefile \ modules/oairepository/etc/Makefile \ modules/oairepository/lib/Makefile \ modules/oairepository/web/Makefile \ modules/oairepository/web/admin/Makefile \ modules/bibindex/Makefile \ modules/bibindex/bin/Makefile \ modules/bibindex/bin/bibindex \ modules/bibindex/bin/bibstat \ modules/bibindex/doc/Makefile \ modules/bibindex/doc/admin/Makefile \ modules/bibindex/doc/hacking/Makefile \ modules/bibindex/lib/Makefile \ modules/bibindex/web/Makefile \ modules/bibindex/web/admin/Makefile \ modules/bibknowledge/Makefile \ modules/bibknowledge/lib/Makefile \ modules/bibknowledge/doc/Makefile \ modules/bibknowledge/doc/admin/Makefile \ modules/bibknowledge/doc/hacking/Makefile \ modules/bibmatch/Makefile \ modules/bibmatch/bin/Makefile \ modules/bibmatch/bin/bibmatch \ modules/bibmatch/doc/Makefile \ modules/bibmatch/doc/admin/Makefile \ modules/bibmatch/doc/hacking/Makefile \ modules/bibmatch/etc/Makefile \ modules/bibmatch/lib/Makefile \ modules/bibmerge/Makefile \ modules/bibmerge/bin/Makefile \ modules/bibmerge/doc/Makefile \ modules/bibmerge/doc/admin/Makefile \ modules/bibmerge/doc/hacking/Makefile \ modules/bibmerge/lib/Makefile \ modules/bibmerge/web/Makefile \ modules/bibmerge/web/admin/Makefile \ modules/bibrank/Makefile \ modules/bibrank/bin/Makefile \ modules/bibrank/bin/bibrank \ modules/bibrank/bin/bibrankgkb \ modules/bibrank/doc/Makefile \ modules/bibrank/doc/admin/Makefile \ modules/bibrank/doc/hacking/Makefile \ modules/bibrank/etc/Makefile \ modules/bibrank/etc/bibrankgkb.cfg \ modules/bibrank/etc/demo_jif.cfg \ modules/bibrank/etc/template_single_tag_rank_method.cfg \ modules/bibrank/lib/Makefile \ modules/bibrank/web/Makefile \ modules/bibrank/web/admin/Makefile \ modules/bibsched/Makefile \ modules/bibsched/bin/Makefile \ modules/bibsched/bin/bibsched \ modules/bibsched/bin/bibtaskex \ modules/bibsched/bin/bibtasklet \ modules/bibsched/doc/Makefile \ modules/bibsched/doc/admin/Makefile \ modules/bibsched/doc/hacking/Makefile \ modules/bibsched/lib/Makefile \ modules/bibsched/lib/tasklets/Makefile \ modules/bibupload/Makefile \ modules/bibsort/Makefile \ modules/bibsort/bin/Makefile \ modules/bibsort/bin/bibsort \ modules/bibsort/lib/Makefile \ modules/bibsort/etc/Makefile \ modules/bibsort/doc/Makefile \ modules/bibsort/doc/admin/Makefile \ modules/bibsort/doc/hacking/Makefile \ modules/bibsort/web/Makefile \ modules/bibsort/web/admin/Makefile \ modules/bibsword/Makefile \ modules/bibsword/bin/Makefile \ modules/bibsword/bin/bibsword \ modules/bibsword/doc/Makefile \ modules/bibsword/doc/admin/Makefile \ modules/bibsword/doc/hacking/Makefile \ modules/bibsword/lib/Makefile \ modules/bibsword/etc/Makefile \ modules/bibupload/bin/Makefile \ modules/bibupload/bin/bibupload \ modules/bibupload/bin/batchuploader \ modules/bibupload/doc/Makefile \ modules/bibupload/doc/admin/Makefile \ modules/bibupload/doc/hacking/Makefile \ modules/bibupload/lib/Makefile \ modules/elmsubmit/Makefile \ modules/elmsubmit/bin/Makefile \ modules/elmsubmit/bin/elmsubmit \ modules/elmsubmit/doc/Makefile \ modules/elmsubmit/doc/admin/Makefile \ modules/elmsubmit/doc/hacking/Makefile \ modules/elmsubmit/etc/Makefile \ modules/elmsubmit/etc/elmsubmit.cfg \ modules/elmsubmit/lib/Makefile \ modules/miscutil/Makefile \ modules/miscutil/bin/Makefile \ modules/miscutil/bin/dbdump \ modules/miscutil/bin/dbexec \ modules/miscutil/bin/inveniocfg \ modules/miscutil/bin/inveniomanage \ modules/miscutil/bin/plotextractor \ modules/miscutil/demo/Makefile \ modules/miscutil/doc/Makefile \ modules/miscutil/doc/hacking/Makefile \ modules/miscutil/etc/Makefile \ modules/miscutil/etc/bash_completion.d/Makefile \ modules/miscutil/etc/bash_completion.d/inveniocfg \ modules/miscutil/etc/ckeditor_scientificchar/Makefile \ modules/miscutil/etc/ckeditor_scientificchar/dialogs/Makefile \ modules/miscutil/etc/ckeditor_scientificchar/lang/Makefile \ + modules/miscutil/etc/templates/Makefile \ modules/miscutil/lib/Makefile \ modules/miscutil/lib/upgrades/Makefile \ modules/miscutil/sql/Makefile \ modules/miscutil/web/Makefile \ modules/webaccess/Makefile \ modules/webaccess/bin/Makefile \ modules/webaccess/bin/authaction \ modules/webaccess/bin/webaccessadmin \ modules/webaccess/etc/Makefile \ modules/webaccess/etc/templates/Makefile \ modules/webaccess/doc/Makefile \ modules/webaccess/doc/admin/Makefile \ modules/webaccess/doc/hacking/Makefile \ modules/webaccess/lib/Makefile \ modules/webaccess/web/Makefile \ modules/webaccess/web/admin/Makefile \ modules/webalert/Makefile \ modules/webalert/bin/Makefile \ modules/webalert/bin/alertengine \ modules/webalert/doc/Makefile \ modules/webalert/doc/admin/Makefile \ modules/webalert/doc/hacking/Makefile \ modules/webalert/lib/Makefile \ modules/webalert/web/Makefile \ modules/webbasket/Makefile \ modules/webbasket/doc/Makefile \ modules/webbasket/doc/admin/Makefile \ modules/webbasket/doc/hacking/Makefile \ modules/webbasket/lib/Makefile \ modules/webbasket/web/Makefile \ modules/webcomment/Makefile \ modules/webcomment/doc/Makefile \ modules/webcomment/doc/admin/Makefile \ modules/webcomment/doc/hacking/Makefile \ modules/webcomment/etc/Makefile \ modules/webcomment/etc/templates/Makefile \ modules/webcomment/lib/Makefile \ modules/webcomment/web/Makefile \ modules/webcomment/web/admin/Makefile \ modules/webhelp/Makefile \ modules/webhelp/web/Makefile \ modules/webhelp/web/admin/Makefile \ modules/webhelp/web/admin/howto/Makefile \ modules/webhelp/web/hacking/Makefile \ modules/webjournal/Makefile \ modules/webjournal/etc/Makefile \ modules/webjournal/doc/Makefile \ modules/webjournal/doc/admin/Makefile \ modules/webjournal/doc/hacking/Makefile \ modules/webjournal/lib/Makefile \ modules/webjournal/lib/elements/Makefile \ modules/webjournal/lib/widgets/Makefile \ modules/webjournal/web/Makefile \ modules/webjournal/web/admin/Makefile \ modules/weblinkback/Makefile \ modules/weblinkback/etc/Makefile \ modules/weblinkback/etc/templates/Makefile \ modules/weblinkback/lib/Makefile \ modules/weblinkback/web/Makefile \ modules/weblinkback/web/admin/Makefile \ modules/webmessage/Makefile \ modules/webmessage/bin/Makefile \ modules/webmessage/bin/webmessageadmin \ modules/webmessage/doc/Makefile \ modules/webmessage/doc/admin/Makefile \ modules/webmessage/doc/hacking/Makefile \ modules/webmessage/etc/Makefile \ modules/webmessage/etc/templates/Makefile \ modules/webmessage/lib/Makefile \ modules/webmessage/web/Makefile \ modules/websearch/Makefile \ modules/websearch/bin/Makefile \ modules/websearch/bin/webcoll \ modules/websearch/doc/Makefile \ modules/websearch/doc/admin/Makefile \ modules/websearch/doc/hacking/Makefile \ modules/websearch/etc/Makefile \ modules/websearch/etc/templates/Makefile \ modules/websearch/lib/Makefile \ modules/websearch/lib/facets/Makefile \ modules/websearch/web/Makefile \ modules/websearch/web/admin/Makefile \ modules/websession/Makefile \ modules/websession/bin/Makefile \ modules/websession/bin/inveniogc \ modules/websession/etc/Makefile \ modules/websession/etc/templates/Makefile \ modules/websession/doc/Makefile \ modules/websession/doc/admin/Makefile \ modules/websession/doc/hacking/Makefile \ modules/websession/lib/Makefile \ modules/websession/web/Makefile \ modules/webstat/Makefile \ modules/webstat/bin/Makefile \ modules/webstat/bin/webstat \ modules/webstat/bin/webstatadmin \ modules/webstat/doc/Makefile \ modules/webstat/doc/admin/Makefile \ modules/webstat/doc/hacking/Makefile \ modules/webstat/etc/Makefile \ modules/webstat/lib/Makefile \ modules/webstyle/Makefile \ modules/webstyle/bin/Makefile \ modules/webstyle/bin/gotoadmin \ modules/webstyle/bin/webdoc \ modules/webstyle/css/Makefile \ modules/webstyle/doc/Makefile \ modules/webstyle/doc/admin/Makefile \ modules/webstyle/doc/hacking/Makefile \ modules/webstyle/etc/Makefile \ modules/webstyle/etc/templates/Makefile \ modules/webstyle/img/Makefile \ modules/webstyle/lib/Makefile \ modules/webstyle/lib/goto_plugins/Makefile \ modules/websubmit/Makefile \ modules/websubmit/bin/Makefile \ modules/websubmit/bin/inveniounoconv \ modules/websubmit/doc/Makefile \ modules/websubmit/doc/admin/Makefile \ modules/websubmit/doc/hacking/Makefile \ modules/websubmit/etc/Makefile \ modules/websubmit/lib/Makefile \ modules/websubmit/lib/functions/Makefile \ modules/websubmit/web/Makefile \ modules/websubmit/web/admin/Makefile \ modules/docextract/Makefile \ modules/docextract/bin/Makefile \ modules/docextract/bin/docextract \ modules/docextract/bin/refextract \ modules/docextract/doc/Makefile \ modules/docextract/lib/Makefile \ modules/docextract/etc/Makefile \ modules/docextract/doc/admin/Makefile \ modules/docextract/doc/hacking/Makefile \ modules/webdeposit/Makefile \ modules/webdeposit/etc/Makefile \ modules/webdeposit/etc/static/Makefile \ modules/webdeposit/etc/templates/Makefile \ modules/webdeposit/lib/Makefile \ modules/webdeposit/lib/deposition_fields/Makefile \ modules/webdeposit/lib/deposition_forms/Makefile \ modules/webdeposit/lib/deposition_types/Makefile \ ]) ## Finally, write output files: AC_OUTPUT ## Write help: AC_MSG_RESULT([****************************************************************************]) AC_MSG_RESULT([** Your Invenio installation is now ready for building. **]) AC_MSG_RESULT([** You have entered the following parameters: **]) AC_MSG_RESULT([** - Invenio main install directory: ${prefix}]) AC_MSG_RESULT([** - Python executable: $PYTHON]) AC_MSG_RESULT([** - MySQL client executable: $MYSQL]) AC_MSG_RESULT([** - CLISP executable: $CLISP]) AC_MSG_RESULT([** - CMUCL executable: $CMUCL]) AC_MSG_RESULT([** - SBCL executable: $SBCL]) AC_MSG_RESULT([** Here are the steps to continue the building process: **]) AC_MSG_RESULT([** 1) Type 'make' to build your Invenio system. **]) AC_MSG_RESULT([** 2) Type 'make install' to install your Invenio system. **]) AC_MSG_RESULT([** After that you can start customizing your installation as documented **]) AC_MSG_RESULT([** in the INSTALL file (i.e. edit invenio.conf, run inveniocfg, etc). **]) AC_MSG_RESULT([** Good luck, and thanks for choosing Invenio. **]) AC_MSG_RESULT([** -- Invenio Development Team <info@invenio-software.org> **]) AC_MSG_RESULT([****************************************************************************]) ## end of file diff --git a/modules/miscutil/etc/Makefile.am b/modules/miscutil/etc/Makefile.am index 90cb609b4..2ae45fe4c 100644 --- a/modules/miscutil/etc/Makefile.am +++ b/modules/miscutil/etc/Makefile.am @@ -1,18 +1,18 @@ ## This file is part of Invenio. -## Copyright (C) 2010, 2011 CERN. +## Copyright (C) 2010, 2011, 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -SUBDIRS = bash_completion.d ckeditor_scientificchar +SUBDIRS = bash_completion.d ckeditor_scientificchar templates diff --git a/modules/miscutil/etc/Makefile.am b/modules/miscutil/etc/templates/Makefile.am similarity index 73% copy from modules/miscutil/etc/Makefile.am copy to modules/miscutil/etc/templates/Makefile.am index 90cb609b4..5314db236 100644 --- a/modules/miscutil/etc/Makefile.am +++ b/modules/miscutil/etc/templates/Makefile.am @@ -1,18 +1,25 @@ ## This file is part of Invenio. -## Copyright (C) 2010, 2011 CERN. +## Copyright (C) 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -SUBDIRS = bash_completion.d ckeditor_scientificchar +templatesdir = $(sysconfdir)/templates +templates_DATA = invenio-apache-vhost.tpl \ + invenio-apache-vhost.conf.tpl \ + invenio-apache-vhost-ssl.conf.tpl + +EXTRA_DIST = $(templates_DATA) + +CLEANFILES = *~ *.tmp diff --git a/modules/miscutil/etc/Makefile.am b/modules/miscutil/etc/templates/invenio-apache-vhost-ssl.conf.tpl similarity index 54% copy from modules/miscutil/etc/Makefile.am copy to modules/miscutil/etc/templates/invenio-apache-vhost-ssl.conf.tpl index 90cb609b4..0a0742bf6 100644 --- a/modules/miscutil/etc/Makefile.am +++ b/modules/miscutil/etc/templates/invenio-apache-vhost-ssl.conf.tpl @@ -1,18 +1,42 @@ +{# ## This file is part of Invenio. -## Copyright (C) 2010, 2011 CERN. +## Copyright (C) 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +#} +{%- extends "invenio-apache-vhost.tpl" -%} -SUBDIRS = bash_completion.d ckeditor_scientificchar +{% set log_suffix = '-ssl' %} + +{%- block header -%} +ServerSignature Off +ServerTokens Prod +{{ '#' if not listen_directive_needed }}{{ 'Listen ' + vhost_site_url_port}} +NameVirtualHost {{ vhost_ip_address }}:{{ vhost_site_url_port }} +{{ ssl_pem_directive }} +{{ ssl_crt_directive }} +{{ ssl_key_directive }} +{{ super() }} +{%- endblock -%} + +{%- block server %} + {{ super() }} + SSLEngine on +{%- endblock server -%} + +{%- block wsgi %} + RedirectMatch /sslredirect/(.*) http://$1 + {{ super() }} +{%- endblock wsgi -%} diff --git a/modules/miscutil/etc/templates/invenio-apache-vhost.conf.tpl b/modules/miscutil/etc/templates/invenio-apache-vhost.conf.tpl new file mode 100644 index 000000000..b2bad5fe6 --- /dev/null +++ b/modules/miscutil/etc/templates/invenio-apache-vhost.conf.tpl @@ -0,0 +1,39 @@ +{# +## This file is part of Invenio. +## Copyright (C) 2013 CERN. +## +## Invenio is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2 of the +## License, or (at your option) any later version. +## +## Invenio is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Invenio; if not, write to the Free Software Foundation, Inc., +## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +#} +{%- extends "invenio-apache-vhost.tpl" -%} + +{%- block header -%} +AddDefaultCharset UTF-8 +ServerSignature Off +ServerTokens Prod +NameVirtualHost {{ vhost_ip_address }}:{{ vhost_site_url_port }} +{{ '#' if not listen_directive_needed }}{{ 'Listen ' + vhost_site_url_port}} +{{ '#' if not wsgi_socket_directive_needed }}WSGISocketPrefix {{ [config.CFG_PREFIX, 'var', 'run']|path_join }} +{{ super() }} +{%- endblock header -%} + +{%- block wsgi %} + WSGIDaemonProcess invenio processes=5 threads=1 user={{ config.CFG_RUNNING_AS_USER }} display-name=%{GROUP} inactivity-timeout=3600 maximum-requests=10000 + WSGIImportScript {{ config.CFG_WSGIDIR }}/invenio.wsgi process-group=invenio application-group=%{GLOBAL} + {{ super() }} +{%- endblock wsgi -%} + +{%- block auth_shibboleth -%} +{# shibboleth is allowed only on https #} +{%- endblock auth_shibboleth -%} diff --git a/modules/miscutil/etc/templates/invenio-apache-vhost.tpl b/modules/miscutil/etc/templates/invenio-apache-vhost.tpl new file mode 100644 index 000000000..5c90354bc --- /dev/null +++ b/modules/miscutil/etc/templates/invenio-apache-vhost.tpl @@ -0,0 +1,172 @@ +{# +## This file is part of Invenio. +## Copyright (C) 2013 CERN. +## +## Invenio is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2 of the +## License, or (at your option) any later version. +## +## Invenio is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Invenio; if not, write to the Free Software Foundation, Inc., +## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +#} +{# +Apache configuration template +============================= + +blocks: +------- +- configuration + - header + - virtual_host + - server + - directory_web + - logging + - alliases + - wsgi + - xsendfile_directive + - directory_wsgi + - deflate_directive + - auth_shibboleth + +variables: +---------- +- log_suffix: adds string to apache log names `{% set log_suffix = '' %}` + (default: '') + +#} +{%- + block configuration -%} +{%- block header -%} +WSGIRestrictStdout Off +{% if os.environ.get('VIRTUAL_ENV', False) %}WSGIPythonHome {{ os.environ['VIRTUAL_ENV'] }}{% endif %} + +<Files *.pyc> + deny from all +</Files> +<Files *~> + deny from all +</Files> +{%- endblock header -%} +{%- block virtual_host %} +<VirtualHost {{ vhost_ip_address }}:{{ vhost_site_url_port }}> + {%- block server %} + ServerName {{ servername }} + ServerAlias {{ serveralias }} + ServerAdmin {{ config.CFG_SITE_ADMIN_EMAIL }} + {%- endblock server -%} + {%- block directory_web %} + DocumentRoot {{ config.CFG_WEBDIR }} + <Directory {{ config.CFG_WEBDIR }}> + Options FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + Allow from all + </Directory> + {%- endblock directory_web -%} + {%- block logging %} + ErrorLog {{ config.CFG_LOGDIR }}/apache{{ log_suffix }}.err + LogLevel warn + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %D" combined_with_timing + CustomLog {{ config.CFG_LOGDIR }}/apache{{ log_suffix }}.log combined_with_timing + {%- endblock logging -%} + {%- block aliases %} + DirectoryIndex index.en.html index.html + Alias /static/ {{ config.CFG_WEBDIR }}/static/ + Alias /img/ {{ config.CFG_WEBDIR }}/img/ + Alias /css/ {{ config.CFG_WEBDIR }}/css/ + Alias /js/ {{ config.CFG_WEBDIR }}/js/ + Alias /flash/ {{ config.CFG_WEBDIR }}/flash/ + Alias /export/ {{ config.CFG_WEBDIR }}/export/ + Alias /MathJax/ {{ config.CFG_WEBDIR }}/MathJax/ + Alias /jsCalendar/ {{ config.CFG_WEBDIR }}/jsCalendar/ + Alias /ckeditor/ {{ config.CFG_WEBDIR }}/ckeditor/ + Alias /mediaelement/ {{ config.CFG_WEBDIR }}/mediaelement/ + AliasMatch /sitemap-(.*) {{ config.CFG_WEBDIR }}/sitemap-$1 + Alias /robots.txt {{ config.CFG_WEBDIR }}/robots.txt + Alias /favicon.ico {{ config.CFG_WEBDIR }}/favicon.ico + Alias /apple-touch-icon-144-precomposed.png {{ config.CFG_WEBDIR }}/apple-touch-icon-144-precomposed.png + Alias /apple-touch-icon-114-precomposed.png {{ config.CFG_WEBDIR }}/apple-touch-icon-114-precomposed.png + Alias /apple-touch-icon-72-precomposed.png {{ config.CFG_WEBDIR }}/apple-touch-icon-72-precomposed.png + Alias /apple-touch-icon-57-precomposed.png {{ config.CFG_WEBDIR }}/apple-touch-icon-57-precomposed.png + {%- endblock aliases -%} + {%- block wsgi %} + WSGIScriptAlias / {{ config.CFG_WSGIDIR }}/invenio.wsgi + WSGIPassAuthorization On + {% endblock wsgi -%} + {%- block xsendfile_directive %} + {{ '#' if not config.CFG_BIBDOCFILE_USE_XSENDFILE }}XSendFile On + {%- for xsfp in [config.CFG_BIBDOCFILE_FILEDIR, + config.CFG_WEBDIR, + config.CFG_WEBSUBMIT_STORAGEDIR, + config.CFG_TMPDIR, + [config.CFG_PREFIX, 'var', 'tmp', 'attachfile']|path_join, + [config.CFG_PREFIX, 'var', 'data', 'comments']|path_join, + [config.CFG_PREFIX, 'var', 'data', 'baskets', 'comments']|path_join, + '/tmp'] %} + {{ '#' if not config.CFG_BIBDOCFILE_USE_XSENDFILE }}XSendFilePath {{ xsfp }} + {%- endfor -%} + {%- endblock xsendfile_directive -%} + {%- block directory_wsgi %} + <Directory {{ config.CFG_WSGIDIR }}> + WSGIProcessGroup invenio + WSGIApplicationGroup %{GLOBAL} + Options FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + Allow from all + </Directory> + {%- endblock directory_wsgi -%} + {%- block deflate_directive -%} + {%- if config.CFG_WEBSTYLE_HTTP_USE_COMPRESSION %} + ## Configuration snippet taken from: + ## <http://httpd.apache.org/docs/2.2/mod/mod_deflate.html> + <IfModule mod_deflate.c> + SetOutputFilter DEFLATE + + # Netscape 4.x has some problems... + BrowserMatch ^Mozilla/4 gzip-only-text/html + + # Netscape 4.06-4.08 have some more problems + BrowserMatch ^Mozilla/4\.0[678] no-gzip + + # MSIE masquerades as Netscape, but it is fine + # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html + + # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 + # the above regex won't work. You can use the following + # workaround to get the desired effect: + BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html + + # Don't compress images + SetEnvIfNoCase Request_URI \ + \.(?:gif|jpe?g|png)$ no-gzip dont-vary + + # Make sure proxies don't deliver the wrong content + <IfModule mod_header.c> + Header append Vary User-Agent env=!dont-vary + </IfModule> + </IfModule> + {% endif -%} + {%- endblock deflate_directive -%} + {%- block auth_shibboleth -%} + {%- if config.CFG_EXTERNAL_AUTH_USING_SSO %} + <Location ~ "/youraccount/login|Shibboleth.sso/"> + SSLRequireSSL # The modules only work using HTTPS + AuthType shibboleth + ShibRequireSession On + ShibRequireAll On + ShibExportAssertion Off + require valid-user + </Location> + {% endif -%} + {%- endblock auth_shibboleth %} +</VirtualHost> +{%- endblock virtual_host -%} +{%- endblock -%} \ No newline at end of file diff --git a/modules/miscutil/lib/Makefile.am b/modules/miscutil/lib/Makefile.am index 1d2daae9f..c937b77a8 100644 --- a/modules/miscutil/lib/Makefile.am +++ b/modules/miscutil/lib/Makefile.am @@ -1,172 +1,173 @@ ## This file is part of Invenio. ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. SUBDIRS = upgrades pylibdir = $(libdir)/python/invenio pylib_DATA = __init__.py \ - cache.py \ + apache_manager.py \ + cache.py \ errorlib.py \ errorlib_unit_tests.py \ errorlib_model.py \ errorlib_webinterface.py \ errorlib_regression_tests.py \ flask_sslify.py \ celery.py \ celery_config.py \ celery_unit_tests.py \ celery_tasks.py \ data_cacher.py \ database_manager.py \ dbdump.py \ web_api_key.py \ web_api_key_model.py \ web_api_key_unit_tests.py \ dbquery.py \ dbquery_unit_tests.py \ dbquery_regression_tests.py \ dataciteutils.py \ dataciteutils_tester.py \ logicutils.py \ logicutils_unit_tests.py \ mailutils.py \ miscutil_config.py \ miscutil_model.py \ messages.py \ messages_unit_tests.py \ textutils.py \ textutils_unit_tests.py \ dateutils.py \ dateutils_unit_tests.py \ htmlutils.py \ htmlutils_unit_tests.py \ testutils.py \ testutils_regression_tests.py \ inveniocfg_upgrader.py \ inveniocfg_upgrader_model.py \ inveniocfg_upgrader_unit_tests.py \ upgrader_manager.py \ invenio_connector.py \ invenio_connector_regression_tests.py \ jinja2utils.py \ urlutils.py \ urlutils_unit_tests.py \ w3c_validator.py \ importutils.py \ importutils_unit_tests.py \ intbitset_unit_tests.py \ intbitset_helper.py \ inveniocfg.py \ inveniomanage.py \ inveniocfg_unit_tests.py \ settings.py \ shellutils.py \ shellutils_unit_tests.py \ sqlalchemyutils.py \ sqlalchemyutils_mysql.py \ pluginutils.py \ pluginutils_unit_tests.py \ plotextractor.py \ plotextractor_converter.py \ plotextractor_getter.py \ plotextractor_output_utils.py \ plotextractor_unit_tests.py \ plotextractor_regression_tests.py \ plotextractor_config.py \ solrutils_bibindex_indexer.py \ solrutils_bibindex_searcher.py \ solrutils_bibrank_indexer.py \ solrutils_bibrank_searcher.py \ solrutils_config.py \ solrutils_regression_tests.py \ solrutils_unit_tests.py \ xapianutils_bibindex_indexer.py \ xapianutils_bibindex_searcher.py \ xapianutils_bibrank_indexer.py \ xapianutils_bibrank_searcher.py \ xapianutils_config.py \ remote_debugger.py \ remote_debugger_config.py \ remote_debugger_wsgi_reload.py \ jsonutils.py \ jsonutils_unit_tests.py \ sequtils_cnum.py \ sequtils.py \ sequtils_model.py \ sequtils_regression_tests.py \ crossrefutils.py \ flaskshell.py \ wtforms_utils.py \ sherpa_romeo.py \ sherpa_romeo_testing.py \ orcid.py \ xmlDict.py jsdir=$(localstatedir)/www/js js_DATA = jquery.mathpreview.js noinst_DATA = testimport.py \ kwalitee.py \ pep8.py tmpdir = $(prefix)/var/tmp tmp_DATA = intbitset_example.int EXTRA_DIST = $(pylib_DATA) \ $(tmp_DATA) \ $(js_DATA) \ testimport.py \ kwalitee.py \ pep8.py \ intbitset.pyx \ intbitset.c \ intbitset.h \ intbitset_impl.c \ intbitset_setup.py \ intbitset.pyx \ solrutils \ solrutils/schema.xml \ solrutils/java_sources.txt \ solrutils/org \ solrutils/org/invenio_software \ solrutils/org/invenio_software/solr \ solrutils/org/invenio_software/solr/BitSetFieldCollector.java \ solrutils/org/invenio_software/solr/InvenioFacetComponent.java \ solrutils/org/invenio_software/solr/FieldCollectorBase.java \ solrutils/org/invenio_software/solr/IntFieldCollector.java \ solrutils/org/invenio_software/solr/FieldCollector.java \ solrutils/org/invenio_software/solr/InvenioQueryComponent.java \ solrutils/org/invenio_software/solr/InvenioBitsetStreamResponseWriter.java \ solrutils/org/invenio_software/solr/InvenioBitSet.java \ solrutils/org/invenio_software/solr/StringFieldCollector.java \ solrutils/solrconfig.xml all: $(PYTHON) $(srcdir)/intbitset_setup.py build_ext install-data-hook: $(PYTHON) $(srcdir)/testimport.py ${prefix} @find ${srcdir} -name intbitset.so -exec cp {} ${pylibdir} \; CLEANFILES = *~ *.tmp *.pyc clean-local: rm -rf build diff --git a/modules/miscutil/lib/apache_manager.py b/modules/miscutil/lib/apache_manager.py new file mode 100644 index 000000000..62221e5d5 --- /dev/null +++ b/modules/miscutil/lib/apache_manager.py @@ -0,0 +1,171 @@ +# -*- coding: utf-8 -*- +## +## This file is part of Invenio. +## Copyright (C) 2013 CERN. +## +## Invenio is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2 of the +## License, or (at your option) any later version. +## +## Invenio is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Invenio; if not, write to the Free Software Foundation, Inc., +## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + +from flask.ext.script import Manager + +manager = Manager(usage="Perform Apache operations.") + + +@manager.option('-f', '--force', dest='force') +@manager.option('--no-ssl', dest='no_ssl') +def create_conf(force=False, no_ssl=True): + """ + Create a apache configuration files. + """ + import os + import pwd + import sys + import shutil + from flask import current_app + from jinja2 import TemplateNotFound + from invenio.jinja2utils import render_template_to_string + from invenio.textutils import wrap_text_in_a_box + from invenio.access_control_config import CFG_EXTERNAL_AUTH_USING_SSO + + CFG_PREFIX = current_app.config.get('CFG_PREFIX', '') + + def get_context(): + from invenio.inveniocfg import _detect_ip_address + + conf = current_app.config + + ## Apache vhost conf file is distro specific, so analyze needs: + # Gentoo (and generic defaults): + listen_directive_needed = True + ssl_pem_directive_needed = False + ssl_pem_path = CFG_PREFIX + '/etc/apache/ssl/apache.pem' + ssl_crt_path = CFG_PREFIX + '/etc/apache/ssl/server.crt' + ssl_key_path = CFG_PREFIX + '/etc/apache/ssl/server.key' + vhost_ip_address_needed = False + wsgi_socket_directive_needed = False + # Debian: + if os.path.exists(os.path.sep + 'etc' + os.path.sep + 'debian_version'): + listen_directive_needed = False + ssl_pem_directive_needed = True + ssl_pem_path = '/etc/apache2/ssl/apache.pem' + ssl_crt_path = '/etc/apache2/ssl/server.crt' + ssl_key_path = '/etc/apache2/ssl/server.key' + # RHEL/SLC: + if os.path.exists(os.path.sep + 'etc' + os.path.sep + 'redhat-release'): + listen_directive_needed = False + ssl_crt_path = '/etc/pki/tls/certs/localhost.crt' + ssl_key_path = '/etc/pki/tls/private/localhost.key' + vhost_ip_address_needed = True + wsgi_socket_directive_needed = True + # maybe we are using non-standard ports? + vhost_site_url = conf.get('CFG_SITE_URL').replace("http://", "") + if vhost_site_url.startswith("https://"): + ## The installation is configured to require HTTPS for any connection + vhost_site_url = vhost_site_url.replace("https://", "") + vhost_site_url_port = '80' + vhost_site_secure_url = conf.get('CFG_SITE_SECURE_URL').replace("https://", "").replace("http://", "") + vhost_site_secure_url_port = '443' + if ':' in vhost_site_url: + vhost_site_url, vhost_site_url_port = vhost_site_url.split(':', 1) + if ':' in vhost_site_secure_url: + vhost_site_secure_url, vhost_site_secure_url_port = vhost_site_secure_url.split(':', 1) + if vhost_site_url_port != '80' or vhost_site_secure_url_port != '443': + listen_directive_needed = True + + apc1 = {'vhost_site_url_port': vhost_site_url_port, + 'servername': vhost_site_url, + 'serveralias': vhost_site_url.split('.')[0], + 'vhost_ip_address': vhost_ip_address_needed and + _detect_ip_address() or '*', + 'wsgi_socket_directive_needed': wsgi_socket_directive_needed, + 'listen_directive_needed': listen_directive_needed, + } + + apc2 = {'vhost_site_url_port': vhost_site_secure_url_port, + 'servername': vhost_site_secure_url, + 'serveralias': vhost_site_secure_url.split('.')[0], + 'vhost_ip_address': vhost_ip_address_needed and + _detect_ip_address() or '*', + 'wsgi_socket_directive_needed': wsgi_socket_directive_needed, + 'ssl_pem_directive': ssl_pem_directive_needed and + 'SSLCertificateFile %s' % ssl_pem_path or + '#SSLCertificateFile %s' % ssl_pem_path, + 'ssl_crt_directive': ssl_pem_directive_needed and + '#SSLCertificateFile %s' % ssl_crt_path or + 'SSLCertificateFile %s' % ssl_crt_path, + 'ssl_key_directive': ssl_pem_directive_needed and + '#SSLCertificateKeyFile %s' % ssl_key_path or + 'SSLCertificateKeyFile %s' % ssl_key_path, + 'listen_directive_needed': listen_directive_needed, + } + + return [apc1, apc2] + + current_app.config.update( + CFG_RUNNING_AS_USER=pwd.getpwuid(os.getuid())[0], + CFG_EXTERNAL_AUTH_USING_SSO=CFG_EXTERNAL_AUTH_USING_SSO, + CFG_WSGIDIR=os.path.join(CFG_PREFIX, 'var', 'www-wsgi')) + + apache_conf_dir = current_app.config.get('CFG_ETCDIR') + os.sep + 'apache' + + print ">>> Going to create Apache conf files..." + conf_files = ['invenio-apache-vhost.conf', 'invenio-apache-vhost-ssl.conf'] + conf_files = conf_files[:1 if no_ssl else 2] + + if not os.path.exists(apache_conf_dir): + os.mkdir(apache_conf_dir) + + for local_file, context in zip(conf_files, + get_context()[:1 if no_ssl else 2]): + print ">>> Writing %s ..." % local_file + + try: + apache_vhost_file = apache_conf_dir + os.sep + local_file + if os.path.exists(apache_vhost_file): + shutil.copy(apache_vhost_file, + apache_vhost_file + '.OLD') + + with open(apache_vhost_file, 'w') as f: + out = render_template_to_string(local_file + '.tpl', os=os, + **context) + print >> f, out + + except TemplateNotFound: + print >> sys.stderr, "Could not find template %s" % local_file + + print wrap_text_in_a_box("""\ +Apache virtual host configuration file(s) for your Invenio site +was(were) created. Please check created file(s) and activate virtual +host(s). For example, you can put the following include statements in +your httpd.conf:\n + +%s + +%s + + +Please see the INSTALL file for more details. + """ % tuple(map(lambda x: "Include " + apache_conf_dir.encode('utf-8') + os.sep + x, + list(conf_files)))) + print ">>> Apache conf files created." + + +def main(): + from invenio.webinterface_handler_flask import create_invenio_flask_app + app = create_invenio_flask_app() + manager.app = app + manager.run() + +if __name__ == '__main__': + main() diff --git a/modules/miscutil/lib/inveniocfg.py b/modules/miscutil/lib/inveniocfg.py index 6bcd07642..94c482007 100644 --- a/modules/miscutil/lib/inveniocfg.py +++ b/modules/miscutil/lib/inveniocfg.py @@ -1,1668 +1,1359 @@ # -*- coding: utf-8 -*- ## ## This file is part of Invenio. ## Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """ Invenio configuration and administration CLI tool. Usage: inveniocfg [options] General options: -h, --help print this help -V, --version print version number Options to finish your installation: --create-secret-key generate random CFG_SITE_SECRET_KEY --create-apache-conf create Apache configuration files --create-tables create DB tables for Invenio --load-webstat-conf load the WebStat configuration --drop-tables drop DB tables of Invenio --check-openoffice check for correctly set up of openoffice temporary directory Options to set up and test a demo site: --create-demo-site create demo site --load-demo-records load demo records --remove-demo-records remove demo records, keeping demo site --drop-demo-site drop demo site configurations too --run-unit-tests run unit test suite (needs demo site) --run-regression-tests run regression test suite (needs demo site) --run-web-tests run web tests in a browser (needs demo site, Firefox, Selenium IDE) --run-flask-tests run Flask test suite Options to update config files in situ: --update-all perform all the update options --update-config-py update config.py file from invenio.conf file --update-dbquery-py update dbquery.py with DB credentials from invenio.conf --update-dbexec update dbexec with DB credentials from invenio.conf --update-bibconvert-tpl update bibconvert templates with CFG_SITE_URL from invenio.conf --update-web-tests update web test cases with CFG_SITE_URL from invenio.conf Options to update DB tables: --reset-all perform all the reset options --reset-sitename reset tables to take account of new CFG_SITE_NAME* --reset-siteadminemail reset tables to take account of new CFG_SITE_ADMIN_EMAIL --reset-fieldnames reset tables to take account of new I18N names from PO files --reset-recstruct-cache reset record structure cache according to CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE Options to upgrade your installation: --upgrade apply all pending upgrades --upgrade-check run pre-upgrade checks for all pending upgrades --upgrade-show-pending show pending upgrades ready to be applied --upgrade-show-applied show history of applied upgrades --upgrade-create-standard-recipe create a new upgrade recipe (for developers) --upgrade-create-release-recipe create a new release upgrade recipe (for developers) Options to help the work: --list print names and values of all options from conf files --get <some-opt> get value of a given option from conf files --conf-dir </some/path> path to directory where invenio*.conf files are [optional] --detect-system-details print system details such as Apache/Python/MySQL versions """ __revision__ = "$Id$" from ConfigParser import ConfigParser from optparse import OptionParser, OptionGroup, IndentedHelpFormatter, Option, \ OptionError import os import random import re import shutil import socket import string import sys def print_usage(): """Print help.""" print __doc__ def get_version(): """ Get running version of Invenio """ from invenio.config import CFG_VERSION return CFG_VERSION def print_version(): """Print version information.""" print get_version() def convert_conf_option(option_name, option_value): """ Convert conf option into Python config.py line, converting values to ints or strings as appropriate. """ ## 1) convert option name to uppercase: option_name = option_name.upper() ## 1a) adjust renamed variables: if option_name in ['CFG_WEBSUBMIT_DOCUMENT_FILE_MANAGER_DOCTYPES', 'CFG_WEBSUBMIT_DOCUMENT_FILE_MANAGER_RESTRICTIONS', 'CFG_WEBSUBMIT_DOCUMENT_FILE_MANAGER_MISC', 'CFG_WEBSUBMIT_FILESYSTEM_BIBDOC_GROUP_LIMIT', 'CFG_WEBSUBMIT_ADDITIONAL_KNOWN_FILE_EXTENSIONS', 'CFG_WEBSUBMIT_DESIRED_CONVERSIONS']: new_option_name = option_name.replace('WEBSUBMIT', 'BIBDOCFILE') print >> sys.stderr, ("""WARNING: %s has been renamed to %s. Please, update your invenio-local.conf file accordingly.""" % (option_name, new_option_name)) option_name = new_option_name ## 2) convert option value to int or string: if option_name in ['CFG_BIBUPLOAD_REFERENCE_TAG', 'CFG_BIBUPLOAD_EXTERNAL_SYSNO_TAG', 'CFG_BIBUPLOAD_EXTERNAL_OAIID_TAG', 'CFG_BIBUPLOAD_EXTERNAL_OAIID_PROVENANCE_TAG', 'CFG_BIBUPLOAD_STRONG_TAGS', 'CFG_BIBFORMAT_HIDDEN_TAGS',]: # some options are supposed be string even when they look like # numeric option_value = '"' + option_value + '"' else: try: option_value = int(option_value) except ValueError: option_value = '"' + option_value + '"' ## 3a) special cases: chars regexps if option_name in ['CFG_BIBINDEX_CHARS_ALPHANUMERIC_SEPARATORS', 'CFG_BIBINDEX_CHARS_PUNCTUATION']: option_value = 'r"[' + option_value[1:-1] + ']"' ## 3abis) special cases: real regexps if option_name in ['CFG_BIBINDEX_PERFORM_OCR_ON_DOCNAMES', 'CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS']: option_value = 'r"' + option_value[1:-1] + '"' ## 3b) special cases: True, False, None if option_value in ['"True"', '"False"', '"None"']: option_value = option_value[1:-1] ## 3c) special cases: dicts and real pythonic lists if option_name in ['CFG_WEBSEARCH_FIELDS_CONVERT', 'CFG_BATCHUPLOADER_WEB_ROBOT_RIGHTS', 'CFG_WEBSEARCH_FULLTEXT_SNIPPETS', 'CFG_WEBSEARCH_FULLTEXT_SNIPPETS_CHARS', 'CFG_SITE_EMERGENCY_EMAIL_ADDRESSES', 'CFG_BIBMATCH_FUZZY_WORDLIMITS', 'CFG_BIBMATCH_QUERY_TEMPLATES', 'CFG_WEBSEARCH_SYNONYM_KBRS', 'CFG_BIBINDEX_SYNONYM_KBRS', 'CFG_WEBCOMMENT_EMAIL_REPLIES_TO', 'CFG_WEBCOMMENT_RESTRICTION_DATAFIELD', 'CFG_WEBCOMMENT_ROUND_DATAFIELD', 'CFG_BIBUPLOAD_FFT_ALLOWED_EXTERNAL_URLS', 'CFG_BIBSCHED_NODE_TASKS', 'CFG_BIBEDIT_EXTEND_RECORD_WITH_COLLECTION_TEMPLATE', 'CFG_OAI_METADATA_FORMATS', 'CFG_BIBDOCFILE_DESIRED_CONVERSIONS', 'CFG_BIBDOCFILE_BEST_FORMATS_TO_EXTRACT_TEXT_FROM', 'CFG_WEB_API_KEY_ALLOWED_URL', 'CFG_BIBDOCFILE_DOCUMENT_FILE_MANAGER_MISC', 'CFG_BIBDOCFILE_DOCUMENT_FILE_MANAGER_DOCTYPES', 'CFG_BIBDOCFILE_DOCUMENT_FILE_MANAGER_RESTRICTIONS', 'CFG_DEVEL_TEST_DATABASE_ENGINES', 'CFG_REFEXTRACT_KBS_OVERRIDE']: try: option_value = option_value[1:-1] except TypeError: if option_name in ('CFG_WEBSEARCH_FULLTEXT_SNIPPETS',): print >> sys.stderr, """WARNING: CFG_WEBSEARCH_FULLTEXT_SNIPPETS has changed syntax: it can be customised to display different snippets for different document types. See the corresponding documentation in invenio.conf. You may want to customise your invenio-local.conf configuration accordingly.""" option_value = """{'': %s}""" % option_value else: print >> sys.stderr, "ERROR: type error in %s value %s." % \ (option_name, option_value) sys.exit(1) ## 3cbis) very special cases: dicts with backward compatible string if option_name in ['CFG_BIBINDEX_SPLASH_PAGES']: if option_value.startswith('"{') and option_value.endswith('}"'): option_value = option_value[1:-1] else: option_value = """{%s: ".*"}""" % option_value ## 3d) special cases: comma-separated lists if option_name in ['CFG_SITE_LANGS', 'CFG_BIBDOCFILE_ADDITIONAL_KNOWN_FILE_EXTENSIONS', 'CFG_WEBSEARCH_USE_MATHJAX_FOR_FORMATS', 'CFG_BIBUPLOAD_STRONG_TAGS', 'CFG_BIBFORMAT_HIDDEN_TAGS', 'CFG_BIBSCHED_GC_TASKS_TO_REMOVE', 'CFG_BIBSCHED_GC_TASKS_TO_ARCHIVE', 'CFG_BIBUPLOAD_FFT_ALLOWED_LOCAL_PATHS', 'CFG_BIBUPLOAD_CONTROLLED_PROVENANCE_TAGS', 'CFG_BIBUPLOAD_DELETE_FORMATS', 'CFG_WEBSEARCH_ENABLED_SEARCH_INTERFACES', 'CFG_WEBSTYLE_HTTP_STATUS_ALERT_LIST', 'CFG_WEBSEARCH_RSS_I18N_COLLECTIONS', 'CFG_BATCHUPLOADER_FILENAME_MATCHING_POLICY', 'CFG_BIBAUTHORID_EXTERNAL_CLAIMED_RECORDS_KEY', 'CFG_BIBCIRCULATION_ITEM_STATUS_OPTIONAL', 'CFG_PLOTEXTRACTOR_DISALLOWED_TEX', 'CFG_OAI_FRIENDS', 'CFG_WEBSTYLE_REVERSE_PROXY_IPS', 'CFG_BIBEDIT_AUTOCOMPLETE_INSTITUTIONS_FIELDS', 'CFG_BIBFORMAT_DISABLE_I18N_FOR_CACHED_FORMATS', 'CFG_BIBFORMAT_HIDDEN_FILE_FORMATS', 'CFG_FLASK_DISABLED_BLUEPRINTS', 'CFG_DEVEL_TOOLS']: out = "[" for elem in option_value[1:-1].split(","): if elem: elem = elem.strip() if option_name in ['CFG_WEBSEARCH_ENABLED_SEARCH_INTERFACES']: # 3d1) integer values out += "%i, " % int(elem) else: # 3d2) string values out += "'%s', " % elem out += "]" option_value = out ## 3e) special cases: multiline if option_name == 'CFG_OAI_IDENTIFY_DESCRIPTION': # make triple quotes option_value = '""' + option_value + '""' ## 3f) ignore some options: if option_name.startswith('CFG_SITE_NAME_INTL'): # treated elsewhere return ## 3g) special cases: float if option_name in ['CFG_BIBDOCFILE_MD5_CHECK_PROBABILITY', 'CFG_BIBMATCH_LOCAL_SLEEPTIME', 'CFG_BIBMATCH_REMOTE_SLEEPTIME', 'CFG_PLOTEXTRACTOR_DOWNLOAD_TIMEOUT', 'CFG_BIBMATCH_FUZZY_MATCH_VALIDATION_LIMIT']: option_value = float(option_value[1:-1]) ## 3h) special cases: bibmatch validation list if option_name in ['CFG_BIBMATCH_MATCH_VALIDATION_RULESETS']: option_value = option_value[1:-1] ## 4a) dropped variables if option_name in ['CFG_BATCHUPLOADER_WEB_ROBOT_AGENT']: print >> sys.stderr, ("""ERROR: CFG_BATCHUPLOADER_WEB_ROBOT_AGENT has been dropped in favour of CFG_BATCHUPLOADER_WEB_ROBOT_AGENTS. Please, update your invenio-local.conf file accordingly.""") option_value = option_value[1:-1] elif option_name in ['CFG_WEBSUBMIT_DOCUMENT_FILE_MANAGER_DOCTYPES', 'CFG_WEBSUBMIT_DOCUMENT_FILE_MANAGER_RESTRICTIONS', 'CFG_WEBSUBMIT_DOCUMENT_FILE_MANAGER_MISC', 'CFG_WEBSUBMIT_FILESYSTEM_BIBDOC_GROUP_LIMIT', 'CFG_WEBSUBMIT_ADDITIONAL_KNOWN_FILE_EXTENSIONS', 'CFG_WEBSUBMIT_DESIRED_CONVERSIONS']: new_option_name = option_name.replace('WEBSUBMIT', 'BIBDOCFILE') print >> sys.stderr, ("""ERROR: %s has been renamed to %s. Please, update your invenio-local.conf file accordingly.""" % (option_name, new_option_name)) option_name = new_option_name elif option_name in ['CFG_WEBSTYLE_INSPECT_TEMPLATES']: print >> sys.stderr, ("""ERROR: CFG_WEBSTYLE_INSPECT_TEMPLATES has been dropped in favour of CFG_DEVEL_TOOLS. Please, update your invenio-local.conf file accordingly.""") return ## 5) finally, return output line: return '%s = %s' % (option_name, option_value) def cli_cmd_update_config_py(conf): """ Update new config.py from conf options, keeping previous config.py in a backup copy. """ print ">>> Going to update config.py..." ## location where config.py is: configpyfile = conf.get("Invenio", "CFG_PYLIBDIR") + \ os.sep + 'invenio' + os.sep + 'config.py' ## backup current config.py file: if os.path.exists(configpyfile): shutil.copy(configpyfile, configpyfile + '.OLD') ## here we go: fdesc = open(configpyfile, 'w') ## generate preamble: fdesc.write("# -*- coding: utf-8 -*-\n") fdesc.write("# DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED\n") fdesc.write("# FROM INVENIO.CONF BY EXECUTING:\n") fdesc.write("# " + " ".join(sys.argv) + "\n") ## special treatment for CFG_SITE_NAME_INTL options: fdesc.write("CFG_SITE_NAME_INTL = {}\n") for lang in conf.get("Invenio", "CFG_SITE_LANGS").split(","): fdesc.write("CFG_SITE_NAME_INTL['%s'] = \"%s\"\n" % (lang, conf.get("Invenio", "CFG_SITE_NAME_INTL_" + lang))) ## special treatment for CFG_SITE_SECURE_URL that may be empty, in ## which case it should be put equal to CFG_SITE_URL: if not conf.get("Invenio", "CFG_SITE_SECURE_URL"): conf.set("Invenio", "CFG_SITE_SECURE_URL", conf.get("Invenio", "CFG_SITE_URL")) ## process all the options normally: sections = conf.sections() sections.sort() for section in sections: options = conf.options(section) options.sort() for option in options: if not option.upper().startswith('CFG_DATABASE_'): # put all options except for db credentials into config.py line_out = convert_conf_option(option, conf.get(section, option)) if line_out: fdesc.write(line_out + "\n") ## special treatment for CFG_SITE_SECRET_KEY that can not be empty if not conf.get("Invenio", "CFG_SITE_SECRET_KEY"): CFG_BINDIR = conf.get("Invenio", "CFG_BINDIR") + os.sep print >> sys.stderr, """WARNING: CFG_SITE_SECRET_KEY can not be empty. You may want to customise your invenio-local.conf configuration accordingly. $ %sinveniocfg --create-secret-key $ %sinveniocfg --update-config-py """ % (CFG_BINDIR, CFG_BINDIR) ## FIXME: special treatment for experimental variables ## CFG_WEBSEARCH_ENABLED_SEARCH_INTERFACES and CFG_WEBSEARCH_DEFAULT_SEARCH_INTERFACE ## (not offering them in invenio.conf since they will be refactored) fdesc.write("CFG_WEBSEARCH_DEFAULT_SEARCH_INTERFACE = 0\n") fdesc.write("CFG_WEBSEARCH_ENABLED_SEARCH_INTERFACES = [0, 1,]\n") ## generate postamble: fdesc.write("") fdesc.write("# END OF GENERATED FILE") ## we are done: fdesc.close() print "You may want to restart Apache now." print ">>> config.py updated successfully." def cli_cmd_update_dbquery_py(conf): """ Update lib/dbquery.py file with DB parameters read from conf file. Note: this edits dbquery.py in situ, taking a backup first. Use only when you know what you are doing. """ print ">>> Going to update dbquery.py..." ## location where dbquery.py is: dbqueryconfigpyfile = conf.get("Invenio", "CFG_PYLIBDIR") + \ os.sep + 'invenio' + os.sep + 'dbquery_config.py' ## backup current dbquery.py file: if os.path.exists(dbqueryconfigpyfile + 'c'): shutil.copy(dbqueryconfigpyfile + 'c', dbqueryconfigpyfile + 'c.OLD') out = ["%s = '%s'\n" % (item.upper(), value) \ for item, value in conf.items('Invenio') \ if item.upper().startswith('CFG_DATABASE_')] fdesc = open(dbqueryconfigpyfile, 'w') fdesc.write("# -*- coding: utf-8 -*-\n") fdesc.writelines(out) fdesc.close() print "You may want to restart Apache now." print ">>> dbquery.py updated successfully." def cli_cmd_update_dbexec(conf): """ Update bin/dbexec file with DB parameters read from conf file. Note: this edits dbexec in situ, taking a backup first. Use only when you know what you are doing. """ print ">>> Going to update dbexec..." ## location where dbexec is: dbexecfile = conf.get("Invenio", "CFG_BINDIR") + \ os.sep + 'dbexec' ## backup current dbexec file: if os.path.exists(dbexecfile): shutil.copy(dbexecfile, dbexecfile + '.OLD') ## replace db parameters via sed: out = '' for line in open(dbexecfile, 'r').readlines(): match = re.search(r'^CFG_DATABASE_(HOST|PORT|NAME|USER|PASS|SLAVE)(\s*=\s*)\'.*\'$', line) if match: dbparam = 'CFG_DATABASE_' + match.group(1) out += "%s%s'%s'\n" % (dbparam, match.group(2), conf.get("Invenio", dbparam)) else: out += line fdesc = open(dbexecfile, 'w') fdesc.write(out) fdesc.close() print ">>> dbexec updated successfully." def cli_cmd_update_bibconvert_tpl(conf): """ Update bibconvert/config/*.tpl files looking for 856 http://.../CFG_SITE_RECORD lines, replacing URL with CFG_SITE_URL taken from conf file. Note: this edits tpl files in situ, taking a backup first. Use only when you know what you are doing. """ print ">>> Going to update bibconvert templates..." ## location where bibconvert/config/*.tpl are: tpldir = conf.get("Invenio", 'CFG_ETCDIR') + \ os.sep + 'bibconvert' + os.sep + 'config' ## find all *.tpl files: for tplfilename in os.listdir(tpldir): if tplfilename.endswith(".tpl"): ## change tpl file: tplfile = tpldir + os.sep + tplfilename shutil.copy(tplfile, tplfile + '.OLD') out = '' for line in open(tplfile, 'r').readlines(): match = re.search(r'^(.*)http://.*?/%s/(.*)$' % conf.get("Invenio", 'CFG_SITE_RECORD'), line) if match: out += "%s%s/%s/%s\n" % (match.group(1), conf.get("Invenio", 'CFG_SITE_URL'), conf.get("Invenio", 'CFG_SITE_RECORD'), match.group(2)) else: out += line fdesc = open(tplfile, 'w') fdesc.write(out) fdesc.close() print ">>> bibconvert templates updated successfully." def cli_cmd_update_web_tests(conf): """ Update web test cases lib/webtest/test_*.html looking for <td>http://.+?[</] strings and replacing them with CFG_SITE_URL taken from conf file. Note: this edits test files in situ, taking a backup first. Use only when you know what you are doing. """ print ">>> Going to update web tests..." ## location where test_*.html files are: testdir = conf.get("Invenio", 'CFG_PREFIX') + os.sep + \ 'lib' + os.sep + 'webtest' + os.sep + 'invenio' ## find all test_*.html files: for testfilename in os.listdir(testdir): if testfilename.startswith("test_") and \ testfilename.endswith(".html"): ## change test file: testfile = testdir + os.sep + testfilename shutil.copy(testfile, testfile + '.OLD') out = '' for line in open(testfile, 'r').readlines(): match = re.search(r'^(.*<td>)http://.+?([</].*)$', line) if match: out += "%s%s%s\n" % (match.group(1), conf.get("Invenio", 'CFG_SITE_URL'), match.group(2)) else: match = re.search(r'^(.*<td>)/opt/invenio(.*)$', line) if match: out += "%s%s%s\n" % (match.group(1), conf.get("Invenio", 'CFG_PREFIX'), match.group(2)) else: out += line fdesc = open(testfile, 'w') fdesc.write(out) fdesc.close() print ">>> web tests updated successfully." def cli_cmd_reset_sitename(conf): """ Reset collection-related tables with new CFG_SITE_NAME and CFG_SITE_NAME_INTL* read from conf files. """ print ">>> Going to reset CFG_SITE_NAME and CFG_SITE_NAME_INTL..." from invenio.dbquery import run_sql, IntegrityError # reset CFG_SITE_NAME: sitename = conf.get("Invenio", "CFG_SITE_NAME") try: run_sql("""INSERT INTO collection (id, name, dbquery, reclist) VALUES (1,%s,NULL,NULL)""", (sitename,)) except IntegrityError: run_sql("""UPDATE collection SET name=%s WHERE id=1""", (sitename,)) # reset CFG_SITE_NAME_INTL: for lang in conf.get("Invenio", "CFG_SITE_LANGS").split(","): sitename_lang = conf.get("Invenio", "CFG_SITE_NAME_INTL_" + lang) try: run_sql("""INSERT INTO collectionname (id_collection, ln, type, value) VALUES (%s,%s,%s,%s)""", (1, lang, 'ln', sitename_lang)) except IntegrityError: run_sql("""UPDATE collectionname SET value=%s WHERE ln=%s AND id_collection=1 AND type='ln'""", (sitename_lang, lang)) print "You may want to restart Apache now." print ">>> CFG_SITE_NAME and CFG_SITE_NAME_INTL* reset successfully." def cli_cmd_reset_recstruct_cache(conf): """If CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE is changed, this function will adapt the database to either store or not store the recstruct format.""" from invenio.intbitset import intbitset from invenio.dbquery import run_sql, serialize_via_marshal from invenio.search_engine import get_record from invenio.bibsched import server_pid, pidfile enable_recstruct_cache = conf.get("Invenio", "CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE") enable_recstruct_cache = enable_recstruct_cache in ('True', '1') pid = server_pid(ping_the_process=False) if pid: print >> sys.stderr, "ERROR: bibsched seems to run with pid %d, according to %s." % (pid, pidfile) print >> sys.stderr, " Please stop bibsched before running this procedure." sys.exit(1) if enable_recstruct_cache: print ">>> Searching records which need recstruct cache resetting; this may take a while..." all_recids = intbitset(run_sql("SELECT id FROM bibrec")) good_recids = intbitset(run_sql("SELECT bibrec.id FROM bibrec JOIN bibfmt ON bibrec.id = bibfmt.id_bibrec WHERE format='recstruct' AND modification_date < last_updated")) recids = all_recids - good_recids print ">>> Generating recstruct cache..." tot = len(recids) count = 0 for recid in recids: value = serialize_via_marshal(get_record(recid)) run_sql("DELETE FROM bibfmt WHERE id_bibrec=%s AND format='recstruct'", (recid, )) run_sql("INSERT INTO bibfmt(id_bibrec, format, last_updated, value) VALUES(%s, 'recstruct', NOW(), %s)", (recid, value)) count += 1 if count % 1000 == 0: print " ... done records %s/%s" % (count, tot) if count % 1000 != 0: print " ... done records %s/%s" % (count, tot) print ">>> recstruct cache generated successfully." else: print ">>> Cleaning recstruct cache..." run_sql("DELETE FROM bibfmt WHERE format='recstruct'") def cli_cmd_reset_siteadminemail(conf): """ Reset user-related tables with new CFG_SITE_ADMIN_EMAIL read from conf files. """ print ">>> Going to reset CFG_SITE_ADMIN_EMAIL..." from invenio.dbquery import run_sql siteadminemail = conf.get("Invenio", "CFG_SITE_ADMIN_EMAIL") run_sql("DELETE FROM user WHERE id=1") run_sql("""INSERT INTO user (id, email, password, note, nickname) VALUES (1, %s, AES_ENCRYPT(email, ''), 1, 'admin')""", (siteadminemail,)) print "You may want to restart Apache now." print ">>> CFG_SITE_ADMIN_EMAIL reset successfully." def cli_cmd_reset_fieldnames(conf): """ Reset I18N field names such as author, title, etc and other I18N ranking method names such as word similarity. Their translations are taken from the PO files. """ print ">>> Going to reset I18N field names..." from invenio.messages import gettext_set_language, language_list_long from invenio.dbquery import run_sql, IntegrityError ## get field id and name list: field_id_name_list = run_sql("SELECT id, name FROM field") ## get rankmethod id and name list: rankmethod_id_name_list = run_sql("SELECT id, name FROM rnkMETHOD") ## update names for every language: for lang, dummy in language_list_long(): _ = gettext_set_language(lang) ## this list is put here in order for PO system to pick names ## suitable for translation field_name_names = {"any field": _("any field"), "title": _("title"), "author": _("author"), "abstract": _("abstract"), "keyword": _("keyword"), "report number": _("report number"), "subject": _("subject"), "reference": _("reference"), "fulltext": _("fulltext"), "collection": _("collection"), "division": _("division"), "year": _("year"), "journal": _("journal"), "experiment": _("experiment"), "record ID": _("record ID")} ## update I18N names for every language: for (field_id, field_name) in field_id_name_list: if field_name_names.has_key(field_name): try: run_sql("""INSERT INTO fieldname (id_field,ln,type,value) VALUES (%s,%s,%s,%s)""", (field_id, lang, 'ln', field_name_names[field_name])) except IntegrityError: run_sql("""UPDATE fieldname SET value=%s WHERE id_field=%s AND ln=%s AND type=%s""", (field_name_names[field_name], field_id, lang, 'ln',)) ## ditto for rank methods: rankmethod_name_names = {"wrd": _("word similarity"), "demo_jif": _("journal impact factor"), "citation": _("times cited"), "citerank_citation_t": _("time-decay cite count"), "citerank_pagerank_c": _("all-time-best cite rank"), "citerank_pagerank_t": _("time-decay cite rank"),} for (rankmethod_id, rankmethod_name) in rankmethod_id_name_list: if rankmethod_name_names.has_key(rankmethod_name): try: run_sql("""INSERT INTO rnkMETHODNAME (id_rnkMETHOD,ln,type,value) VALUES (%s,%s,%s,%s)""", (rankmethod_id, lang, 'ln', rankmethod_name_names[rankmethod_name])) except IntegrityError: run_sql("""UPDATE rnkMETHODNAME SET value=%s WHERE id_rnkMETHOD=%s AND ln=%s AND type=%s""", (rankmethod_name_names[rankmethod_name], rankmethod_id, lang, 'ln',)) print ">>> I18N field names reset successfully." def cli_check_openoffice(conf): """ If OpenOffice.org integration is enabled, checks whether the system is properly configured. """ from invenio.bibtask import check_running_process_user from invenio.websubmit_file_converter import can_unoconv, get_file_converter_logger logger = get_file_converter_logger() for handler in logger.handlers: logger.removeHandler(handler) check_running_process_user() print ">>> Checking if Libre/OpenOffice.org is correctly integrated...", sys.stdout.flush() if can_unoconv(True): print "ok" else: sys.exit(1) def test_db_connection(): """ Test DB connection, and if fails, advise user how to set it up. Useful to be called during table creation. """ print "Testing DB connection...", from invenio.textutils import wrap_text_in_a_box from invenio.dbquery import run_sql, Error ## first, test connection to the DB server: try: run_sql("SHOW TABLES") except Error, err: from invenio.dbquery import CFG_DATABASE_HOST, CFG_DATABASE_PORT, \ CFG_DATABASE_NAME, CFG_DATABASE_USER, CFG_DATABASE_PASS print wrap_text_in_a_box("""\ DATABASE CONNECTIVITY ERROR %(errno)d: %(errmsg)s.\n Perhaps you need to set up database and connection rights? If yes, then please login as MySQL admin user and run the following commands now: $ mysql -h %(dbhost)s -P %(dbport)s -u root -p mysql mysql> CREATE DATABASE %(dbname)s DEFAULT CHARACTER SET utf8; mysql> GRANT ALL PRIVILEGES ON %(dbname)s.* TO %(dbuser)s@%(webhost)s IDENTIFIED BY '%(dbpass)s'; mysql> QUIT The values printed above were detected from your configuration. If they are not right, then please edit your invenio-local.conf file and rerun 'inveniocfg --update-all' first. If the problem is of different nature, then please inspect the above error message and fix the problem before continuing.""" % \ {'errno': err.args[0], 'errmsg': err.args[1], 'dbname': CFG_DATABASE_NAME, 'dbhost': CFG_DATABASE_HOST, 'dbport': CFG_DATABASE_PORT, 'dbuser': CFG_DATABASE_USER, 'dbpass': CFG_DATABASE_PASS, 'webhost': CFG_DATABASE_HOST == 'localhost' and 'localhost' or os.popen('hostname -f', 'r').read().strip(), }) sys.exit(1) print "ok" ## second, test insert/select of a Unicode string to detect ## possible Python/MySQL/MySQLdb mis-setup: print "Testing Python/MySQL/MySQLdb UTF-8 chain...", try: try: beta_in_utf8 = "β" # Greek beta in UTF-8 is 0xCEB2 run_sql("CREATE TABLE test__invenio__utf8 (x char(1), y varbinary(2)) DEFAULT CHARACTER SET utf8 ENGINE=MyISAM;") run_sql("INSERT INTO test__invenio__utf8 (x, y) VALUES (%s, %s)", (beta_in_utf8, beta_in_utf8)) res = run_sql("SELECT x,y,HEX(x),HEX(y),LENGTH(x),LENGTH(y),CHAR_LENGTH(x),CHAR_LENGTH(y) FROM test__invenio__utf8") assert res[0] == ('\xce\xb2', '\xce\xb2', 'CEB2', 'CEB2', 2L, 2L, 1L, 2L) run_sql("DROP TABLE test__invenio__utf8") except Exception, err: print wrap_text_in_a_box("""\ DATABASE RELATED ERROR %s\n A problem was detected with the UTF-8 treatment in the chain between the Python application, the MySQLdb connector, and the MySQL database. You may perhaps have installed older versions of some prerequisite packages?\n Please check the INSTALL file and please fix this problem before continuing.""" % err) sys.exit(1) finally: run_sql("DROP TABLE IF EXISTS test__invenio__utf8") print "ok" def cli_cmd_create_secret_key(conf): """Generate and append CFG_SITE_SECRET_KEY to invenio-local.conf. Useful for the installation process.""" print ">>> Going to generate random CFG_SITE_SECRET_KEY..." try: from invenio.config import CFG_ETCDIR, CFG_SITE_SECRET_KEY except ImportError: print "ERROR: please run 'inveniocfg --update-config-py' first." sys.exit(1) if CFG_SITE_SECRET_KEY is not None and len(CFG_SITE_SECRET_KEY) > 0: print "ERROR: CFG_SITE_SECRET_KEY is already filled." sys.exit(1) invenio_local_path = CFG_ETCDIR + os.sep + 'invenio-local.conf' if _grep_version_from_executable(invenio_local_path, 'CFG_SITE_SECRET_KEY'): print "WARNING: invenio-local.conf already contains CFG_SITE_SECRET_KEY." print "You may want to run 'inveniocfg --update-all'' now." print ">>> No need to generate secret key." else: secret_key = ''.join([random.choice(string.letters + string.digits) \ for dummy in range(0,256)]) with open(invenio_local_path, 'a') as f: f.write('\nCFG_SITE_SECRET_KEY = %s\n' % (secret_key, )) print ">>> CFG_SITE_SECRET_KEY appended to `%s`." % (invenio_local_path, ) def cli_cmd_create_tables(conf): """Create and fill Invenio DB tables. Useful for the installation process.""" print ">>> Going to create and fill tables..." from invenio.config import CFG_PREFIX test_db_connection() for cmd in ["%s/bin/dbexec < %s/lib/sql/invenio/tabcreate.sql" % (CFG_PREFIX, CFG_PREFIX), "%s/bin/dbexec < %s/lib/sql/invenio/tabfill.sql" % (CFG_PREFIX, CFG_PREFIX)]: if os.system(cmd): print "ERROR: failed execution of", cmd sys.exit(1) cli_cmd_reset_sitename(conf) cli_cmd_reset_siteadminemail(conf) cli_cmd_reset_fieldnames(conf) for cmd in ["%s/bin/webaccessadmin -u admin -c -a" % CFG_PREFIX]: if os.system(cmd): print "ERROR: failed execution of", cmd sys.exit(1) print ">>> Tables created and filled successfully." def cli_cmd_load_webstat_conf(conf): print ">>> Going to load WebStat config..." from invenio.config import CFG_PREFIX cmd = "%s/bin/webstatadmin --load-config" % CFG_PREFIX if os.system(cmd): print "ERROR: failed execution of", cmd sys.exit(1) print ">>> WebStat config load successfully." def cli_cmd_drop_tables(conf): """Drop Invenio DB tables. Useful for the uninstallation process.""" print ">>> Going to drop tables and related data on filesystem ..." from invenio.webinterface_handler_flask import with_app_context @with_app_context() def run(): from invenio.textutils import wrap_text_in_a_box, wait_for_user from invenio.webstat import destroy_customevents wait_for_user(wrap_text_in_a_box("""WARNING: You are going to destroy your database tables and related data on filesystem!""")) msg = destroy_customevents() if msg: print msg from invenio.sqlalchemyutils import db from invenio.bibdocfile import _make_base_dir from sqlalchemy import event def bibdoc_before_drop(target, connection_dummy, **kw_dummy): for (docid,) in db.session.query(target.c.id).all(): directory = _make_base_dir(docid) if os.path.isdir(directory): shutil.rmtree(directory) from invenio.bibedit_model import Bibdoc event.listen(Bibdoc.__table__, "before_drop", bibdoc_before_drop) db.drop_all() run() print ">>> Tables dropped successfully." def cli_cmd_create_demo_site(conf): """Create demo site. Useful for testing purposes.""" print ">>> Going to create demo site..." from invenio.config import CFG_PREFIX from invenio.dbquery import run_sql run_sql("TRUNCATE schTASK") run_sql("TRUNCATE session") run_sql("DELETE FROM user WHERE email=''") for cmd in ["%s/bin/dbexec < %s/lib/sql/invenio/democfgdata.sql" % \ (CFG_PREFIX, CFG_PREFIX),]: if os.system(cmd): print "ERROR: failed execution of", cmd sys.exit(1) cli_cmd_reset_fieldnames(conf) # needed for I18N demo ranking method names for cmd in ["%s/bin/webaccessadmin -u admin -c -r -D" % CFG_PREFIX, "%s/bin/webcoll -u admin" % CFG_PREFIX, "%s/bin/webcoll 1" % CFG_PREFIX, "%s/bin/bibsort -u admin --load-config" % CFG_PREFIX, "%s/bin/bibsort 2" % CFG_PREFIX, ]: if os.system(cmd): print "ERROR: failed execution of", cmd sys.exit(1) print ">>> Demo site created successfully." def cli_cmd_load_demo_records(conf): """Load demo records. Useful for testing purposes.""" from invenio.config import CFG_PREFIX from invenio.dbquery import run_sql print ">>> Going to load demo records..." run_sql("TRUNCATE schTASK") for cmd in ["%s/bin/bibupload -u admin -i %s/var/tmp/demobibdata.xml" % (CFG_PREFIX, CFG_PREFIX), "%s/bin/bibupload 1" % CFG_PREFIX, "%s/bin/bibdocfile --textify --with-ocr --recid 97" % CFG_PREFIX, "%s/bin/bibdocfile --textify --all" % CFG_PREFIX, "%s/bin/bibindex -u admin" % CFG_PREFIX, "%s/bin/bibindex 2" % CFG_PREFIX, "%s/bin/bibreformat -u admin -o HB" % CFG_PREFIX, "%s/bin/bibreformat 3" % CFG_PREFIX, "%s/bin/webcoll -u admin" % CFG_PREFIX, "%s/bin/webcoll 4" % CFG_PREFIX, "%s/bin/bibrank -u admin" % CFG_PREFIX, "%s/bin/bibrank 5" % CFG_PREFIX, "%s/bin/bibsort -u admin -R" % CFG_PREFIX, "%s/bin/bibsort 6" % CFG_PREFIX, "%s/bin/oairepositoryupdater -u admin" % CFG_PREFIX, "%s/bin/oairepositoryupdater 7" % CFG_PREFIX, "%s/bin/bibupload 8" % CFG_PREFIX,]: if os.system(cmd): print "ERROR: failed execution of", cmd sys.exit(1) print ">>> Demo records loaded successfully." def cli_cmd_remove_demo_records(conf): """Remove demo records. Useful when you are finished testing.""" print ">>> Going to remove demo records..." from invenio.config import CFG_PREFIX from invenio.dbquery import run_sql from invenio.textutils import wrap_text_in_a_box, wait_for_user wait_for_user(wrap_text_in_a_box("""WARNING: You are going to destroy your records and documents!""")) if os.path.exists(CFG_PREFIX + os.sep + 'var' + os.sep + 'data'): shutil.rmtree(CFG_PREFIX + os.sep + 'var' + os.sep + 'data') run_sql("TRUNCATE schTASK") for cmd in ["%s/bin/dbexec < %s/lib/sql/invenio/tabbibclean.sql" % (CFG_PREFIX, CFG_PREFIX), "%s/bin/webcoll -u admin" % CFG_PREFIX, "%s/bin/webcoll 1" % CFG_PREFIX,]: if os.system(cmd): print "ERROR: failed execution of", cmd sys.exit(1) print ">>> Demo records removed successfully." def cli_cmd_drop_demo_site(conf): """Drop demo site completely. Useful when you are finished testing.""" print ">>> Going to drop demo site..." from invenio.textutils import wrap_text_in_a_box, wait_for_user wait_for_user(wrap_text_in_a_box("""WARNING: You are going to destroy your site and documents!""")) cli_cmd_drop_tables(conf) cli_cmd_create_tables(conf) cli_cmd_remove_demo_records(conf) print ">>> Demo site dropped successfully." def cli_cmd_run_unit_tests(conf): """Run unit tests, usually on the working demo site.""" from invenio.testutils import build_and_run_unit_test_suite if not build_and_run_unit_test_suite(): sys.exit(1) def cli_cmd_run_js_unit_tests(conf): """Run JavaScript unit tests, usually on the working demo site.""" from invenio.testutils import build_and_run_js_unit_test_suite if not build_and_run_js_unit_test_suite(): sys.exit(1) def cli_cmd_run_regression_tests(conf): """Run regression tests, usually on the working demo site.""" from invenio.testutils import build_and_run_regression_test_suite if not build_and_run_regression_test_suite(): sys.exit(1) def cli_cmd_run_web_tests(conf): """Run web tests in a browser. Requires Firefox with Selenium.""" from invenio.testutils import build_and_run_web_test_suite if not build_and_run_web_test_suite(): sys.exit(1) def cli_cmd_run_flask_tests(conf): """Run flask tests.""" from invenio.testutils import build_and_run_flask_test_suite build_and_run_flask_test_suite() def _detect_ip_address(): """Detect IP address of this computer. Useful for creating Apache vhost conf snippet on RHEL like machines. @return: IP address, or '*' if cannot detect @rtype: string @note: creates socket for real in order to detect real IP address, not the loopback one. """ try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(('invenio-software.org', 0)) return s.getsockname()[0] except: return '*' def cli_cmd_create_apache_conf(conf): """ Create Apache conf files for this site, keeping previous files in a backup copy. """ - print ">>> Going to create Apache conf files..." - from invenio.textutils import wrap_text_in_a_box - from invenio.access_control_config import CFG_EXTERNAL_AUTH_USING_SSO - apache_conf_dir = conf.get("Invenio", 'CFG_ETCDIR') + \ - os.sep + 'apache' - - ## Preparation of XSendFile directive - xsendfile_directive_needed = int(conf.get("Invenio", 'CFG_BIBDOCFILE_USE_XSENDFILE')) != 0 - if xsendfile_directive_needed: - xsendfile_directive = "XSendFile On\n" - else: - xsendfile_directive = "#XSendFile On\n" - for path in (conf.get('Invenio', 'CFG_BIBDOCFILE_FILEDIR'), # BibDocFile - conf.get('Invenio', 'CFG_WEBDIR'), - conf.get('Invenio', 'CFG_WEBSUBMIT_STORAGEDIR'), # WebSubmit - conf.get('Invenio', 'CFG_TMPDIR'), - os.path.join(conf.get('Invenio', 'CFG_PREFIX'), 'var', 'tmp', 'attachfile'), - os.path.join(conf.get('Invenio', 'CFG_PREFIX'), 'var', 'data', 'comments'), - os.path.join(conf.get('Invenio', 'CFG_PREFIX'), 'var', 'data', 'baskets', 'comments'), - '/tmp'): # BibExport - if xsendfile_directive_needed: - xsendfile_directive += ' XSendFilePath %s\n' % path - else: - xsendfile_directive += ' #XSendFilePath %s\n' % path - xsendfile_directive = xsendfile_directive.strip() - - ## Preparation of deflate directive - deflate_directive_needed = int(conf.get("Invenio", 'CFG_WEBSTYLE_HTTP_USE_COMPRESSION')) != 0 - if deflate_directive_needed: - deflate_directive = r""" - ## Configuration snippet taken from: - ## <http://httpd.apache.org/docs/2.2/mod/mod_deflate.html> - <IfModule mod_deflate.c> - SetOutputFilter DEFLATE - - # Netscape 4.x has some problems... - BrowserMatch ^Mozilla/4 gzip-only-text/html - - # Netscape 4.06-4.08 have some more problems - BrowserMatch ^Mozilla/4\.0[678] no-gzip - - # MSIE masquerades as Netscape, but it is fine - # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html - - # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 - # the above regex won't work. You can use the following - # workaround to get the desired effect: - BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html - - # Don't compress images - SetEnvIfNoCase Request_URI \ - \.(?:gif|jpe?g|png)$ no-gzip dont-vary - - # Make sure proxies don't deliver the wrong content - <IfModule mod_header.c> - Header append Vary User-Agent env=!dont-vary - </IfModule> - </IfModule> - """ - else: - deflate_directive = "" - - if CFG_EXTERNAL_AUTH_USING_SSO: - shibboleth_directive = r""" - <Location ~ "/youraccount/login|Shibboleth.sso/"> - SSLRequireSSL # The modules only work using HTTPS - AuthType shibboleth - ShibRequireSession On - ShibRequireAll On - ShibExportAssertion Off - require valid-user - </Location> - """ - else: - shibboleth_directive = "" - - ## Apache vhost conf file is distro specific, so analyze needs: - # Gentoo (and generic defaults): - listen_directive_needed = True - ssl_pem_directive_needed = False - ssl_pem_path = '/etc/apache2/ssl/apache.pem' - ssl_crt_path = '/etc/apache2/ssl/server.crt' - ssl_key_path = '/etc/apache2/ssl/server.key' - vhost_ip_address_needed = False - wsgi_socket_directive_needed = False - # Debian: - if os.path.exists(os.path.sep + 'etc' + os.path.sep + 'debian_version'): - listen_directive_needed = False - ssl_pem_directive_needed = True - # RHEL/SLC: - if os.path.exists(os.path.sep + 'etc' + os.path.sep + 'redhat-release'): - listen_directive_needed = False - ssl_crt_path = '/etc/pki/tls/certs/localhost.crt' - ssl_key_path = '/etc/pki/tls/private/localhost.key' - vhost_ip_address_needed = True - wsgi_socket_directive_needed = True - # maybe we are using non-standard ports? - vhost_site_url = conf.get('Invenio', 'CFG_SITE_URL').replace("http://", "") - if vhost_site_url.startswith("https://"): - ## The installation is configured to require HTTPS for any connection - vhost_site_url = vhost_site_url.replace("https://", "") - vhost_site_url_port = '80' - vhost_site_secure_url = conf.get('Invenio', 'CFG_SITE_SECURE_URL').replace("https://", "") - vhost_site_secure_url_port = '443' - if ':' in vhost_site_url: - vhost_site_url, vhost_site_url_port = vhost_site_url.split(':', 1) - if ':' in vhost_site_secure_url: - vhost_site_secure_url, vhost_site_secure_url_port = vhost_site_secure_url.split(':', 1) - if vhost_site_url_port != '80' or vhost_site_secure_url_port != '443': - listen_directive_needed = True - ## OK, let's create Apache vhost files: - if not os.path.exists(apache_conf_dir): - os.mkdir(apache_conf_dir) - apache_vhost_file = apache_conf_dir + os.sep + \ - 'invenio-apache-vhost.conf' - apache_vhost_ssl_file = apache_conf_dir + os.sep + \ - 'invenio-apache-vhost-ssl.conf' - apache_vhost_body = """\ -AddDefaultCharset UTF-8 -ServerSignature Off -ServerTokens Prod -NameVirtualHost %(vhost_ip_address)s:%(vhost_site_url_port)s -%(listen_directive)s -%(wsgi_socket_directive)s -WSGIRestrictStdout Off -<Files *.pyc> - deny from all -</Files> -<Files *~> - deny from all -</Files> -<VirtualHost %(vhost_ip_address)s:%(vhost_site_url_port)s> - ServerName %(servername)s - ServerAlias %(serveralias)s - ServerAdmin %(serveradmin)s - DocumentRoot %(webdir)s - <Directory %(webdir)s> - Options FollowSymLinks MultiViews - AllowOverride None - Order allow,deny - Allow from all - </Directory> - ErrorLog %(logdir)s/apache.err - LogLevel warn - LogFormat "%%h %%l %%u %%t \\"%%r\\" %%>s %%b \\"%%{Referer}i\\" \\"%%{User-agent}i\\" %%D" combined_with_timing - CustomLog %(logdir)s/apache.log combined_with_timing - DirectoryIndex index.en.html index.html - Alias /static/ %(webdir)s/static/ - Alias /img/ %(webdir)s/img/ - Alias /css/ %(webdir)s/css/ - Alias /js/ %(webdir)s/js/ - Alias /flash/ %(webdir)s/flash/ - Alias /export/ %(webdir)s/export/ - Alias /MathJax/ %(webdir)s/MathJax/ - Alias /jsCalendar/ %(webdir)s/jsCalendar/ - Alias /ckeditor/ %(webdir)s/ckeditor/ - Alias /mediaelement/ %(webdir)s/mediaelement/ - AliasMatch /sitemap-(.*) %(webdir)s/sitemap-$1 - Alias /robots.txt %(webdir)s/robots.txt - Alias /favicon.ico %(webdir)s/favicon.ico - Alias /favicon.ico %(webdir)s/apple-touch-icon-144-precomposed.png - Alias /favicon.ico %(webdir)s/apple-touch-icon-114-precomposed.png - Alias /favicon.ico %(webdir)s/apple-touch-icon-72-precomposed.png - Alias /favicon.ico %(webdir)s/apple-touch-icon-57-precomposed.png - WSGIDaemonProcess invenio processes=5 threads=1 display-name=%%{GROUP} inactivity-timeout=3600 maximum-requests=10000 - WSGIImportScript %(wsgidir)s/invenio.wsgi process-group=invenio application-group=%%{GLOBAL} - WSGIScriptAlias / %(wsgidir)s/invenio.wsgi - WSGIPassAuthorization On - %(xsendfile_directive)s - <Directory %(wsgidir)s> - WSGIProcessGroup invenio - WSGIApplicationGroup %%{GLOBAL} - Options FollowSymLinks MultiViews - AllowOverride None - Order allow,deny - Allow from all - </Directory> - %(deflate_directive)s -</VirtualHost> -""" % {'vhost_site_url_port': vhost_site_url_port, - 'servername': vhost_site_url, - 'serveralias': vhost_site_url.split('.')[0], - 'serveradmin': conf.get('Invenio', 'CFG_SITE_ADMIN_EMAIL'), - 'webdir': conf.get('Invenio', 'CFG_WEBDIR'), - 'logdir': conf.get('Invenio', 'CFG_LOGDIR'), - 'libdir' : conf.get('Invenio', 'CFG_PYLIBDIR'), - 'wsgidir': os.path.join(conf.get('Invenio', 'CFG_PREFIX'), 'var', 'www-wsgi'), - 'vhost_ip_address': vhost_ip_address_needed and _detect_ip_address() or '*', - 'listen_directive': listen_directive_needed and 'Listen ' + vhost_site_url_port or \ - '#Listen ' + vhost_site_url_port, - 'wsgi_socket_directive': (wsgi_socket_directive_needed and \ - 'WSGISocketPrefix ' or '#WSGISocketPrefix ') + \ - conf.get('Invenio', 'CFG_PREFIX') + os.sep + 'var' + os.sep + 'run', - 'xsendfile_directive' : xsendfile_directive, - 'deflate_directive': deflate_directive, - } - apache_vhost_ssl_body = """\ -ServerSignature Off -ServerTokens Prod -%(listen_directive)s -NameVirtualHost %(vhost_ip_address)s:%(vhost_site_secure_url_port)s -%(ssl_pem_directive)s -%(ssl_crt_directive)s -%(ssl_key_directive)s -WSGIRestrictStdout Off -<Files *.pyc> - deny from all -</Files> -<Files *~> - deny from all -</Files> -<VirtualHost %(vhost_ip_address)s:%(vhost_site_secure_url_port)s> - ServerName %(servername)s - ServerAlias %(serveralias)s - ServerAdmin %(serveradmin)s - SSLEngine on - DocumentRoot %(webdir)s - <Directory %(webdir)s> - Options FollowSymLinks MultiViews - AllowOverride None - Order allow,deny - Allow from all - </Directory> - ErrorLog %(logdir)s/apache-ssl.err - LogLevel warn - LogFormat "%%h %%l %%u %%t \\"%%r\\" %%>s %%b \\"%%{Referer}i\\" \\"%%{User-agent}i\\" %%D" combined_with_timing - CustomLog %(logdir)s/apache-ssl.log combined_with_timing - DirectoryIndex index.en.html index.html - Alias /static/ %(webdir)s/static/ - Alias /img/ %(webdir)s/img/ - Alias /css/ %(webdir)s/css/ - Alias /js/ %(webdir)s/js/ - Alias /flash/ %(webdir)s/flash/ - Alias /export/ %(webdir)s/export/ - Alias /MathJax/ %(webdir)s/MathJax/ - Alias /jsCalendar/ %(webdir)s/jsCalendar/ - Alias /ckeditor/ %(webdir)s/ckeditor/ - Alias /mediaelement/ %(webdir)s/mediaelement/ - AliasMatch /sitemap-(.*) %(webdir)s/sitemap-$1 - Alias /robots.txt %(webdir)s/robots.txt - Alias /favicon.ico %(webdir)s/favicon.ico - Alias /favicon.ico %(webdir)s/apple-touch-icon-144-precomposed.png - Alias /favicon.ico %(webdir)s/apple-touch-icon-114-precomposed.png - Alias /favicon.ico %(webdir)s/apple-touch-icon-72-precomposed.png - Alias /favicon.ico %(webdir)s/apple-touch-icon-57-precomposed.png - RedirectMatch /sslredirect/(.*) http://$1 - WSGIScriptAlias / %(wsgidir)s/invenio.wsgi - WSGIPassAuthorization On - %(xsendfile_directive)s - <Directory %(wsgidir)s> - WSGIProcessGroup invenio - WSGIApplicationGroup %%{GLOBAL} - Options FollowSymLinks MultiViews - AllowOverride None - Order allow,deny - Allow from all - </Directory> - %(deflate_directive)s - %(shibboleth_directive)s -</VirtualHost> -""" % {'vhost_site_secure_url_port': vhost_site_secure_url_port, - 'servername': vhost_site_secure_url, - 'serveralias': vhost_site_secure_url.split('.')[0], - 'serveradmin': conf.get('Invenio', 'CFG_SITE_ADMIN_EMAIL'), - 'webdir': conf.get('Invenio', 'CFG_WEBDIR'), - 'logdir': conf.get('Invenio', 'CFG_LOGDIR'), - 'libdir' : conf.get('Invenio', 'CFG_PYLIBDIR'), - 'wsgidir' : os.path.join(conf.get('Invenio', 'CFG_PREFIX'), 'var', 'www-wsgi'), - 'vhost_ip_address': vhost_ip_address_needed and _detect_ip_address() or '*', - 'listen_directive' : listen_directive_needed and 'Listen ' + vhost_site_secure_url_port or \ - '#Listen ' + vhost_site_secure_url_port, - 'ssl_pem_directive': ssl_pem_directive_needed and \ - 'SSLCertificateFile %s' % ssl_pem_path or \ - '#SSLCertificateFile %s' % ssl_pem_path, - 'ssl_crt_directive': ssl_pem_directive_needed and \ - '#SSLCertificateFile %s' % ssl_crt_path or \ - 'SSLCertificateFile %s' % ssl_crt_path, - 'ssl_key_directive': ssl_pem_directive_needed and \ - '#SSLCertificateKeyFile %s' % ssl_key_path or \ - 'SSLCertificateKeyFile %s' % ssl_key_path, - 'xsendfile_directive' : xsendfile_directive, - 'deflate_directive': deflate_directive, - 'shibboleth_directive': shibboleth_directive, - } - # write HTTP vhost snippet: - if os.path.exists(apache_vhost_file): - shutil.copy(apache_vhost_file, - apache_vhost_file + '.OLD') - fdesc = open(apache_vhost_file, 'w') - fdesc.write(apache_vhost_body) - fdesc.close() - print - print "Created file", apache_vhost_file - # write HTTPS vhost snippet: - vhost_ssl_created = False - if conf.get('Invenio', 'CFG_SITE_SECURE_URL').startswith("https://"): - if os.path.exists(apache_vhost_ssl_file): - shutil.copy(apache_vhost_ssl_file, - apache_vhost_ssl_file + '.OLD') - fdesc = open(apache_vhost_ssl_file, 'w') - fdesc.write(apache_vhost_ssl_body) - fdesc.close() - vhost_ssl_created = True - print "Created file", apache_vhost_ssl_file - - print wrap_text_in_a_box("""\ -Apache virtual host configuration file(s) for your Invenio site -was(were) created. Please check created file(s) and activate virtual -host(s). For example, you can put the following include statements in -your httpd.conf:\n - -Include %s - -%s - - -Please see the INSTALL file for more details. - """ % (apache_vhost_file, (vhost_ssl_created and 'Include ' or '#Include ') + apache_vhost_ssl_file)) - print ">>> Apache conf files created." + import sys + from warnings import warn + from invenio.apache_manager import main + + warn('inveniocfg --create-apache-conf is deprecated. Please use \n$ inveniomanage apache create_conf') + + sys_argv = sys.argv + sys.argv = 'apache_manager.py create_conf'.split() + main() + sys.argv = sys_argv def cli_cmd_get(conf, varname): """ Return value of VARNAME read from CONF files. Useful for third-party programs to access values of conf options such as CFG_PREFIX. Return None if VARNAME is not found. """ try: if not varname: raise Exception("ERROR: Please specify a configuration variable.") varname = varname.lower() # do not pay attention to section names yet: all_options = {} for section in conf.sections(): for option in conf.options(section): all_options[option] = conf.get(section, option) varvalue = all_options.get(varname, None) if varvalue is None: raise Exception() print varvalue except Exception, e: if e.message: print e.message sys.exit(1) def cli_cmd_list(conf): """ Print a list of all conf options and values from CONF. """ sections = conf.sections() sections.sort() for section in sections: options = conf.options(section) options.sort() for option in options: print option.upper(), '=', conf.get(section, option) def _grep_version_from_executable(path_to_exec, version_regexp): """ Try to detect a program version by digging into its binary PATH_TO_EXEC and looking for VERSION_REGEXP. Return program version as a string. Return empty string if not succeeded. """ from invenio.shellutils import run_shell_command exec_version = "" if os.path.exists(path_to_exec): dummy1, cmd2_out, dummy2 = run_shell_command("strings %s | grep %s", (path_to_exec, version_regexp)) if cmd2_out: for cmd2_out_line in cmd2_out.split("\n"): if len(cmd2_out_line) > len(exec_version): # the longest the better exec_version = cmd2_out_line return exec_version def detect_apache_version(): """ Try to detect Apache version by localizing httpd or apache executables and grepping inside binaries. Return list of all found Apache versions and paths. (For a given executable, the returned format is 'apache_version [apache_path]'.) Return empty list if no success. """ from invenio.shellutils import run_shell_command out = [] dummy1, cmd_out, dummy2 = run_shell_command("locate bin/httpd bin/apache") for apache in cmd_out.split("\n"): apache_version = _grep_version_from_executable(apache, '^Apache\/') if apache_version: out.append("%s [%s]" % (apache_version, apache)) return out def cli_cmd_detect_system_details(conf): """ Detect and print system details such as Apache/Python/MySQL versions etc. Useful for debugging problems on various OS. """ import MySQLdb print ">>> Going to detect system details..." print "* Hostname: " + socket.gethostname() print "* Invenio version: " + conf.get("Invenio", "CFG_VERSION") print "* Python version: " + sys.version.replace("\n", " ") print "* Apache version: " + ";\n ".join(detect_apache_version()) print "* MySQLdb version: " + MySQLdb.__version__ try: from invenio.dbquery import run_sql print "* MySQL version:" for key, val in run_sql("SHOW VARIABLES LIKE 'version%'") + \ run_sql("SHOW VARIABLES LIKE 'charact%'") + \ run_sql("SHOW VARIABLES LIKE 'collat%'"): if False: print " - %s: %s" % (key, val) elif key in ['version', 'character_set_client', 'character_set_connection', 'character_set_database', 'character_set_results', 'character_set_server', 'character_set_system', 'collation_connection', 'collation_database', 'collation_server']: print " - %s: %s" % (key, val) except ImportError: print "* ERROR: cannot import dbquery" print ">>> System details detected successfully." def cli_cmd_upgrade(conf): """ Command for applying upgrades """ from invenio.inveniocfg_upgrader import cmd_upgrade cmd_upgrade(conf) def cli_cmd_upgrade_check(conf): """ Command for running pre-upgrade checks """ from invenio.inveniocfg_upgrader import cmd_upgrade_check cmd_upgrade_check(conf) def cli_cmd_upgrade_show_pending(conf): """ Command for showing upgrades ready to be applied """ from invenio.inveniocfg_upgrader import cmd_upgrade_show_pending cmd_upgrade_show_pending(conf) def cli_cmd_upgrade_show_applied(conf): """ Command for showing all upgrades already applied. """ from invenio.inveniocfg_upgrader import cmd_upgrade_show_applied cmd_upgrade_show_applied(conf) def cli_cmd_upgrade_create_release_recipe(conf, path): """ Create a new release upgrade recipe (for developers). """ from invenio.inveniocfg_upgrader import cmd_upgrade_create_release_recipe cmd_upgrade_create_release_recipe(conf, path) def cli_cmd_upgrade_create_standard_recipe(conf, path, depends_on=None, release=False): """ Create a new upgrade recipe (for developers). """ from invenio.inveniocfg_upgrader import cmd_upgrade_create_standard_recipe cmd_upgrade_create_standard_recipe(conf, path, depends_on=depends_on, release=release) def prepare_option_parser(): """Parse the command line options.""" class InvenioOption(Option): """ Option class that implements the action 'store_append_const' which will 1) append <const> to list in options.<dest> 2) take a value and store in options.<const> Useful for e.g. appending a const to an actions list, while also taking an option value and storing it. This ensures that we can run actions in the order they are given on the command-line. Python 2.4 compatibility note: *append_const* action is not available in Python 2.4, so it is implemented here, together with the new action *store_append_const*. """ ACTIONS = Option.ACTIONS + ("store_append_const", "append_const") STORE_ACTIONS = Option.STORE_ACTIONS + ("store_append_const", "append_const") TYPED_ACTIONS = Option.TYPED_ACTIONS + ("store_append_const", ) ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("store_append_const", ) CONST_ACTIONS = getattr(Option, 'CONST_ACTIONS', ()) + ("store_append_const", "append_const") def take_action(self, action, dest, opt, value, values, parser): if action == "store_append_const": # Combination of 'store' and 'append_const' actions values.ensure_value(dest, []).append(self.const) value_dest = self.const.replace('-', '_') setattr(values, value_dest, value) elif action == "append_const" and not hasattr(Option, 'CONST_ACTIONS'): values.ensure_value(dest, []).append(self.const) else: Option.take_action(self, action, dest, opt, value, values, parser) def _check_const(self): if self.action not in self.CONST_ACTIONS and self.const is not None: raise OptionError( "'const' must not be supplied for action %r" % self.action, self) CHECK_METHODS = [ Option._check_action, Option._check_type, Option._check_choice, Option._check_dest, _check_const, Option._check_nargs, Option._check_callback, ] parser = OptionParser(option_class=InvenioOption, description="Invenio configuration and administration CLI tool", formatter=IndentedHelpFormatter(max_help_position=31)) parser.add_option("-V", "--version", action="store_true", help="print version number") finish_options = OptionGroup(parser, "Options to finish your installation") finish_options.add_option("", "--create-secret-key", dest='actions', const='create-secret-key', action="append_const", help="generate random CFG_SITE_SECRET_KEY") finish_options.add_option("", "--create-apache-conf", dest='actions', const='create-apache-conf', action="append_const", help="create Apache configuration files") finish_options.add_option("", "--create-tables", dest='actions', const='create-tables', action="append_const", help="create DB tables for Invenio") finish_options.add_option("", "--load-webstat-conf", dest='actions', const='load-webstat-conf', action="append_const", help="load the WebStat configuration") finish_options.add_option("", "--drop-tables", dest='actions', const='drop-tables', action="append_const", help="drop DB tables of Invenio") finish_options.add_option("", "--check-openoffice", dest='actions', const='check-openoffice', action="append_const", help="check for correctly set up of openoffice temporary directory") parser.add_option_group(finish_options) demotest_options = OptionGroup(parser, "Options to set up and test a demo site") demotest_options.add_option("", "--create-demo-site", dest='actions', const='create-demo-site', action="append_const", help="create demo site") demotest_options.add_option("", "--load-demo-records", dest='actions', const='load-demo-records', action="append_const", help="load demo records") demotest_options.add_option("", "--remove-demo-records", dest='actions', const='remove-demo-records', action="append_const", help="remove demo records, keeping demo site") demotest_options.add_option("", "--drop-demo-site", dest='actions', const='drop-demo-site', action="append_const", help="drop demo site configurations too") demotest_options.add_option("", "--run-unit-tests", dest='actions', const='run-unit-tests', action="append_const", help="run unit test suite (needs demo site)") demotest_options.add_option("", "--run-js-unit-tests", dest='actions', const='run-js-unit-tests', action="append_const", help="run JS unit test suite (needs demo site)") demotest_options.add_option("", "--run-regression-tests", dest='actions', const='run-regression-tests', action="append_const", help="run regression test suite (needs demo site)") demotest_options.add_option("", "--run-web-tests", dest='actions', const='run-web-tests', action="append_const", help="run web tests in a browser (needs demo site, Firefox, Selenium IDE)") demotest_options.add_option("", "--run-flask-tests", dest='actions', const='run-flask-tests', action="append_const", help="run Flask test suite") parser.add_option_group(demotest_options) config_options = OptionGroup(parser, "Options to update config files in situ") config_options.add_option("", "--update-all", dest='actions', const='update-all', action="append_const", help="perform all the update options") config_options.add_option("", "--update-config-py", dest='actions', const='update-config-py', action="append_const", help="update config.py file from invenio.conf file") config_options.add_option("", "--update-dbquery-py", dest='actions', const='update-dbquery-py', action="append_const", help="update dbquery.py with DB credentials from invenio.conf") config_options.add_option("", "--update-dbexec", dest='actions', const='update-dbexec', action="append_const", help="update dbexec with DB credentials from invenio.conf") config_options.add_option("", "--update-bibconvert-tpl", dest='actions', const='update-bibconvert-tpl', action="append_const", help="update bibconvert templates with CFG_SITE_URL from invenio.conf") config_options.add_option("", "--update-web-tests", dest='actions', const='update-web-tests', action="append_const", help="update web test cases with CFG_SITE_URL from invenio.conf") parser.add_option_group(config_options) reset_options = OptionGroup(parser, "Options to update DB tables") reset_options.add_option("", "--reset-all", dest='actions', const='reset-all', action="append_const", help="perform all the reset options") reset_options.add_option("", "--reset-sitename", dest='actions', const='reset-sitename', action="append_const", help="reset tables to take account of new CFG_SITE_NAME*") reset_options.add_option("", "--reset-siteadminemail", dest='actions', const='reset-siteadminemail', action="append_const", help="reset tables to take account of new CFG_SITE_ADMIN_EMAIL") reset_options.add_option("", "--reset-fieldnames", dest='actions', const='reset-fieldnames', action="append_const", help="reset tables to take account of new I18N names from PO files") reset_options.add_option("", "--reset-recstruct-cache", dest='actions', const='reset-recstruct-cache', action="append_const", help="reset record structure cache according to CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE") parser.add_option_group(reset_options) upgrade_options = OptionGroup(parser, "Options to upgrade your installation") upgrade_options.add_option("", "--upgrade", dest='actions', const='upgrade', action="append_const", help="apply all pending upgrades") upgrade_options.add_option("", "--upgrade-check", dest='actions', const='upgrade-check', action="append_const", help="run pre-upgrade checks for pending upgrades") upgrade_options.add_option("", "--upgrade-show-pending", dest='actions', const='upgrade-show-pending', action="append_const", help="show pending upgrades") upgrade_options.add_option("", "--upgrade-show-applied", dest='actions', const='upgrade-show-applied', action="append_const", help="show history of applied upgrades") upgrade_options.add_option("", "--upgrade-create-standard-recipe", dest='actions', metavar='REPOSITORY[,DIR]', const='upgrade-create-standard-recipe', action="store_append_const", help="create a new standard upgrade recipe (for developers)") upgrade_options.add_option("", "--upgrade-create-release-recipe", dest='actions', metavar='REPOSITORY[,DIR]', const='upgrade-create-release-recipe', action="store_append_const", help="create a new release upgrade recipe (for developers)") parser.add_option_group(upgrade_options) helper_options = OptionGroup(parser, "Options to help the work") helper_options.add_option("", "--list", dest='actions', const='list', action="append_const", help="print names and values of all options from conf files") helper_options.add_option("", "--get", dest='actions', const='get', action="store_append_const", metavar="OPTION", help="get value of a given option from conf files") helper_options.add_option("", "--conf-dir", action="store", metavar="PATH", help="path to directory where invenio*.conf files are [optional]") helper_options.add_option("", "--detect-system-details", dest='actions', const='detect-system-details', action="append_const", help="print system details such as Apache/Python/MySQL versions") parser.add_option_group(helper_options) parser.add_option('--yes-i-know', action='store_true', dest='yes-i-know', help='use with care!') return parser def prepare_conf(options): """ Read configuration files """ conf = ConfigParser() confdir = getattr(options, 'conf_dir', None) if confdir is None: ## try to detect path to conf dir (relative to this bin dir): confdir = re.sub(r'/bin$', '/etc', sys.path[0]) if confdir and not os.path.exists(confdir): raise Exception("ERROR: bad --conf-dir option value - directory does not exists.") sys.exit(1) ## read conf files: for conffile in [confdir + os.sep + 'invenio.conf', confdir + os.sep + 'invenio-autotools.conf', confdir + os.sep + 'invenio-local.conf', ]: if os.path.exists(conffile): conf.read(conffile) else: if not conffile.endswith("invenio-local.conf"): # invenio-local.conf is optional, otherwise stop raise Exception("ERROR: Badly guessed conf file location %s (Please use --conf-dir option.)" % conffile) return conf def main(*cmd_args): """Main entry point.""" # Allow easier testing if not cmd_args: cmd_args = sys.argv[1:] # Parse arguments parser = prepare_option_parser() (options, dummy_args) = parser.parse_args(list(cmd_args)) if getattr(options, 'version', False): print_version() else: # Read configuration try: conf = prepare_conf(options) except Exception, e: print e sys.exit(1) ## Decide what to do actions = getattr(options, 'actions', None) if not actions: print """ERROR: Please specify a command. Please see '--help'.""" sys.exit(1) for action in actions: if action == 'get': cli_cmd_get(conf, getattr(options, 'get', None)) elif action == 'list': cli_cmd_list(conf) elif action == 'detect-system-details': cli_cmd_detect_system_details(conf) elif action == 'create-secret-key': cli_cmd_create_secret_key(conf) elif action == 'create-tables': cli_cmd_create_tables(conf) elif action == 'load-webstat-conf': cli_cmd_load_webstat_conf(conf) elif action == 'drop-tables': cli_cmd_drop_tables(conf) elif action == 'check-openoffice': cli_check_openoffice(conf) elif action == 'create-demo-site': cli_cmd_create_demo_site(conf) elif action == 'load-demo-records': cli_cmd_load_demo_records(conf) elif action == 'remove-demo-records': cli_cmd_remove_demo_records(conf) elif action == 'drop-demo-site': cli_cmd_drop_demo_site(conf) elif action == 'run-unit-tests': cli_cmd_run_unit_tests(conf) elif action == 'run-js-unit-tests': cli_cmd_run_js_unit_tests(conf) elif action == 'run-regression-tests': cli_cmd_run_regression_tests(conf) elif action == 'run-web-tests': cli_cmd_run_web_tests(conf) elif action == 'run-flask-tests': cli_cmd_run_flask_tests(conf) elif action == 'update-all': cli_cmd_update_config_py(conf) cli_cmd_update_dbquery_py(conf) cli_cmd_update_dbexec(conf) cli_cmd_update_bibconvert_tpl(conf) cli_cmd_update_web_tests(conf) elif action == 'update-config-py': cli_cmd_update_config_py(conf) elif action == 'update-dbquery-py': cli_cmd_update_dbquery_py(conf) elif action == 'update-dbexec': cli_cmd_update_dbexec(conf) elif action == 'update-bibconvert-tpl': cli_cmd_update_bibconvert_tpl(conf) elif action == 'update-web-tests': cli_cmd_update_web_tests(conf) elif action == 'reset-all': cli_cmd_reset_sitename(conf) cli_cmd_reset_siteadminemail(conf) cli_cmd_reset_fieldnames(conf) cli_cmd_reset_recstruct_cache(conf) elif action == 'reset-sitename': cli_cmd_reset_sitename(conf) elif action == 'reset-siteadminemail': cli_cmd_reset_siteadminemail(conf) elif action == 'reset-fieldnames': cli_cmd_reset_fieldnames(conf) elif action == 'reset-recstruct-cache': cli_cmd_reset_recstruct_cache(conf) elif action == 'create-apache-conf': cli_cmd_create_apache_conf(conf) elif action == 'upgrade': cli_cmd_upgrade(conf) elif action == 'upgrade-check': cli_cmd_upgrade_check(conf) elif action == 'upgrade-show-pending': cli_cmd_upgrade_show_pending(conf) elif action == 'upgrade-show-applied': cli_cmd_upgrade_show_applied(conf) elif action == 'upgrade-create-standard-recipe': cli_cmd_upgrade_create_standard_recipe(conf, getattr(options, 'upgrade_create_standard_recipe', None)) elif action == 'upgrade-create-release-recipe': cli_cmd_upgrade_create_release_recipe(conf, getattr(options, 'upgrade_create_release_recipe', None)) else: print "ERROR: Unknown command", action sys.exit(1) if __name__ == '__main__': main()