Merging from head
[beagle.git] / tools / beagle-crawl-system.in
blob9370bf175ea937ee8cd6ba1605b161a4b2352b16
1 #!/bin/sh
4 # beagle-crawl-system
6 # Copyright (C) 2005 Novell, Inc.
10 # Permission is hereby granted, free of charge, to any person obtaining a copy
11 # of this software and associated documentation files (the "Software"), to deal
12 # in the Software without restriction, including without limitation the rights
13 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 # copies of the Software, and to permit persons to whom the Software is
15 # furnished to do so, subject to the following conditions:
17 # The above copyright notice and this permission notice shall be included in all
18 # copies or substantial portions of the Software.
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 # SOFTWARE.
29 umask 022
31 CRAWL_USER=beagleindex
33 export TMPDIR=/tmp
35 # Mono requires a writable wapi directory
36 MONO_SHARED_DIR=`mktemp -d -p $TMPDIR .beagleindexwapi.XXXXXXXXXX`|| ( echo "Can't create wapi directory!" ; exit 1 )
37 chown $CRAWL_USER $MONO_SHARED_DIR
39 for crawl_file in @sysconfdir@/beagle/crawl-*; do
40 unset CRAWL_ENABLED CRAWL_DISABLE_FILTERING CRAWL_RECURSIVE CRAWL_CACHE_TEXT CRAWL_ALLOW_PATTERNS CRAWL_DENY_PATTERNS CRAWL_PATHS CRAWL_INDEX_NAME
42 if [ -f $crawl_file ] ; then
43 . $crawl_file
45 if [ -n "$CRAWL_ENABLED" -a "$CRAWL_ENABLED" = "yes" ] ; then
47 OPTIONS="`test -n "$CRAWL_DISABLE_FILTERING" -a "$CRAWL_DISABLE_FILTERING" = "yes" && \
48 echo --disable-filtering`"
50 OPTIONS="$OPTIONS `test -n "$CRAWL_DISABLE_DIRECTORIES" -a "$CRAWL_DISABLE_DIRECTORIES" = "yes" && \
51 echo --disable-directories`"
53 OPTIONS="$OPTIONS `test -n "$CRAWL_RECURSIVE" -a "$CRAWL_RECURSIVE" = "yes" && \
54 echo --recursive`"
56 OPTIONS="$OPTIONS `test -n "$CRAWL_CACHE_TEXT" -a "$CRAWL_CACHE_TEXT" = "yes" && \
57 echo --enable-text-cache`"
59 OPTIONS="$OPTIONS `test -n "$CRAWL_ALLOW_PATTERNS" && \
60 echo --allow-pattern $CRAWL_ALLOW_PATTERNS`"
62 OPTIONS="$OPTIONS `test -n "$CRAWL_DENY_PATTERNS" && \
63 echo --deny-pattern $CRAWL_DENY_PATTERNS`"
65 IONICE=`which ionice 2>/dev/null`
66 if [ -n "$IONICE" ]; then
67 IONICE="$IONICE -c 3"
70 eval nice -n 19 $IONICE su -s /bin/bash $CRAWL_USER -c \"MONO_SHARED_DIR=$MONO_SHARED_DIR @sbindir@/beagle-build-index --target @localstatedir@/cache/beagle/indexes/$CRAWL_INDEX_NAME $OPTIONS $CRAWL_PATHS\" > /dev/null 2>&1
73 done
75 # delete wapi directory
76 rm -rf $MONO_SHARED_DIR
78 exit 0