From 99b8d63d77ee2c68c4860b6449bd5dfc806cbb53 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Thu, 3 Aug 2017 16:47:00 +0200 Subject: [PATCH] import of the current scripts --- install-xapian.sh | 43 +++++++++++++++++++++++++++++++++++++++++ rebuild-search-index.py | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 install-xapian.sh create mode 100644 rebuild-search-index.py diff --git a/install-xapian.sh b/install-xapian.sh new file mode 100644 index 0000000..58186bc --- /dev/null +++ b/install-xapian.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# first argument of the script is Xapian version (e.g. 1.2.19) +VERSION=$1 + +# prepare +mkdir $VIRTUAL_ENV/packages && cd $VIRTUAL_ENV/packages + +CORE=xapian-core-$VERSION +BINDINGS=xapian-bindings-$VERSION + +# download +echo "Downloading source..." +curl -O -L https://oligarchy.co.uk/xapian/$VERSION/${CORE}.tar.xz +curl -O -L https://oligarchy.co.uk/xapian/$VERSION/${BINDINGS}.tar.xz + +# extract +echo "Extracting source..." +tar -xf ${CORE}.tar.xz +tar -xf ${BINDINGS}.tar.xz + +# install +echo "Installing Xapian-core..." +cd $VIRTUAL_ENV/packages/${CORE} +./configure --prefix=$VIRTUAL_ENV && make && make install + +PYV=`python -c "import sys;t='{v[0]}'.format(v=list(sys.version_info[:1]));sys.stdout.write(t)";` + +if [ $PYV = "2" ]; then + PYTHON_FLAG=--with-python +else + PYTHON_FLAG=--with-python3 +fi + +echo "Installing Xapian-bindings..." +cd $VIRTUAL_ENV/packages/${BINDINGS} +./configure --prefix=$VIRTUAL_ENV $PYTHON_FLAG XAPIAN_CONFIG=$VIRTUAL_ENV/bin/xapian-config && make && make install + +# clean +rm -rf $VIRTUAL_ENV/packages + +# test +python -c "import xapian" + diff --git a/rebuild-search-index.py b/rebuild-search-index.py new file mode 100644 index 0000000..c27b135 --- /dev/null +++ b/rebuild-search-index.py @@ -0,0 +1,37 @@ +#!/usr/local/webapps/moin/moin-env/bin/python + +import sys + + +CONFIG_PATH = '/var/www/moin/config/' + + +def is_venv(): + return (hasattr(sys, 'real_prefix') or + (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)) + + +if __name__ == '__main__': + + if not is_venv(): + print 'you need to activate the virtual environment' + sys.exit(1) + + sys.path.append(CONFIG_PATH) + from farmconfig import wikis + from MoinMoin.script.moin import run + + for module_name, url_regex in wikis: + # removes starting carret and port definitions and onward + tmp = url_regex[1:-11] + url = tmp.replace('?', '') + + sys.argv = [ + 'moin', + '--config-dir=' + CONFIG_PATH, + '--wiki-url=' + url, + 'index', + 'build', + '--mode=rebuild'] + + run()