-.\" $OpenBSD: locate.updatedb.8,v 1.2 1996/09/15 16:50:39 michaels Exp $
+.\" $OpenBSD: locate.updatedb.8,v 1.3 1997/01/04 01:36:01 millert Exp $
.\"
.\" Copyright (c) 1996
.\" Mike Pritchard <mpp@FreeBSD.org>. All rights reserved.
.Nd update locate database
.Sh SYNOPSIS
.Nm /usr/libexec/locate.updatedb
+.Op Fl --tmpdir=dir
+.Op Fl --fcodes=dbfile
+.Op Fl --searchpaths='dir1 dir2...'
+.Op Fl --prunepaths='dir1 dir2...'
+.Op Fl --filesystems='type1 type2...'
.Sh DESCRIPTION
.Nm Locate.updatedb
updates the database used by
.Xr locate 1 .
It is typically run once a week by the
-.Nm /etc/weekly script.
+.Pa /etc/weekly
+script.
.Pp
The contents of the newly built database can be controlled by the
-.Nm /etc/locate.rc file.
+.Pa /etc/locate.rc
+file as well as the command line arguments.
+.Sh OPTIONS
+.Bl -tag -width --filesystems
+The available options are as follows:
+.It Fl --tmpdir
+Sets the directory temporary files are stored in.
+.It Fl --fcodes
+Use the named file as the find codes database. If the file
+name ``-'' is given, the database will be sent to standard output.
+.It Fl --searchpaths
+Sets the list of directories to be put in the database.
+.It Fl --prunepaths
+Sets the list of parent directories that should not be go in
+the database.
+.It Fl --filesystems
+A list of filesystem types to be traversed by
+.Xr find 1 .
.Sh FILES
.Bl -tag -width /var/db/locate.database -compact
.It Pa /var/db/locate.database
-the actual database
+the default database
.It Pa /etc/locate.rc
the configuration file
.El
#!/bin/sh
#
-# $OpenBSD: updatedb.sh,v 1.6 1997/01/03 23:33:49 millert Exp $
+# $OpenBSD: updatedb.sh,v 1.7 1997/01/04 01:36:01 millert Exp $
#
# Copyright (c) September 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
# All rights reserved.
#
# updatedb - update locate database for local mounted filesystems
#
-# $Id: updatedb.sh,v 1.6 1997/01/03 23:33:49 millert Exp $
+# $Id: updatedb.sh,v 1.7 1997/01/04 01:36:01 millert Exp $
LOCATE_CONFIG="/etc/locate.rc"
if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then
PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH
+USAGE="Usage: $0 [--tmpdir=dir] [--fcodes=dbfile] [--searchpaths='dir1 dir2...'] [--prunepaths='dir1 dir2...'] [--filesystems='type1 type2...']"
: ${mklocatedb=locate.mklocatedb} # make locate database program
: ${FCODES=/var/db/locate.database} # the database
: ${FILESYSTEMS="ffs"} # allowed filesystems
: ${find=find}
+# Command line args override rc file and defaults
+while test $# != 0; do
+ option=`echo $1 | sed 's/^\([^=]*\).*$/\1/'`
+ optarg=`echo $1 | sed 's/^[^=]*=\(.*$\)/\1/'`
+
+ # All options take an argument
+ if [ "$option" = "$optarg" ]; then
+ echo "$USAGE"
+ exit 1
+ fi
+
+ case "$option" in
+ --tmpdir) TMPDIR="$optarg";;
+ --fcodes) FCODES="$optarg";;
+ --searchpaths) SEARCHPATHS="$optarg";;
+ --prunepaths) PRUNEPATHS="$optarg";;
+ --filesystems) FILESYSTEMS="$optarg";;
+ esac
+ shift
+done
+
case X"$SEARCHPATHS" in
X) echo "$0: empty variable SEARCHPATHS"; exit 1;; esac
case X"$FILESYSTEMS" in
$mklocatedb > $tmp
then
case X"`$find $tmp -size -257c -print`" in
- X) cat $tmp > $FCODES;;
+ X) if [ "$FCODES" = "-" ]; then
+ cat $tmp
+ else
+ cat $tmp > $FCODES
+ fi;;
*) echo "updatedb: locate database $tmp is empty"
exit 1
esac