#!/bin/bash # PURPOSE # This is not a nightly script. You use it to regenerate the model-collections # if Greenstone has changed fundamentally, such as what HASH OIDs get assigned # to documents or something that changes the contents of the index and # archives folders. This has happened now with the commits # http://trac.greenstone.org/changeset/28022 and # http://trac.greenstone.org/changeset/28021 # These commits generate new stable HASH OIDs for the existing documents. # USAGE # Put this file in the toplevel of the Greenstone 2 binary/SVN installation # that you want to generate the model collections with. # Call with 0 args to process all model collections # Call with n args, where each is a collection name in the model-collections # list # PSEUDOCODE # This script: # Checks out the model-collections folder from SVN # Makes a copy # In the copy: gets rid of their .svn folders, and builds each collection in turn, moving building to index once done function single_collection () { collection=$1 #escape the filename (in case of space) collection=`echo $collection | sed 's@ @\\\ @g'` #get just the basename collection=`basename $collection` import.pl -removeold $collection buildcol.pl -removeold $collection rm -rf collect/$collection/index mv collect/$collection/building collect/$collection/index echo echo "*********************" echo "Done processing $collection" echo "*********************" echo } function all_collections() { #for each collection, import, build, move building to index for collection in collect/*; do single_collection $collection; done } # The program starts here # Need pdfbox for the PDFBox tutorial if [ ! -e ext/pdf-box ]; then cd ext if [ ! -e ext/pdf-box-java.tar.gz ]; then wget http://trac.greenstone.org/export/head/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz tar -xvzf pdf-box-java.tar.gz fi cd .. fi if test -e model-collect; then svn up model-collect else svn co http://svn.greenstone.org/other-projects/nightly-tasks/diffcol/trunk/model-collect fi # move the existing collect folder out of the way if [ -e collect ] && [ ! -e collect_orig ] ; then mv collect collect_orig fi # make a copy of the model-collect named as the new collect # and remove the copy's .svn folders if [ -e collect_orig ]; then if [ -e collect ]; then rm -rf collect fi cp -r model-collect collect fi #cd collect #find . -name ".svn" -type d -exec rm -rf {} \; #cd .. find collect -name ".svn" -type d -exec rm -rf {} \; # Set up the Greenstone environment for building source setup.bash # parse arguments # http://stackoverflow.com/questions/12711786/bash-convert-command-line-arguments-into-array # http://stackoverflow.com/questions/255898/how-to-iterate-over-arguments-in-bash-script if [ "$1" == "" ]; then all_collections else # Command-line args are a list of collections, # process each command-line arg, after confirming such a collection exists for collection in collect/"$@"; do if test -e $collection; then single_collection $collection; else echo "Can't find collection $collection. Skipping." fi done fi