3 export _EXEC="${0%/*}/" _DATA="" # _DATE="$(date +%s)"
10 This script should be run regularly via cron to remove outdated
11 records from search the index.
15 INSTALL_DIR/maintenance.sh SITE_DIR
17 maintenance.sh --exec "INSTALL_DIR" --data "SITE_DIR"
22 Point to the location of your shellwiki installation. This will
23 default to the path at which the script is called, if it can be
27 Point to the location of your site installation. I.e. the directory
28 containing your "pages/" and "index/" dir.
35 while [ $# -gt 0 ]; do case $1 in
36 --exec|-e) _EXEC="${2%/}"; shift 2;;
37 --data|-d) _DATA="${2%/}"; shift 2;;
38 --verbose|-v) verb=true; shift 1;;
46 if ! [ -d "$_DATA/pages/" -a -d "$_DATA/index/" ]; then
47 printf 'ERROR: %s\n\n' "\"${_DATA}\" does not seem to be valid site directory" >&2
50 if ! [ -x "$_EXEC/parsers/40_indexer.sh" -a -x "$_EXEC/cgilite/storage.sh" ]; then
51 printf 'ERROR: %s\n\n' "could not determine shellwiki installation path (tried \"$_EXEC\")" >&2
55 . "$_EXEC/cgilite/storage.sh"
57 for word in "$_DATA/index"/*; do
58 [ "$word" = "$_DATA/index/*" ] && continue
60 [ "$verb" ] && printf '\r \r%s\r' "${word##*/}" >&2
61 mv -- "$word" "${word}.$$"
63 while read -r date location freq num total; do
64 l="$_DATA/pages$(UNSTRING "$location")#index.flag"
65 d="$(stat -c %Y "$l")" 2>&-
67 if [ "$date" -ge "$d" ] 2>&-; then
68 printf '%i %s %f %i %i\n' \
69 "$date" "$location" "$freq" "$num" "$total"
70 elif [ "$verb" ]; then
71 printf 'Removing "%s" from "%s"\n' "$location" "$word" >&2
73 done <"${word}.$$" >>"${word}"