#! /bin/sh
###############################################################################
#
# File:         findutils-4.1.locate.after.inst.sh
# RCS:          $Header: $
# Description:  add permission checks to locate
# Author:       Christian Limpach <chris@nice.ch>
# Created:      Mon Apr  3 20:52:47 1995
# Modified:     Wed Apr  5 03:49:17 1995 (Christian Limpach) chris@nice.ch
# Language:     Shell-script
# Package:      N/A
# Status:       Experimental (Do Not Distribute)
#
# (C) Copyright 1995, Christian Limpach, all rights reserved.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see ftp://nice.ethz.ch/users/chris/TERMS
# for details. This software comes with ABSOLUTELY NO WARRANTY.
#
###############################################################################

nidump passwd . | egrep '^[^:]*:[^:]*:([0-9]|[0-9][0-9]):'
echo
echo -n 'enter locatedb user uid: (default 23) '
read uid
if [ "x"$uid = "x" ]; then
  uid=23
fi

nidump passwd . | sed -n "/^nobody:/ s/nobody:\*:-2:/locatedb:*:$uid:/p" | \
  niload passwd .

cd locate
sed '/^LDADD =/ q' Makefile >Makefile2
cat >>Makefile2 <<+ 

install:
	echo "#! /bin/sh" >$(libexecdir)/cron.updatedb
	echo "PATH=/bin:/usr/bin:/usr/etc" >$(libexecdir)/cron.updatedb
	echo "touch $(LOCATE_DB).n" >> $(libexecdir)/cron.updatedb
	echo "chmod 600 $(LOCATE_DB).n" >> $(libexecdir)/cron.updatedb
	echo "cat $(bindir)/updatedb | perl -pe 's/chmod 644/chmod 600/'" \
	     "| sh" >> $(libexecdir)/cron.updatedb
	echo "chown locatedb $(LOCATE_DB)" >> $(libexecdir)/cron.updatedb
	echo "rm -f $(LOCATE_DB).n" >> $(libexecdir)/cron.updatedb
	chmod 755 $(libexecdir)/cron.updatedb
	chown locatedb $(LOCATE_DB) $(bindir)/locate
	chmod 4755 $(bindir)/locate
	echo >/dev/tty
	echo crontab entry suggestion: >/dev/tty
	echo "30 3 * * *              $(libexecdir)/cron.updatedb" >/dev/tty
	
+
make -sf Makefile2 install
rm -f Makefile2
