#! /bin/sh

#
# mkdatabase	- Thomas Bueschgens <sledge@hammer.oche.de>
#
#				Sun Apr 17 12:36:41 MET DST 1994
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/local/bin

# First try of creating a small database containing the complete
# pathnames of .ps and .dmp-files, just containing the directories, so
# less time is spend for this during printing (shouldn't be a
# significant factor, but who knows?) ;-)
#
# This database should be updated on a regular base via cron, every
# hour sound good, since no performance-loss should be expected during
# update. Only systems with LARGE disks and lots of users may realize
# it...
#
# I hope Andreas will forgive me for my ideas
#
#


# Get the home-dirs of all users with uid >= 99, ps & dmp-files are
# likely to reside there.

# Pasing an argument like UserID to awk would be moe elegant and
# flexible, but we've got to live with it

FINDPATH=`awk -f /usr/lib/apsfilter/bin/mkdatabase.awk < /etc/passwd`

# Build Database containing pathnames using find
find $FINDPATH -name '*.ps' -o -name '*.dmp' -o -name '*.eps'	\
	| xargs -i dirname {}					\
	| sort							\
	| uniq							\
	> /usr/lib/apsfilter/bin/database.var

# Setting the right ownership of database.var
chown bin.bin /usr/lib/apsfilter/bin/database.var

# Try to get the permissions right, so noone is able to tamper with
# it, ok?  But since PATH also includes /usr/local/bin this may be a
# security hole anyway.
chmod a=r /usr/lib/apsfilter/bin/database.var
