File: rundig.sh

package info (click to toggle)
htdig 1%3A3.2.0b6-3.1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 14,936 kB
  • ctags: 9,369
  • sloc: ansic: 49,626; cpp: 46,470; sh: 23,053; xml: 4,180; perl: 2,543; makefile: 868; php: 79; asm: 14
file content (96 lines) | stat: -rw-r--r-- 2,720 bytes parent folder | download | duplicates (9)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /bin/sh

# rundig.sh
# a script to drive ht://Dig updates
# Copyright (c) 1998 Colin Viebrock <cmv@shmooze.net>
# Copyright (c) 1998-1999 Geoff Hutchison <ghutchis@wso.williams.edu>
# Updated for ht://Dig 3.2.0b3 Feb 2001, Copyright (c) 2001 Geoff Hutchison
# Distributed under the GNU GPL version 2 or later

if [ "$1" = "-v" ]; then
    verbose="-v"
fi

# This is the directory where htdig lives
BASEDIR=/export/htdig

# This is the db dir
DBDIR=$BASEDIR/db/

# This is the name of a temporary report file
REPORT=/tmp/htdig.report

# This is who gets the report
REPORT_DEST="webmaster@yourdomain.com"
export REPORT_DEST

# This is the subject line of the report
SUBJECT="cron: htdig report for domain"

# This is the name of the conf file to use
CONF=htdig.conf

# This is the directory htdig will use for temporary sort files
TMPDIR=$DBDIR
export TMPDIR

# This is the PATH used by this script. Change it if you have problems
#  with not finding wc or grep.
PATH=/usr/local/bin:/usr/bin:/bin

##### Dig phase
STARTTIME=`date`
echo Start time: $STARTTIME
echo rundig: Start time:   $STARTTIME > $REPORT
$BASEDIR/bin/htdig $verbose -s -a -c $BASEDIR/conf/$CONF >> $REPORT
TIME=`date`
echo Done Digging: $TIME
echo rundig: Done Digging: $TIME >> $REPORT

##### Purge Phase
# (clean out broken links, etc.)
$BASEDIR/bin/htpurge $verbose -a -c $BASEDIR/conf/$CONF >> $REPORT
TIME=`date`
echo Done Purging: $TIME
echo rundig: Done Purging: $TIME >> $REPORT

##### Cleanup Phase
# To enable htnotify or the soundex search, uncomment the following lines
# $BASEDIR/bin/htnotify $verbose >>$REPORT
# $BASEDIR/bin/htfuzzy $verbose soundex
# To get additional statistics, uncomment the following line
# $BASEDIR/bin/htstat $verbose >>$REPORT

# Move 'em into place. Since these are only used by htdig for update digs
# and we always use -a, we just leave them as .work
# mv $DBDIR/db.docs.index.work $DBDIR/db.docs.index
# (this is just a mapping from a URL to a DocID)
# We need the .work for next time as an update dig, plus the copy for searching
cp $DBDIR/db.docdb.work $DBDIR/db.docdb
cp $DBDIR/db.excerpts.work $DBDIR/db.excerpts
cp $DBDIR/db.words.db.work $DBDIR/db.words.db
test -f $DBDIR/db.words.db.work_weakcmpr &&
  cp $DBDIR/db.words.db.work_weakcmpr $DBDIR/db.words.db_weakcmpr

END=`date`
echo End time: $END
echo rundig: End time:     $END >> $REPORT
echo 

# Grab the important statistics from the report file
# All lines begin with htdig: or htmerge:
fgrep "htdig:" $REPORT  
echo 
fgrep "htmerge:" $REPORT
echo
fgrep "rundig:" $REPORT
echo

WC=`wc -l $REPORT`
echo Total lines in $REPORT: $WC

# Send out the report ...
mail -s "$SUBJECT - $STARTTIME" $REPORT_DEST < $REPORT

# ... and clean up
rm $REPORT