root/other-projects/nightly-tasks/diffcol/trunk/gen-model-colls.sh @ 28027

Revision 28027, 3.2 KB (checked in by ak19, 6 years ago)

Need PDFBox for generating the pdfbox MODEL collection too

Line 
1#!/bin/bash
2
3# PURPOSE
4# This is not a nightly script. You use it to regenerate the model-collections
5# if Greenstone has changed fundamentally, such as what HASH OIDs get assigned
6# to documents or something that changes the contents of the index and
7# archives folders. This has happened now with the commits
8# http://trac.greenstone.org/changeset/28022 and
9# http://trac.greenstone.org/changeset/28021
10# These commits generate new stable HASH OIDs for the existing documents.
11
12
13# USAGE
14# Put this file in the toplevel of the Greenstone 2 binary/SVN installation
15# that you want to generate the model collections with.
16# Call with 0 args to process all model collections
17# Call with n args, where each is a collection name in the model-collections
18# list
19
20# PSEUDOCODE
21# This script:
22# Checks out the model-collections folder from SVN
23# Makes a copy
24# In the copy: gets rid of their .svn folders, and builds each collection in turn, moving building to index once done
25
26
27
28function single_collection () {
29    collection=$1   
30
31    #escape the filename (in case of space)
32    collection=`echo $collection | sed 's@ @\\\ @g'`
33   
34    #get just the basename
35    collection=`basename $collection`
36   
37    import.pl -removeold $collection
38    buildcol.pl -removeold $collection
39    rm -rf collect/$collection/index
40    mv collect/$collection/building collect/$collection/index
41   
42    echo
43    echo "*********************"
44    echo "Done processing $collection"
45    echo "*********************"
46    echo
47}
48
49
50function all_collections() {
51
52    #for each collection, import, build, move building to index
53    for collection in collect/*; do
54    single_collection $collection;
55    done
56}
57
58
59# The program starts here
60
61# Need pdfbox for the PDFBox tutorial
62if [ ! -e ext/pdf-box ]; then
63    cd ext
64    if [ ! -e ext/pdf-box-java.tar.gz ]; then
65    wget http://trac.greenstone.org/export/head/gs2-extensions/pdf-box/trunk/pdf-box-java.tar.gz
66    tar -xvzf pdf-box-java.tar.gz
67    fi
68    cd ..
69fi
70
71
72if test -e model-collect; then   
73    svn up model-collect
74else
75    svn co http://svn.greenstone.org/other-projects/nightly-tasks/diffcol/trunk/model-collect
76fi
77
78# move the existing collect folder out of the way
79if [ -e collect ] && [ ! -e collect_orig ] ; then
80    mv collect collect_orig
81fi
82
83# make a copy of the model-collect named as the new collect
84# and remove the copy's .svn folders
85if [ -e collect_orig ]; then
86    if [ -e collect ]; then
87    rm -rf collect
88    fi
89    cp -r model-collect collect
90fi
91
92#cd collect
93#find . -name ".svn" -type d -exec rm -rf {} \;
94#cd ..
95find collect -name ".svn" -type d -exec rm -rf {} \;
96
97
98# Set up the Greenstone environment for building
99source setup.bash
100
101# parse arguments
102# http://stackoverflow.com/questions/12711786/bash-convert-command-line-arguments-into-array
103# http://stackoverflow.com/questions/255898/how-to-iterate-over-arguments-in-bash-script
104
105if [ "$1" == "" ]; then
106    all_collections
107else
108    # Command-line args are a list of collections,
109    # process each command-line arg, after confirming such a collection exists
110
111    for collection in collect/"$@"; do
112    if test -e $collection; then   
113        single_collection $collection;
114    else
115        echo "Can't find collection $collection. Skipping."
116    fi
117    done
118fi
Note: See TracBrowser for help on using the browser.