Index  Up  <<  >>  


makecat -- set up a catalog from a template

The supplied makecat script, which is in the MiniVend program directory bin, is designed to set up a catalog based on your server configuration. It interrogates the user for parameters like the directories to use, URL to base the catalog in, HTTP server definitions, and file ownership. It is self-documenting in that it asks verbose questions and gives relevant examples.

The makecat script needs a template catalog to operate on. The simple and basic demo templates are distributed with MiniVend. You can also look for older demo catalogs (mostly for ideas) at ftp.minivend.com.

IMPORTANT NOTE: You only make a catalog once. All further configuration is done by editing the files within the catalog directory.

A catalog template contains an image of a configured catalog. The best way to see what the makecat program does is to configure the simple demo and then run a recursive diff on the template and configured catalog directories:

  diff -r mvend/simple catalogs/simple

NOTE: diff is usually only available on UNIX.

You will see that the files are mostly the same, except that certain macro strings have been replaced with the answers you gave to the script. For example, if you answered www.mydomain.com at the prompt for server name, then you would see this difference in the catalog.cfg file:

    # template
    Variable SERVER_NAME  &#32;_MVC_SERVERNAME__

    # configured catalog
    Variable SERVER_NAME  www.mydomain.com

The macro string &#32;_MVC_SERVERNAME__ was substituted with the answer to the question about server name. In the same way, other variables are substituted, and include (at least):

    MVC_BASEDIR      MVC_IMAGEDIR
    MVC_CATROOT      MVC_IMAGEURL
    MVC_CATUSER      MVC_MAILORDERTO
    MVC_CGIBASE      MVC_MINIVENDGROUP
    MVC_CGIDIR       MVC_MINIVENDUSER
    MVC_CGIURL       MVC_SAMPLEHTML
    MVC_DEMOTYPE     MVC_SAMPLEURL
    MVC_DOCUMENTROOT MVC_VENDROOT
    MVC_ENCRYPTOR

(Not all of these are present in the simple or sample templates, and quite a few more may be defined.) In fact, any environment variable that is set and begins with MVC_ will be substituted for by the makecat script. So if you wanted to set up a configurable parameter to customize the COMPANY variable in catalog.cfg, you could run a pre-qualifying script that set the environment variable MVC_COMPANY and then place in the catalog.cfg file:

    Variable   COMPANY   &#32;_MVC_COMPANY__

All files within a template directory are substituted for macros, not just the catalog.cfg file. There are two special directories named html and images. These will be recursively copied to the directories defined as SampleHTML and ImageDir.

IMPORTANT NOTE: The template directory is located in the MiniVend software directory, i.e. where minivend.cfg resides. You normally do not edit files in the template directory. If you want to try creating your own template, it is recommended that you name it something besides simple and copy the simple demo directory to it as a starting point. Templates are normally placed in the MiniVend base directory, but can be located anywhere -- the script will prompt you for location if it cannot find a template.

In addition to the standard parameters prompted for by MiniVend, and the standard catalog creation procedure, you may define four other files in the config directory of the template:

    additional_fields  -- file with more parameters for macro substitution
    additional_help    -- extended description for the additional_fields
    precopy_commands   -- commands passed to the system prior to catalog copy
    postcopy_commands  -- commands passed to the system after catalog copy

All files are paragraph-based; in other words, a blank line (with no spaces) terminates the individual setting.

The additional_fields file contains:

    PARAM
    The prompt. Set PARAM to?
    The default value of PARAM

This would cause a question during makecat:

    The prompt. Set PARAM to?.....[The default value of PARAM]

If the additional_help file is present, you can give additional instructions for PARAM.

    PARAM
    These are additional instructions for PARAM, and they
    may span multiple lines up to the first blank line.

The prompt would now be:

    These are additional instructions for PARAM, and they
    may span multiple lines up to the first blank line.

    The prompt. Set PARAM to?.....[The default value of PARAM]

If the file config/precopy_commands exists, it will be read as a command followed by the prompt/help value.

    mysqladmin create &#32;_MVC_CATALOGNAME__
    We need to create an SQL database for your Minivend
    database tables.

This will cause the prompt:

    We need to create an SQL database for your Minivend
    database tables.
     
    Run command "mysqladmin create simple"?

If the response is ``y'' or ``yes'', then the command will be run by passing it through the Perl system() function. As with any of the additional configuration files, MVC_PARAM macro substitution is done on the command and help. Obviously you must have proper permissions for the command.

The file config/postcopy_commands is exactly the same as precopy_commands except you are prompted after the catalog files are copied and macro substitution is performed on all files.


Index  Up  <<  >>