Debian Codegraph @

contrib/multidig/gen-collect

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!@BASH@
2
3 #
4 # gen-collect 1.1
5 #
6 # Copyright (c) 1998-1999 The ht://Dig Group
7 # Distributed under the terms of the GNU General Public License (GPL)
8 # version 2 or later.
9 # for the ht://Dig search system http://www.htdig.org/
10 # and the multidig script system http://www.htdig.org/contrib/scripts/
11 #
12 # Part of the "multidig script system"
13 # a system of shell scripts and some modified conf files
14 # that makes dealing with multiple databases easier for ht://Dig
15 #
16 # Syntax:
17 # gen-collect [-v]
18 #
19 # Merges multiple databases into ``collected'' db
20 # (This is done by multidig too, but this script lets you *just*
21 # generate the collections.)
22 #
23
24 # This is useful for debugging info
25 if [ "$1" = "-v" ]; then
26 verbose=-v
27 fi
28
29 # You may need to set the following:
30 MULTIDIG_CONF=@CONFIG_DIR@/multidig.conf
31 source $MULTIDIG_CONF
32
33 # We may be called inside multidig, so we don't want to mess with the report.
34 for collect in `cat $COLLECT_LIST`; do
35 # What's the conf file for this database?
36 CONF=$CONFIG_DIR/$collect.conf
37 echo Generating $collect at: `date`
38
39 # We want to replace the old .work files with the first database
40 # This ensures that we *only* get documents from the merged db
41 # and not old ones left around in our previous collected db
42 firstdb=`head -n 1 $DB_BASE/$collect/$collect.collect`
43 cp $DB_BASE/$firstdb/db.docdb $DB_BASE/$collect/db.docdb.work
44 cp $DB_BASE/$firstdb/db.docs.index $DB_BASE/$collect/db.docs.index.work
45 cp $DB_BASE/$firstdb/db.wordlist.work $DB_BASE/$collect/db.wordlist.work
46 cp $DB_BASE/$firstdb/db.words.db $DB_BASE/$collect/db.words.db.work
47 # Now we need to work out the number of remaining db in the collection
48 LENGTH=`wc -l $DB_BASE/$collect/$collect.collect | awk '{print $1;}'`
49 let NUM=LENGTH-1
50
51 for db in `tail -n $NUM $DB_BASE/$collect/$collect.collect`; do
52 if [ "$1" = "-v" ]; then
53 echo Merging db $db of collect $collect
54 fi
55 MERGE_CONF=$CONFIG_DIR/$db.conf
56 # There's a slight bug in the merge function.
57 # It's looking for db.wordlist, not .work. So lets copy it temporarily
58 cp $DB_BASE/$db/db.wordlist.work $DB_BASE/$db/db.wordlist
59 # Do the merging, using -d and -w to prevent normal merging
60 # (it would be a waste of time, we'd repeat it multiple times)
61 $BINDIR/htmerge $verbose -s -d -w -m $MERGE_CONF -a -c $CONF >>$REPORT
62 # And now remove the copy
63 rm $DB_BASE/$db/db.wordlist
64 done
65
66 # Now after merging in all of those databases
67 # we need to do the usual htmerge run
68 $BINDIR/htmerge -a $verbose -s -c $CONF >>$REPORT
69
70 if [ "$1" = "-v" ]; then
71 echo Moving files $collect at: `date`
72 fi
73 # If you don't have the space for backups, this step can be omitted
74 if [ $BACKUPS = "true" ]; then
75 cp $DB_BASE/$collect/db.docdb $DB_BASE/$collect/db.docdb.bak
76 cp $DB_BASE/$collect/db.docs.index $DB_BASE/$collect/db.docs.index.bak
77 # cp $DB_BASE/$collect/db.wordlist $DB_BASE/$collect/db.wordlist.bak
78 cp $DB_BASE/$collect/db.words.db $DB_BASE/$collect/db.words.db.bak
79 fi
80
81 # Move them because we don't want .work files around
82 # (Remember, we're generating using merging,
83 # so we want to make sure we don't have old stuff to gum up the works...
84 mv $DB_BASE/$collect/db.docdb.work $DB_BASE/$collect/db.docdb
85 mv $DB_BASE/$collect/db.docs.index.work $DB_BASE/$collect/db.docs.index
86 # mv $DB_BASE/$collect/db.wordlist.work $DB_BASE/$collect/db.wordlist
87 mv $DB_BASE/$collect/db.words.db.work $DB_BASE/$collect/db.words.db
88
89 # Make them world readable!
90 chmod 644 $DB_BASE/$collect/db.docdb
91 chmod 644 $DB_BASE/$collect/db.docs.index
92 # chmod 644 $DB_BASE/$collect/db.wordlist
93 chmod 644 $DB_BASE/$collect/db.words.db
94 if [ "$1" = "-v" ]; then
95 echo Done with $collect at: `date`
96 fi
97 done
98
99 # That's it!