1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2015 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;
55 require UNIVERSAL::require;
58 Widget => '/Widgets/Form/Select',
60 Description => 'Database type', # loc
65 } qw/mysql Pg SQLite Oracle/
68 mysql => 'MySQL', #loc
69 Pg => 'PostgreSQL', #loc
70 SQLite => 'SQLite', #loc
71 Oracle => 'Oracle', #loc
76 Widget => '/Widgets/Form/String',
78 Description => 'Database host', #loc
80 DefaultLabel => "Keep 'localhost' if you're not sure. Leave blank to connect locally over a socket", #loc
81 Hints => "The domain name of your database server (like 'db.example.com').", #loc
85 Widget => '/Widgets/Form/Integer',
87 Description => 'Database port', #loc
90 'Leave empty to use the default value for your database', #loc
94 Widget => '/Widgets/Form/String',
96 Description => 'Database name', #loc
101 Widget => '/Widgets/Form/String',
104 Hints => "Leave this alone to use the default dba username for your database type", #loc
105 Description => 'DBA username', # loc
109 DatabaseAdminPassword => {
111 Widget => '/Widgets/Form/String',
113 Description => 'DBA password', #loc
114 DefaultLabel => "The DBA's database password",#loc
116 Hints => "You must provide the dba's password so we can create the RT database and user.",
120 Widget => '/Widgets/Form/String',
122 Description => 'Database username for RT', #loc
123 Hints => 'RT will connect to the database using this user. It will be created for you.', #loc
126 DatabasePassword => {
127 Widget => '/Widgets/Form/String',
129 Description => 'Database password for RT', #loc
131 Hints => 'The password RT should use to connect to the database.',
134 DatabaseRequireSSL => {
135 Widget => '/Widgets/Form/Boolean',
137 Description => 'Use SSL?', # loc
141 Widget => '/Widgets/Form/String',
143 Description => 'Site name', #loc
144 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
147 MinimumPasswordLength => {
148 Widget => '/Widgets/Form/Integer',
150 Description => 'Minimum password length', #loc
155 Widget => '/Widgets/Form/String',
157 Description => 'Administrative password', #loc
158 Hints => 'RT will create a user called "root" and set this as their password', #loc
163 Widget => '/Widgets/Form/String',
165 Description => 'RT Administrator Email', #loc
166 Hints => "When RT can't handle an email message, where should it be forwarded?", #loc
170 Widget => '/Widgets/Form/String',
172 Description => 'Comment address', #loc
174 'the default addresses that will be listed in From: and Reply-To: headers of comment mail.' #loc
177 CorrespondAddress => {
178 Widget => '/Widgets/Form/String',
180 Description => 'Correspond address', #loc
182 'the default addresses that will be listed in From: and Reply-To: headers of correspondence mail.' #loc
186 Widget => '/Widgets/Form/String',
188 Hints => 'Where to find your sendmail binary.', #loc
189 Description => 'Path to sendmail', #loc
193 Widget => '/Widgets/Form/Select',
195 Description => 'Timezone', #loc
198 $ret->{Values} = ['', DateTime::TimeZone->all_names];
200 my $dt = DateTime->now;
201 for my $tz ( DateTime::TimeZone->all_names ) {
202 $dt->set_time_zone( $tz );
203 $ret->{ValuesLabel}{$tz} =
204 $tz . ' ' . $dt->strftime('%z');
206 $ret->{ValuesLabel}{''} = 'System Default'; #loc
213 Widget => '/Widgets/Form/String',
215 Description => 'Domain name', #loc
216 Hints => "Don't include http://, just something like 'localhost', 'rt.example.com'", #loc
220 Widget => '/Widgets/Form/Integer',
222 Description => 'Web port', #loc
223 Hints => 'which port your web server will listen to, e.g. 8080', #loc
232 return $Meta{$type} if $type;
239 $type = $class if !ref $class && $class && $class ne 'RT::Installer';
241 return undef unless $type;
242 return $RT::Installer
243 && exists $RT::Installer->{InstallConfig}{$type}
244 ? $RT::Installer->{InstallConfig}{$type}
245 : scalar RT->Config->Get($type);
251 push @types, $class if !ref $class && $class && $class ne 'RT::Installer';
253 return { map { $_ => CurrentValue($_) } @types };
258 return $ENV{RT_SITE_CONFIG} || File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' );
264 my $file = $class->ConfigFile;
270 open( my $fh, '<', $file ) or die $!;
272 $content =~ s/^\s*1;\s*$//m;
275 # make organization the same as rtname
276 $RT::Installer->{InstallConfig}{Organization} =
277 $RT::Installer->{InstallConfig}{rtname};
279 if ( open my $fh, '>', $file ) {
280 for ( sort keys %{ $RT::Installer->{InstallConfig} } ) {
282 # we don't want to store root's password in config.
283 next if $class->Meta($_) and $class->Meta($_)->{SkipWrite};
285 $RT::Installer->{InstallConfig}{$_} = ''
286 unless defined $RT::Installer->{InstallConfig}{$_};
288 # remove obsolete settings we'll add later
289 $content =~ s/^\s* Set \s* \( \s* \$$_ .*$//xm;
291 $content .= "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n";
297 return ( 1, "Successfully saved configuration to $file." );
300 return ( 0, "Cannot save configuration to $file: $!" );
305 RT::Installer - RT's Installer
310 my $meta = RT::Installer->Meta;
314 C<RT::Installer> class provides access to RT Installer Meta
318 RT::Base->_ImportOverlays();