X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FInstaller.pm;h=372c33d327142ccd8ba00ade0043faccb58fa7e7;hp=2cc5ba93141657d746a9f3ce0c44dfacf8aa7e74;hb=de9d037528895f7151a9aead6724ce2df95f9586;hpb=63a268637b2d51a8766412617724b9436439deb6 diff --git a/rt/lib/RT/Installer.pm b/rt/lib/RT/Installer.pm index 2cc5ba931..372c33d32 100644 --- a/rt/lib/RT/Installer.pm +++ b/rt/lib/RT/Installer.pm @@ -1,40 +1,40 @@ # BEGIN BPS TAGGED BLOCK {{{ -# +# # COPYRIGHT: -# -# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC -# -# +# +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC +# +# # (Except where explicitly superseded by other copyright notices) -# -# +# +# # LICENSE: -# +# # This work is made available to you under the terms of Version 2 of # the GNU General Public License. A copy of that license should have # been provided with this software, but in any event can be snarfed # from www.gnu.org. -# +# # This work is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 or visit their web page on the internet at # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. -# -# +# +# # CONTRIBUTION SUBMISSION POLICY: -# +# # (The following paragraph is not intended to limit the rights granted # to you to modify and distribute this software under the terms of # the GNU General Public License and is only of importance to you if # you choose to contribute your changes and enhancements to the # community by submitting them to Best Practical Solutions, LLC.) -# +# # By intentionally submitting any modifications, corrections or # derivatives to this work, or any other work intended for use with # Request Tracker, to Best Practical Solutions, LLC, you confirm that @@ -43,13 +43,15 @@ # royalty-free, perpetual, license to use, copy, create derivative # works based on those contributions, and sublicense and distribute # those contributions and any derivatives thereof. -# +# # END BPS TAGGED BLOCK }}} package RT::Installer; use strict; use warnings; +use DateTime; + require UNIVERSAL::require; my %Meta = ( DatabaseType => { @@ -95,6 +97,7 @@ my %Meta = ( }, }, DatabaseAdmin => { + SkipWrite => 1, Widget => '/Widgets/Form/String', WidgetArguments => { Default => 1, @@ -104,6 +107,7 @@ my %Meta = ( }, }, DatabaseAdminPassword => { + SkipWrite => 1, Widget => '/Widgets/Form/String', WidgetArguments => { Description => 'DBA password', #loc @@ -127,12 +131,6 @@ my %Meta = ( Hints => 'The password RT should use to connect to the database.', }, }, - DatabaseRequireSSL => { - Widget => '/Widgets/Form/Boolean', - WidgetArguments => { - Description => 'Use SSL?', # loc - }, - }, rtname => { Widget => '/Widgets/Form/String', WidgetArguments => { @@ -147,6 +145,7 @@ my %Meta = ( }, }, Password => { + SkipWrite => 1, Widget => '/Widgets/Form/String', WidgetArguments => { Description => 'Administrative password', #loc @@ -184,27 +183,7 @@ my %Meta = ( Description => 'Path to sendmail', #loc }, }, - WebDomain => { - Widget => '/Widgets/Form/String', - WidgetArguments => { - Description => 'Domain name', #loc - Hints => "Don't include http://, just something like 'localhost', 'rt.example.com'", #loc - }, - }, - WebPort => { - Widget => '/Widgets/Form/Integer', - WidgetArguments => { - Description => 'Web port', #loc - Hints => 'which port your web server will listen to, e.g. 8080', #loc - }, - }, - -); - -my $HAS_DATETIME_TZ = eval { require DateTime::TimeZone }; - -if ($HAS_DATETIME_TZ) { - $Meta{Timezone} = { + Timezone => { Widget => '/Widgets/Form/Select', WidgetArguments => { Description => 'Timezone', #loc @@ -212,30 +191,34 @@ if ($HAS_DATETIME_TZ) { my $ret; $ret->{Values} = ['', DateTime::TimeZone->all_names]; - my $has_datetime = eval { require DateTime }; - if ( $has_datetime ) { - my $dt = DateTime->now; - for my $tz ( DateTime::TimeZone->all_names ) { - $dt->set_time_zone( $tz ); - $ret->{ValuesLabel}{$tz} = - $tz . ' ' . $dt->strftime('%z'); - } + my $dt = DateTime->now; + for my $tz ( DateTime::TimeZone->all_names ) { + $dt->set_time_zone( $tz ); + $ret->{ValuesLabel}{$tz} = + $tz . ' ' . $dt->strftime('%z'); } $ret->{ValuesLabel}{''} = 'System Default'; #loc return $ret; }, }, - }; -} -else { - $Meta{Timezone} = { + }, + WebDomain => { Widget => '/Widgets/Form/String', WidgetArguments => { - Description => 'Timezone', #loc + Description => 'Domain name', #loc + Hints => "Don't include http://, just something like 'localhost', 'rt.example.com'", #loc }, - }; -} + }, + WebPort => { + Widget => '/Widgets/Form/Integer', + WidgetArguments => { + Description => 'Web port', #loc + Hints => 'which port your web server will listen to, e.g. 8080', #loc + }, + }, + +); sub Meta { my $class = shift; @@ -266,7 +249,7 @@ sub CurrentValues { sub ConfigFile { require File::Spec; - return File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' ); + return $ENV{RT_SITE_CONFIG} || File::Spec->catfile( $RT::EtcPath, 'RT_SiteConfig.pm' ); } sub SaveConfig { @@ -278,7 +261,7 @@ sub SaveConfig { { local $/; - open my $fh, '<', $file or die $!; + open( my $fh, '<', $file ) or die $!; $content = <$fh>; $content =~ s/^\s*1;\s*$//m; } @@ -288,10 +271,10 @@ sub SaveConfig { $RT::Installer->{InstallConfig}{rtname}; if ( open my $fh, '>', $file ) { - for ( keys %{ $RT::Installer->{InstallConfig} } ) { + for ( sort keys %{ $RT::Installer->{InstallConfig} } ) { # we don't want to store root's password in config. - next if $_ eq 'Password'; + next if $class->Meta($_) and $class->Meta($_)->{SkipWrite}; $RT::Installer->{InstallConfig}{$_} = '' unless defined $RT::Installer->{InstallConfig}{$_}; @@ -299,7 +282,9 @@ sub SaveConfig { # remove obsolete settings we'll add later $content =~ s/^\s* Set \s* \( \s* \$$_ .*$//xm; - $content .= "Set( \$$_, '$RT::Installer->{InstallConfig}{$_}' );\n"; + my $value = $RT::Installer->{InstallConfig}{$_}; + $value =~ s/(['\\])/\\$1/g; + $content .= "Set( \$$_, '$value' );\n"; } $content .= "1;\n"; print $fh $content; @@ -326,15 +311,7 @@ C class provides access to RT Installer Meta =cut -eval "require RT::Installer_Vendor"; -if ($@ && $@ !~ qr{^Can't locate RT/Installer_Vendor.pm}) { - die $@; -}; - -eval "require RT::Installer_Local"; -if ($@ && $@ !~ qr{^Can't locate RT/Installer_Local.pm}) { - die $@; -}; +RT::Base->_ImportOverlays(); 1;