summaryrefslogtreecommitdiff
path: root/usr.bin/locate
diff options
context:
space:
mode:
authorsimonb <simonb@NetBSD.org>2020-02-06 08:45:44 +0000
committersimonb <simonb@NetBSD.org>2020-02-06 08:45:44 +0000
commitf5c7abb3ed7c41a92946a28a87ffe0068c6580dd (patch)
treee1e10a769c8755f373fc3fa459fd7cc9644f5c88 /usr.bin/locate
parent9a419c9737a60a080647cce274aaa37eea8143b4 (diff)
Add support for specifying an alternate locate.updatedb config file.
Diffstat (limited to 'usr.bin/locate')
-rw-r--r--usr.bin/locate/locate/locate.updatedb.818
-rw-r--r--usr.bin/locate/locate/updatedb.sh34
2 files changed, 46 insertions, 6 deletions
diff --git a/usr.bin/locate/locate/locate.updatedb.8 b/usr.bin/locate/locate/locate.updatedb.8
index 7e1f80ecdd5..19a5d4c9481 100644
--- a/usr.bin/locate/locate/locate.updatedb.8
+++ b/usr.bin/locate/locate/locate.updatedb.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: locate.updatedb.8,v 1.3 2008/09/22 13:10:25 hubertf Exp $
+.\" $NetBSD: locate.updatedb.8,v 1.4 2020/02/06 08:45:44 simonb Exp $
.\"
.\" Copyright (c) 1999-2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 5, 2005
+.Dd February 6, 2020
.Dt LOCATE.UPDATEDB 8
.Os
.Sh NAME
@@ -35,6 +35,7 @@
.Nd update locate database
.Sh SYNOPSIS
.Nm /usr/libexec/locate.updatedb
+.Op Fl c Ar file
.Sh DESCRIPTION
The
.Nm
@@ -46,6 +47,19 @@ It is usually run once per week, see
.Pp
The file systems and files (not) scanned can be configured in
.Xr locate.conf 5 .
+.Sh OPTIONS
+The
+.Nm
+program supports this option:
+.Bl -tag -width XcXfileXX
+.It Fl c Ar file
+Use
+.Ar file
+(in
+.Xr locate.conf 5
+format) as the configuration file instead of the default
+.Pa /etc/locate.conf .
+.El
.Sh FILES
.Bl -tag -width /usr/libexec/locate.updatedb -compact
.It Pa /var/db/locate.database
diff --git a/usr.bin/locate/locate/updatedb.sh b/usr.bin/locate/locate/updatedb.sh
index 1a72f74bcd2..4a435eac853 100644
--- a/usr.bin/locate/locate/updatedb.sh
+++ b/usr.bin/locate/locate/updatedb.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: updatedb.sh,v 1.15 2014/08/04 21:56:30 apb Exp $
+# $NetBSD: updatedb.sh,v 1.16 2020/02/06 08:45:44 simonb Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
@@ -40,10 +40,9 @@
#
LIBDIR="/usr/libexec" # for subprograms
- # for temp files
-TMPDIR=/tmp
+TMPDIR="/tmp" # for temp files
FCODES="/var/db/locate.database" # the database
-CONF=/etc/locate.conf # configuration file
+CONF="/etc/locate.conf" # configuration file
PATH="/bin:/usr/bin"
@@ -97,6 +96,26 @@ shell_quote()
printf "%s\n" "$result"
)}
+args=`getopt c: $*`
+if [ $? -ne 0 ]; then
+ progname=`basename $0`
+ echo 'Usage: ...'
+ echo "usage: ${progname} [-c config]"
+ exit 2
+fi
+set -- $args
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -c)
+ CONF=$2; shift
+ ;;
+ --)
+ shift; break
+ ;;
+ esac
+ shift
+done
+
# read configuration file
if [ -f "$CONF" ]; then
while read -r com args; do
@@ -149,6 +168,13 @@ if [ -f "$CONF" ]; then
echo "$CONF: workdir: $1 nonexistent" >&2
fi
;;
+ database)
+ if [ $# -ne 1 ]; then
+ echo "$CONF: database takes exactly one argument" >&2
+ else
+ FCODES="$1"
+ fi
+ ;;
*)
echo "$CONF: $com: unknown config command" >&2
exit 1