Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

ph (cso nameserver) Frequently Asked Questions (FAQ)
Section - 1.3 How do I create a ph database?

( Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Forum archive ]


Top Document: ph (cso nameserver) Frequently Asked Questions (FAQ)
Previous Document: 1.2.1 Where should the database files be kept?
Next Document: 1.4 How do I enable phquery for fuzzy mail addressing?
See reader questions & answers on this topic! - Help others by sharing your knowledge
To create a database, you need to define the fields for the database,
determine its size, create a text file of data to be input into the
database, then run the database building programs. 

a. Defining the database

A ph database is defined by a "cnf" file.  The default file which comes
with ph is "prod.cnf".  It's a good idea to start with a copy of this
file, and to change as little as possible.  Some clients rely on the names
of certain fields in the cnf file, so changing them can cause unforeseen
problems.  The ph installation instructions specifically state that you
should NOT change the following fields: 

Used in ph source code
----------------------
2:email
3:name
4:type
5:id
6:alias
7:password
8:proxy
23:nickname
25:all
30:hero
43:suppress

Used by utilities and clients
-----------------------------
0:address
1:phone
9:department
10:title
11:curriculum
20:home_address
21:permanent_address
22:office_address
26:callsign
31:no_update
32:office_phone
33:home_phone
35:high_school
37:permanent_phone
42:left_uiuc

You should be able to change other fields without causing too many
problems.  For each field in the file, you will see a field number, a
field name, the number of bytes in the field, a descriptive name, and a
list of properties for the field.  Each of these items is separated by a
colon, with field entries separated by new lines.  You will probably want
to change the descriptions of some of the fields, as well as their length
in bytes, but you should generally leave the names and numbers alone. 

There are numerous properties you can assign to a field, and most sites
will want to customize these properties.  The most commonly changed
properties are as follows: 

1. Lookup: if present, clients can search on this field

2. Public: if present, clients can see this field.  LocalPub is a
variation which allows only clients in the local domain to see the field. 
If neither is present, only the system administrators and owners can see
the field. 

3. Default: If this is present, the contents of the field are returned on
normal searches.  If not present, the contents are returned only when
specifically requested by the client. 

4. Change: if present, clients who have authenticated (logged in) can
change the contents of the field. 

b. Creating an input file

To create an input file, you create a tab-delimited file containing the
information for the database.  Each line will be composed of field
numbers, a colon, the data for the field, and a tab (if another field
follows).  The format looks like this: 

fieldnum:data-for-field (tab)	fieldnum:data-for-field... (new line)

Here's a simple example:

3:Hunter, Noel C	32:759-5812	 22:POBox 7408	4:p
3:Dominick, James Lyon	32:759-5261	4:p

This example has two records, one for Noel Hunter, and one for James
Dominick.  Both records include data for fields 3,4 and 32, and the entry
for Noel Hunter also has data for field 22. 

Notice that the entries do not have to be in any order, and that some
entries can contain more fields than others.  Field 4, the "type" field,
must be present if you want ph to limit the number of entries returned by
searches. 

c. Building the database

Assuming that the database cnf file (see a, above) is called "prod.cnf",
and the database text input file (see b, above) is called "qi.input", we
can create a ph database with the following shell script (note that this
version now works on a copy rather than the production database,
minimizing the time that the server is down): 

#!/bin/sh
# PH database build script
# Designed from numerous contributions to the info-ph list
# Coded by Noel Hunter (noel@camelcity.com)
# 
# Builds a PH Database from the input stored in the file qi.input.
# During the build, works on a copy of the database, not the working version.
# If disk space is a premium, modify the script to work on prod, not prod-new.
#
# The latest version of this script is available from:
# http://www.camelcity.com/~noel/usenet/ph-build.sh
#
echo "PH database build script started..."
#
# cd to the cso library directory.  We assume all the cso programs  
# are installed here:
cd /usr/local/lib/cso
#
echo "Making a working copy of prod.cnf for building the new database..."
cp prod.cnf prod-new.cnf
#
# Determine the size for the database using the "sizedb" program
# that comes with the server.  You need perl to use sizedb, along
# with the file primes.shar.  If you don't have these, you can hard-
# code in a prime bigger than the number of indexed fields (from the
# cnf file) times the number of records in your database (qi.input):
echo "Calculating size..."
size=`./sizedb prod-new.cnf qi.input`
#
# Build the database using the specifications in "prod-new.cnf", and the
# data in "qi.input"
echo "Executing credb..."
./credb $size prod-new
echo "Executing maked..."
./maked prod-new <qi.input
echo "Executing makei..."
./makei prod-new
echo "Executing build..."
./build -s prod-new
#
# Move the new database into place:
echo "Moving database into place..."
mv prod-new.bdx prod.bdx
mv prod-new.bnr prod.bnr
mv prod-new.dir prod.dir
mv prod-new.dov prod.dov
mv prod-new.idx prod.idx
mv prod-new.iov prod.iov
mv prod-new.lck prod.lck
mv prod-new.seq prod.seq
#
# Set permissions so that users cannot access the database directly.
# We assume that the qi server is running under a login that can
# access the files, if not, change "whois" below to the appropriate
# user name:
chown whois *
chmod -R o-rwx,g-rwx *
#
echo "PH database build script complete."

User Contributions:

Comment about this article, ask questions, or add new information about this topic:




Top Document: ph (cso nameserver) Frequently Asked Questions (FAQ)
Previous Document: 1.2.1 Where should the database files be kept?
Next Document: 1.4 How do I enable phquery for fuzzy mail addressing?

Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
noel@camelcity.com (PH FAQ Coordinators)





Last Update March 27 2014 @ 02:12 PM