discourse-legacysite-perl/site/glist/templates/help/GT/Installer.html
2024-06-17 22:24:05 +10:00

714 lines
22 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GT::Installer - Performs initial installs for GTI products</title>
<link rev="made" href="mailto:root@penguin.office.gossamer-threads.com" />
<style type="text/css">
/* $MVD$:fontset("Untitled Font Set 1","ARIEL","HELVETICA","HELV","SANSERIF") */
/* $MVD$:fontset("Arial","Arial") */
/* $MVD$:fontset("Arial Black","Arial Black") */
/* $MVD$:fontset("Algerian","Algerian") */
body {
background-color: white;
font-family: Verdana, Arial, sans-serif;
font-size: small;
color: black;
}
p {
background-color : white;
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
h1 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : medium;
background-color : white;
color : maroon;
}
h2 {
font-family : Verdana, Arial, sans-serif;
font-size : medium;
font-weight : bold;
color : blue;
background-color : white;
}
h3 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : medium;
color : black;
background-color : white;
}
h4 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : maroon;
background-color : white;
}
h5 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : blue;
background-color : white;
}
h6 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : small;
color : black;
background-color : white;
}
ul {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
ol {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dl {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
li {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
th {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
td {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dl {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dd {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
dt {
font-family : Verdana, Arial, sans-serif;
font-size : small;
color : black;
}
code {
font-family : Courier;
font-size : small;
color : black;
}
pre {
font-family : Courier;
font-size : small;
color : black;
}
.mvd-H1 {
font-family : Verdana, Arial, sans-serif;
font-weight : bold;
font-size : 14.0pt;
background-color : transparent;
background-image : none;
color : maroon;
}
.mvd-H2 {
font-family : Verdana, Arial, sans-serif;
font-size : 12.0pt;
color : blue;
}
p.indent {
font-family : "Verdana, Arial, sans-serif";
list-style-type : circle;
list-style-position : inside;
color : black;
margin-left : 16.0pt;
}
.mvd-P-indent {
font-family : Verdana, Arial, sans-serif;
list-style-type : circle;
list-style-position : inside;
color : black;
margin-left : 16.0pt;
}
pre.programlisting {
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
.mvd-PRE-programlisting {
font-size : 9.0pt;
list-style-type : disc;
margin-left : 16.0pt;
margin-top : -14.0pt;
}
.mvd-PRE {
font-size : 9.0pt;
}
p.note {
margin-left : 28.0pt;
}
.mvd-P-note {
margin-left : 28.0pt;
}
.mvd-H4 {
font-family : Verdana, Arial, sans-serif;
font-weight : normal;
font-size : 9.0pt;
color : black;
margin-left : 6.0pt;
margin-top : -14.0pt;
}
.mvd-P {
font-family : Verdana, Arial, sans-serif;
font-size : 10.0pt;
color : black;
}
.mvd-BODY {
font-family : Verdana, Arial, sans-serif;
background-color : white;
}
p.indentnobullet {
font-family : Verdana, Arial, sans-serif;
list-style-type : none;
}
.mvd-P-indentnobullet {
font-family : Verdana, Arial, sans-serif;
list-style-type : none;
}
</style>
</head>
<body style="background-color: white">
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<ul>
<li><a href="#creating_a_new_gt__installer_object">Creating a new GT::Installer object</a></li>
<li><a href="#add_config__adding_configuration_options_">add_config - Adding configuration options.</a></li>
<li><a href="#add_config_message__add_a_configuration_message_">add_config_message - Add a configuration message.</a></li>
<li><a href="#install_exit_message__add_an_exit_message_for_installs_">install_exit_message - Add an exit message for installs.</a></li>
<li><a href="#install_to__specify_where_to_untar_files_to_">install_to - Specify where to untar files to.</a></li>
<li><a href="#use_lib__set_the_use_lib_path_for_addition_to_all__pl_and__cgi_files_">use_lib - Set the use lib path for addition to all .pl and .cgi files.</a></li>
<li><a href="#replace_path__generic_method_to_replace_paths_upon_install">replace_path - Generic method to replace paths upon install</a></li>
<li><a href="#add_upgrade__adding_upgrade_options_">add_upgrade - Adding upgrade options.</a></li>
</ul>
<li><a href="#copyright">COPYRIGHT</a></li>
<li><a href="#version">VERSION</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>GT::Installer - Performs initial installs for GTI products</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
main();</pre>
<pre>
sub main {
my $format = 'scroll1';
my $installer = GT::Installer-&gt;new(
product =&gt; 'Gossamer Mail',
version =&gt; '2.0.0 beta 1',
load_defaults =&gt; \&amp;load_defaults,
load_config =&gt; \&amp;load_config,
save_config =&gt; \&amp;save_config,
checksums =&gt; &quot;&lt;%Data Path%&gt;/admin/checksums&quot;,
welcome_format =&gt; $format
);</pre>
<pre>
$installer-&gt;add_config_message(q|
This should be the system path and url (start with <a href="http://">http://</a>)
to the directory where your admin files are. No trailing
slash please.|, $format);</pre>
<pre>
$installer-&gt;add_config(
type =&gt; 'path',
key =&gt; &quot;Admin Path&quot;,
message =&gt; 'Admin Path',
);
}
# Regex to path keys. These regexs have to capture
# the file in $1
$installer-&gt;install_to(
'^admin/(.*)$' =&gt; 'Admin Path',
'^user/(.*)$' =&gt; 'User Path',
'^batch/(.*)$' =&gt; 'Batch Path',
'^data/(.*)$' =&gt; 'Data Path',
'^images/(.*)$' =&gt; 'Images Path',
);
$installer-&gt;add_upgrade(
message =&gt; 'Program Files. e.g. .pm, .pl and .cgi files',
file_list =&gt; '\.(?:pl|cgi|pm)$'
);
$installer-&gt;add_upgrade(skip =&gt; 'ConfigData\.pm$');
$installer-&gt;perform;
}</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>GT::Installer is an installer class for all Gossamer Threads
products. It will handle both a command line interface and a
CGI inteface.</p>
<p>All intallation directives are specified at the start and are
called for each CGI request if being ran in CGI mode.</p>
<p>
</p>
<h2><a name="creating_a_new_gt__installer_object">Creating a new GT::Installer object</a></h2>
<p>There are several options when creating a new GT::Installer
object. All options are in the form of key value pairs. The
options can be passed in as a flattened hash or as a hash
reference.</p>
<p>There are two options that must be specified. These are
<em>product</em> and <em>version</em>. All other options are optional.</p>
<p>There are two ways to get a GT::SQL object. First, you can simply
provide the path to the def file directory where GT::SQL stores all
it's information:</p>
<pre>
$db = new GT::SQL '/path/to/def';</pre>
<p>or you can pass in a hash or hash ref and specify options:</p>
<pre>
$db = new GT::SQL {
def_path =&gt; '/path/to/def',
cache =&gt; 1,
debug =&gt; 1,
subclass =&gt; 1
);</pre>
<p>You must specify def_path. Setting cache =&gt; 1, will result in
all table or relation objects to be cached which can improve
performance.</p>
<p>Setting subclass =&gt; 0 or subclass =&gt; 1 will enable or disable
the ability to subclass any of the objects GT::SQL creates. The
default behaviour is 1.</p>
<p>GT::SQL has advanced debugging, and setting it to 1 should be
adequate for most operations.</p>
<dl>
<dt><strong><a name="item_product">product</a></strong><br />
</dt>
<dd>
Specifies the name of the product. This name is used in the
welcome message and in various parts of the dialogue.
</dd>
<dd>
<pre>
product =&gt; 'Gossamer Mail'</pre>
</dd>
<p></p>
<dt><strong><a name="item_version">version</a></strong><br />
</dt>
<dd>
This is the version of the product. It is used on the startup
screen to tell the user what version we are installing or
upgrading to.
</dd>
<dd>
<pre>
version =&gt; '2.0.0 beta 1'</pre>
</dd>
<p></p>
<dt><strong><a name="item_load_defaults">load_defaults</a></strong><br />
</dt>
<dd>
This is a code reference that is called when installing. It
is used to defaults for prompts you have set up. The only
argument to this code reference if the installer object
which has method to assist in setting up defaults for the
different configuration options that you would specify.
</dd>
<dd>
<p>If you return false from this code reference the error is
expected to be in GT::Installer::error. GT::Installer inherets
from GT::Base so you can just call the <em>error</em> method on the
object and return it to achieve this.</p>
</dd>
<dd>
<pre>
load_defaults =&gt; \&amp;load_defaults</pre>
</dd>
<p></p>
<dt><strong><a name="item_load_config">load_config</a></strong><br />
</dt>
<dd>
This is another code reference. It is called when the user
specifies that they are doing an upgrade. The argument to
this callback is the installer object. The path to the admin
directory of the last install is a key in the installer object
<em>admin_path</em>. In this code reference you will need to correlate
all the config option keys to the values in your config file.
See the example included in this pod for a possible why to
do this.
</dd>
<dd>
<pre>
load_config =&gt; \&amp;load_config</pre>
</dd>
<dd>
<p>If you return false from this code reference the error is
expected to be in GT::Installer::error. GT::Installer inherets
from GT::Base so you can just call the <em>error</em> method on the
object and return it to achieve this.</p>
</dd>
<p></p>
<dt><strong><a name="item_save_config">save_config</a></strong><br />
</dt>
<dd>
This is a code reference that is called after an install or
upgrade. It gives you the opertunity to save any user input into
there new/old config file.
</dd>
<dd>
<pre>
save_config =&gt; \&amp;save_config</pre>
</dd>
<p></p>
<dt><strong><a name="item_checksums">checksums</a></strong><br />
</dt>
<dd>
This should be set to the full system path to the checksum file.
If this is not set checksums will not be used, which makes
the upgrade questions usless and all files will be overridden.
There is no possible way you can know the full path to this file
at the point you set it. You can specify tags in this path
that will get replaced with what the user entered. The tags
are similar to <a href="glist.cgi?do=admin_gtdoc&topic=/GT/Template.html">the GT::Template manpage</a> tags in that they start with
<em>&amp;lt;%</em> and end with <em>%&amp;gt;</em>. No other <a href="glist.cgi?do=admin_gtdoc&topic=/GT/Template.html">the GT::Template manpage</a> tags conventions
are used.
</dd>
<dd>
<pre>
checksums =&gt; &quot;&lt;%Data Path%&gt;/admin/checksums&quot;</pre>
</dd>
<p></p>
<dt><strong><a name="item_welcome_format">welcome_format</a></strong><br />
</dt>
<dd>
This is the welcome format. There are named formats that are
used in GT::Installer for most command line output. This
is the one that is used for the initial message. This is not
used in CGI mode.
</dd>
<dd>
<p>There are currently 4 formats (more to come :)). There are:</p>
</dd>
<dl>
<dt><strong><a name="item_scroll1">scroll1</a></strong><br />
</dt>
<dd>
<pre>
_________________________________________________________________
/\ \
\_| |
| |
| This is the scroll1 format |
| ______________________________________________________________|_
\_/_______________________________________________________________/</pre>
</dd>
<dt><strong><a name="item_scroll2">scroll2</a></strong><br />
</dt>
<dd>
<pre>
__^__ __^__
( ___ )--------------------------------------------------------------( ___ )
| / | | \ |
| / | This is the scroll2 format | \ |
|___| |___|
(_____)--------------------------------------------------------------(_____)</pre>
</dd>
<dt><strong><a name="item_professional">professional</a></strong><br />
</dt>
<dd>
<pre>
#================================================================#
= =
= This is the professional format =
#================================================================#</pre>
</dd>
<dt><strong><a name="item_none">none</a></strong><br />
</dt>
<dd>
This format just performs line wraps. Has no outline :(
</dd>
<p></p></dl>
</dl>
<p>
</p>
<h2><a name="add_config__adding_configuration_options_">add_config - Adding configuration options.</a></h2>
<p>There are 3 methods for adding user prompts. When I say user promts I
mean that in the telnet sence, in CGI mode it is just a table row.</p>
<p>This is the method you will be calling for every install option the
user should specify. This method takes it's arguments as key value
pair. The arguments can either be in the form of a flatened hash or
a hash reference.</p>
<pre>
$installer-&gt;add_config(
type =&gt; 'url',
key =&gt; &quot;Admin URL&quot;,
message =&gt; 'Admin URL',
telnet_callback =&gt; \&amp;telnet_callback,
);</pre>
<p>Each key in the hash defines an attribute of the user prompt.</p>
<dl>
<dt><strong><a name="item_type">type</a></strong><br />
</dt>
<dd>
The type attribute should be one of the built in input types. There is
currently no way to specify your own type. If this becomes a problem
it will be added. The built in types are as follows.
</dd>
<dd>
<pre>
url - User specifies a URL.
ftp - User specifies an FTP URL.
path - User specifies a Path to something on the system.
message - This is the same as calling the add_config_message
method.
create_dirs - This is a yes/no answer on weather the user wants the
directories for this install created.
email - User specifies and email address. This is commonly
used to prompt for the admin email address.
reg_number - User specifies the registration number they recieved
from us when they paid for the product.
email_support - Specify either the path to sendmail or the hostname
of an smtp server. What is specified with be in the
config hash as email_support. The key default for
this option is Mailer.
perl_path - Specify the path to perl on this system.</pre>
</dd>
<p></p>
<dt><strong><a name="item_key">key</a></strong><br />
</dt>
<dd>
Each item the user enters is stored in a hash in the installer object.
This hash is called <em>config</em>. This specifies the key used in that hash
to store this user option.
</dd>
<dd>
<p>This key is also used at the end of the telnet install to display
the options the user has specified for the install.</p>
</dd>
<dd>
<p>You will be accessing these keys in your configuration callbacks to
either set defaults or save the user specified options in your config
file. See the complete example below to see how this is used.</p>
</dd>
<p></p>
<dt><strong><a name="item_message">message</a></strong><br />
</dt>
<dd>
This is the message the user is pompted with in telnet. From the with
this appears on the left of the form the user fills out.
</dd>
<dd>
<p>This will default to the value of the <em>key</em> if not specified</p>
</dd>
<p></p>
<dt><strong><a name="item_telnet_callback">telnet_callback</a></strong><br />
</dt>
<dd>
This is a code reference that, if specified, will be ran after the user
enteres the information. You can use this to tweek the other option
defaults. If this method returns false the user will be reprompted for
the information. So you can effectivly use this to validate command
line input.
</dd>
<p></p></dl>
<p>
</p>
<h2><a name="add_config_message__add_a_configuration_message_">add_config_message - Add a configuration message.</a></h2>
<p>This is a method to add a configuration message. This message is
displayed to the user in telnet in the order you specify it. No prompt
is performed for these messages.</p>
<p>This is a shortcut function that is the same as specifing:</p>
<pre>
$installer-&gt;add_config(
type =&gt; 'message',
message =&gt; 'This message is displayed to the user',
format =&gt; 'none'
);</pre>
<p>The arguments to this function are (message, format). Message is what
is displayed, format is the format used. See above for a list of
formats.</p>
<pre>
$installer-&gt;add_config_message(q|My configuration message.|, 'professional');</pre>
<p>
</p>
<h2><a name="install_exit_message__add_an_exit_message_for_installs_">install_exit_message - Add an exit message for installs.</a></h2>
<p>This is the message that is displayed after the installation is
complete. This message uses the same convention for tags as the
<em>checksum</em> option for the constructor method. Any keys that are set
during the install will be available as tags here. The second argument
to this method is an optional format (used in telnet see above).</p>
<pre>
$installer-&gt;install_exit_message(q|
To run the setup, point your browser to:
&lt;a href=&quot;&lt;%Admin URL%&gt;/admin.cgi&quot;&gt;&lt;%Admin URL%&gt;/admin.cgi&lt;/a&gt;
|, 'scroll2');</pre>
<p>
</p>
<h2><a name="install_to__specify_where_to_untar_files_to_">install_to - Specify where to untar files to.</a></h2>
<p>The way this options is specified is a bit strange and my be rewritten.
It takes it arguments as a hash of regular expressions to keys. The
keys are the keys you specified with add_config(). The regexs are matched
against the relative path in the tar file. Anything captured in $1 is
appended to the value the user entered for that regexs key. For example
is you specify a key <em>Admin Path</em> such as</p>
<pre>
$installer-&gt;add_config(
type =&gt; 'path',
key =&gt; 'Admin Path'
);</pre>
<p>You could then use the key like:</p>
<pre>
$installer-&gt;install_to(
'^admin/(.*)' =&gt; 'Admin Path'
);</pre>
<p>This would replace admin/ in the relative path in the tar file with what
the user entered for the Admin Path prompt.</p>
<p>
</p>
<h2><a name="use_lib__set_the_use_lib_path_for_addition_to_all__pl_and__cgi_files_">use_lib - Set the use lib path for addition to all .pl and .cgi files.</a></h2>
<p>The argument to this should be a <em>key</em> specified with add_config(). The
path the user entered for that config is added to all .cgi and .pl files
in a <em>use lib ''</em> statement. Followig the example above:</p>
<pre>
$installer-&gt;use_lib('Admin Path');</pre>
<p>All .cgi and .pl file in the install will now have</p>
<pre>
use lib '/home/bline/projects/library';</pre>
<p>added to them assuming the path the user entered for that config option was
<em>/home/bline/projects/library'</em>.</p>
<p>You can set $GT::Installer::USE_LIB_SPACES to something other than the default
4 spaces to alter the number of spaces that will be put before the ``use lib''.
Please be careful - if you set this to something other than whitespace you are
asking for trouble or being an 1337 h4xx0r.</p>
<p>
</p>
<h2><a name="replace_path__generic_method_to_replace_paths_upon_install">replace_path - Generic method to replace paths upon install</a></h2>
<p>The argument should be a hash of key =&gt; value replacements that should be
made upon installation.</p>
<pre>
$installer-&gt;replace_path(
'../private/ConfigData.pm' =&gt; '&lt;%Private_Path%&gt;/ConfigData.pm'
);</pre>
<p>This will replace all occurrences of ../private/ConfigData.pm with what the
user entered in &lt;%Private_Path%&gt;.</p>
<p>
</p>
<h2><a name="add_upgrade__adding_upgrade_options_">add_upgrade - Adding upgrade options.</a></h2>
<p>This is a method for grouping files and or directories under user prompted
upgrade options. This is <em>NOT</em> designed to be a complete upgrade system. It
handled basic checksuming, overwrites and backup. This should probably not
be used for a major upgrade.</p>
<p>more to come...</p>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (c) 2004 Gossamer Threads Inc. All Rights Reserved.
<a href="http://www.gossamer-threads.com/">http://www.gossamer-threads.com/</a></p>
<p>
</p>
<hr />
<h1><a name="version">VERSION</a></h1>
<p>Revision: $Id: Installer.pm,v 1.93 2005/03/27 20:52:53 jagerman Exp $</p>
</body>
</html>