1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2012 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
100 Widget => '/Widgets/Form/String',
103 Hints => "Leave this alone to use the default dba username for your database type", #loc
104 Description => 'DBA username', # loc
108 DatabaseAdminPassword => {
109 Widget => '/Widgets/Form/String',
111 Description => 'DBA password', #loc
112 DefaultLabel => "The DBA's database password",#loc
114 Hints => "You must provide the dba's password so we can create the RT database and user.",
118 Widget => '/Widgets/Form/String',
120 Description => 'Database username for RT', #loc
121 Hints => 'RT will connect to the database using this user. It will be created for you.', #loc
124 DatabasePassword => {
125 Widget => '/Widgets/Form/String',
127 Description => 'Database password for RT', #loc
129 Hints => 'The password RT should use to connect to the database.',
132 DatabaseRequireSSL => {
133 Widget => '/Widgets/Form/Boolean',
135 Description => 'Use SSL?', # loc
139 Widget => '/Widgets/Form/String',
141 Description => 'Site name', #loc
142 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
145 MinimumPasswordLength => {
146 Widget => '/Widgets/Form/Integer',
148 Description => 'Minimum password length', #loc
152 Widget => '/Widgets/Form/String',
154 Description => 'Administrative password', #loc
155 Hints => 'RT will create a user called "root" and set this as their password', #loc
160 Widget => '/Widgets/Form/String',
162 Description => 'RT Administrator Email', #loc
163 Hints => "When RT can't handle an email message, where should it be forwarded?", #loc
167 Widget => '/Widgets/Form/String',
169 Description => 'Comment address', #loc
171 'the default addresses that will be listed in From: and Reply-To: headers of comment mail.' #loc
174 CorrespondAddress => {
175 Widget => '/Widgets/Form/String',
177 Description => 'Correspond address', #loc
179 'the default addresses that will be listed in From: and Reply-To: headers of correspondence mail.' #loc
183 Widget => '/Widgets/Form/String',
185 Hints => 'Where to find your sendmail binary.', #loc
186 Description => 'Path to sendmail', #loc
190 Widget => '/Widgets/Form/Select',
192 Description => 'Timezone', #loc
195 $ret->{Values} = ['', DateTime::TimeZone->all_names];
197 my $dt = DateTime->now;
198 for my $tz ( DateTime::TimeZone->all_names ) {
199 $dt->set_time_zone( $tz );
200 $ret->{ValuesLabel}{$tz} =
201 $tz . ' ' . $dt->strftime('%z');
203 $ret->{ValuesLabel}{''} = 'System Default'; #loc
210 Widget => '/Widgets/Form/String',
212 Description => 'Domain name', #loc
213 Hints => "Don't include http://, just something like 'localhost', 'rt.example.com'", #loc
217 Widget => '/Widgets/Form/Integer',
219 Description => 'Web port', #loc
220 Hints => 'which port your web server will listen to, e.g. 8080', #loc
229 return $Meta{$type} if $type;
236 $type = $class if !ref $class && $class && $class ne 'RT::Installer';
238 return undef unless $type;
239 return $RT::Installer
240 && exists $RT::Installer->{InstallConfig}{$type}
241 ? $RT::Installer->{InstallConfig}{$type}
242 : scalar RT->Config->Get($type);
248 push @types, $class if !ref $class && $class && $class ne 'RT::Installer';
250 return { map { $_ => CurrentValue($_) } @types };
255 return $ENV{RT_SITE_CONFIG} || File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' );
261 my $file = $class->ConfigFile;
267 open( my $fh, '<', $file ) or die $!;
269 $content =~ s/^\s*1;\s*$//m;
272 # make organization the same as rtname
273 $RT::Installer->{InstallConfig}{Organization} =
274 $RT::Installer->{InstallConfig}{rtname};
276 if ( open my $fh, '>', $file ) {
277 for ( keys %{ $RT::Installer->{InstallConfig} } ) {
279 # we don't want to store root's password in config.
280 next if $_ eq 'Password';
282 $RT::Installer->{InstallConfig}{$_} = ''
283 unless defined $RT::Installer->{InstallConfig}{$_};
285 # remove obsolete settings we'll add later
286 $content =~ s/^\s* Set \s* \( \s* \$$_ .*$//xm;
288 $content .= "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n";
294 return ( 1, "Successfully saved configuration to $file." );
297 return ( 0, "Cannot save configuration to $file: $!" );
302 RT::Installer - RT's Installer
307 my $meta = RT::Installer->Meta;
311 C<RT::Installer> class provides access to RT Installer Meta
315 RT::Base->_ImportOverlays();