1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
6 # <sales@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
13 # This work is made available to you under the terms of Version 2 of
14 # the GNU General Public License. A copy of that license should have
15 # been provided with this software, but in any event can be snarfed
18 # This work is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 # 02110-1301 or visit their web page on the internet at
27 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 # CONTRIBUTION SUBMISSION POLICY:
32 # (The following paragraph is not intended to limit the rights granted
33 # to you to modify and distribute this software under the terms of
34 # the GNU General Public License and is only of importance to you if
35 # you choose to contribute your changes and enhancements to the
36 # community by submitting them to Best Practical Solutions, LLC.)
38 # By intentionally submitting any modifications, corrections or
39 # derivatives to this work, or any other work intended for use with
40 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 # you are the copyright holder for those contributions and you grant
42 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 # royalty-free, perpetual, license to use, copy, create derivative
44 # works based on those contributions, and sublicense and distribute
45 # those contributions and any derivatives thereof.
47 # END BPS TAGGED BLOCK }}}
49 package RT::Installer;
53 require UNIVERSAL::require;
56 Widget => '/Widgets/Form/Select',
58 Description => 'Database type', # loc
63 } qw/mysql Pg SQLite Oracle/
66 mysql => 'MySQL', #loc
67 Pg => 'PostgreSQL', #loc
68 SQLite => 'SQLite', #loc
69 Oracle => 'Oracle', #loc
74 Widget => '/Widgets/Form/String',
76 Description => 'Database host', #loc
78 DefaultLabel => "Keep 'localhost' if you're not sure. Leave blank to connect locally over a socket", #loc
79 Hints => "The domain name of your database server (like 'db.example.com').", #loc
83 Widget => '/Widgets/Form/Integer',
85 Description => 'Database port', #loc
88 'Leave empty to use the default value for your database', #loc
92 Widget => '/Widgets/Form/String',
94 Description => 'Database name', #loc
98 Widget => '/Widgets/Form/String',
101 Hints => "Leave this alone to use the default dba username for your database type", #loc
102 Description => 'DBA username', # loc
106 DatabaseAdminPassword => {
107 Widget => '/Widgets/Form/String',
109 Description => 'DBA password', #loc
110 DefaultLabel => "The DBA's database password",#loc
112 Hints => "You must provide the dba's password so we can create the RT database and user.",
116 Widget => '/Widgets/Form/String',
118 Description => 'Database username for RT', #loc
119 Hints => 'RT will connect to the database using this user. It will be created for you.', #loc
122 DatabasePassword => {
123 Widget => '/Widgets/Form/String',
125 Description => 'Database password for RT', #loc
127 Hints => 'The password RT should use to connect to the database.',
130 DatabaseRequireSSL => {
131 Widget => '/Widgets/Form/Boolean',
133 Description => 'Use SSL?', # loc
137 Widget => '/Widgets/Form/String',
139 Description => 'Site name', #loc
140 Hints => 'RT will use this string to uniquely identify your installation and looks for it in the subject of emails to decide what ticket a message applies to. We recommend that you set this to your internet domain. (ex: example.com)' #loc
143 MinimumPasswordLength => {
144 Widget => '/Widgets/Form/Integer',
146 Description => 'Minimum password length', #loc
150 Widget => '/Widgets/Form/String',
152 Description => 'Administrative password', #loc
153 Hints => 'RT will create a user called "root" and set this as their password', #loc
158 Widget => '/Widgets/Form/String',
160 Description => 'RT Administrator Email', #loc
161 Hints => "When RT can't handle an email message, where should it be forwarded?", #loc
165 Widget => '/Widgets/Form/String',
167 Description => 'Comment address', #loc
169 'the default addresses that will be listed in From: and Reply-To: headers of comment mail.' #loc
172 CorrespondAddress => {
173 Widget => '/Widgets/Form/String',
175 Description => 'Correspond address', #loc
177 'the default addresses that will be listed in From: and Reply-To: headers of correspondence mail.' #loc
181 Widget => '/Widgets/Form/String',
183 Hints => 'Where to find your sendmail binary.', #loc
184 Description => 'Path to sendmail', #loc
188 Widget => '/Widgets/Form/String',
190 Description => 'Domain name', #loc
191 Hints => "Don't include http://, just something like 'localhost', 'rt.example.com'", #loc
195 Widget => '/Widgets/Form/Integer',
197 Description => 'Web port', #loc
198 Hints => 'which port your web server will listen to, e.g. 8080', #loc
204 my $HAS_DATETIME_TZ = eval { require DateTime::TimeZone };
206 if ($HAS_DATETIME_TZ) {
208 Widget => '/Widgets/Form/Select',
210 Description => 'Timezone', #loc
213 $ret->{Values} = ['', DateTime::TimeZone->all_names];
215 my $has_datetime = eval { require DateTime };
216 if ( $has_datetime ) {
217 my $dt = DateTime->now;
218 for my $tz ( DateTime::TimeZone->all_names ) {
219 $dt->set_time_zone( $tz );
220 $ret->{ValuesLabel}{$tz} =
221 $tz . ' ' . $dt->strftime('%z');
224 $ret->{ValuesLabel}{''} = 'System Default'; #loc
233 Widget => '/Widgets/Form/String',
235 Description => 'Timezone', #loc
243 return $Meta{$type} if $type;
250 $type = $class if !ref $class && $class && $class ne 'RT::Installer';
252 return undef unless $type;
253 return $RT::Installer
254 && exists $RT::Installer->{InstallConfig}{$type}
255 ? $RT::Installer->{InstallConfig}{$type}
256 : scalar RT->Config->Get($type);
262 push @types, $class if !ref $class && $class && $class ne 'RT::Installer';
264 return { map { $_ => CurrentValue($_) } @types };
269 return File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' );
275 my $file = $class->ConfigFile;
281 open( my $fh, '<', $file ) or die $!;
283 $content =~ s/^\s*1;\s*$//m;
286 # make organization the same as rtname
287 $RT::Installer->{InstallConfig}{Organization} =
288 $RT::Installer->{InstallConfig}{rtname};
290 if ( open my $fh, '>', $file ) {
291 for ( keys %{ $RT::Installer->{InstallConfig} } ) {
293 # we don't want to store root's password in config.
294 next if $_ eq 'Password';
296 $RT::Installer->{InstallConfig}{$_} = ''
297 unless defined $RT::Installer->{InstallConfig}{$_};
299 # remove obsolete settings we'll add later
300 $content =~ s/^\s* Set \s* \( \s* \$$_ .*$//xm;
302 $content .= "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n";
308 return ( 1, "Successfully saved configuration to $file." );
311 return ( 0, "Cannot save configuration to $file: $!" );
316 RT::Installer - RT's Installer
321 my $meta = RT::Installer->Meta;
325 C<RT::Installer> class provides access to RT Installer Meta
329 RT::Base->_ImportOverlays();