	      Instruction to start a database based rpmfind site
	      ==================================================

	                   Michael B. Weiner
			 hunter@userfriendly.net

			   Daniel Veillard
			 daniel@veillard.com


Initial standard setup:
-----------------------

   A Linux preferably Red Hat or RPM based machine with Apache + MySql + Php,
on a Red Hat 7.1 the packages needed are:
       apache-1.3.19-5.i386.rpm
       apacheconf-0.7-2.noarch.rpm
       apache-devel-1.3.19-5.i386.rpm
       mysql-3.23.36-1.i386.rpm
       mysqlclient9-3.23.22-4.i386.rpm
       mysql-devel-3.23.36-1.i386.rpm
       mysql-server-3.23.36-1.i386.rpm
       php-4.0.4pl1-9.i386.rpm
       php-devel-4.0.4pl1-9.i386.rpm
       php-mysql-4.0.4pl1-9.i386.rpm

Follow the mysql instructions for the base install (change the root
password 'mysqladmin -u root password new_password' !)

Grab and compile rpm2html with database support:
------------------------------------------------

  Create a user who will run the indexing, log in as the user and
extract the CVS version following the instructions given at
    http://rpmfind.net/linux/rpm2html/download.html

        - shell> cd rpm2html
	- shell> autoconf ; autoheader ; ./configure --with-sql
	         [...]
        - shell> make

this should produce 2 binaries, rpm2html and sqltools


rpm2html mysql db setup:
------------------------
As root, create and set the proper permissions for the database 'rpmfind'

	- shell> mysqladmin -p create rpmfind
	- shell> mysql -u root mysql -p
	         password:
	- mysql> GRANT ALL PRIVILEGES ON *.* TO user@localhost
	      -> IDENTIFIED BY 'xxxx' WITH GRANT OPTION;

of course use something different than 'xxxx'

Check the rpmfind database and create tables as the user:
---------------------------------------------------------

log on as the 'user', then check you have access:

        - shell> mysql -p
	         password: (the user password xxxx)
	- mysql> use rpmfind
	  Database changed
	  mysql> quit
	  Bye

Make sure you export your MySQL_PASS=xxxx within the 'user' shell that
has access to update/read/write/etc the 'rpmfind' database then run 

        - shell> sqltools stat

It should warn about the lack of tables and create them showing 0 records
at the end.
Start running the indexer (the path to the binary or to your config file
may be different:

        - shell> cd rpm2html
	- shell> ./rpm2html rpm2html.config

this should import the config options and start the indexing. You can stop it
and restart it incrementally:

        - shell> export MySQL_PASS=XXXX ; cd $HOME/rpm2html ;
	         $HOME/rpm2html/sqltools reindex

Allowing Apache/PHP to access the tables:
-----------------------------------------

Assuming the PHP script runs as user nobody (apache usual setup),
this gives read-only access to the tables and read-write to the
table storing the requests and their number:

GRANT SELECT ON rpmfind.* TO nobody@localhost;
GRANT INSERT,SELECT,UPDATE  ON rpmfind.Queries TO nobody@localhost;

Adding mirrors to the list in the PHP pages:
--------------------------------------------

INSERT INTO Searches (URL,name,active) VALUES
('http://speakeasy.rpmfind.net/linux/rpm2html/search.php','speakeasy',1);

etc...


Install the cron jobs building the database and indexes:
--------------------------------------------------------

# NEW rpm2html cronjobs
10 0 * * * export MySQL_PASS=XXXX ; $HOME/rpm2html/sqltools resources ; $HOME/rpm2html/sqltools topindex
5 0,8,16 * * * export MySQL_PASS=XXXX ; $HOME/rpm2html/sqltools all
30 1 * * * killall sqltools ; killall rpm2html ; find /home2/httpd/html/linux/RPM -not -type d -a -not -type l -mtime +15 -exec rm {} \; ; export MySQL_PASS=XXXX ; cd $HOME/rpm2html ; $HOME/rpm2html/sqltools reindex
35 */4 * * * export MySQL_PASS=XXXX ; cd $HOME/rpm2html ; $HOME/rpm2html/sqltools reindex ; $HOME/rpm2html/sqltools resources ; $HOME/rpm2html/sqltools topindex
30 1,9,17 * * * export MySQL_PASS=XXXX ; $HOME/rpm2html/sqltools check ; $HOME/rpm2html/sqltools stats
