summaryrefslogtreecommitdiffstats
path: root/lurker/index/lurker-regenerate
blob: 63a39a64d366e6f84b2caaad38a63ffa659bdf46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/sh -e
# Options: [path to lurker-*] [config file]

epath="$1"
cfg="$2"

if ! test -z "$epath"; then \
        if ! echo "$epath" | grep -q "^/"; then
                echo If a path is specified, it must be absolute
                exit 1
        fi
        epath="$epath/";
fi
if ! test -z "$cfg"; then \
        if ! echo "$cfg" | grep -q "^/"; then
                echo If a config file is specified, its path must be absolute
                exit 1
        fi
        copt="-c"
fi

dbdir=`"${epath}lurker-params" $copt "$cfg" -d`
cd "$dbdir"

if test -d .tmp; then \
        echo "The database appears to be in the middle of a conversion already."
        echo "Please deal with the '.tmp' folder in the $dbdir and try again"
        exit 1
fi

mkdir .tmp
cd .tmp
mv -i ../* .

for l in `"${epath}lurker-list" $copt "$cfg" -i`; do
  echo Reindexing $l
  if ! test -f $l; then continue; fi
  gzip -dfc < $l | "${epath}lurker-index" $copt "$cfg" -p ./db -l $l -v
done

cd ..
rm -rf .tmp

echo
echo "Database has been regenerated; please double-check the permissions"
echo "Now flushing all web cache (re-run as root if you lack www permission)"
echo "  ${epath}lurker-prune $copt $cfg -p"
"${epath}lurker-prune" $copt "$cfg" -p