X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FInstaller.pm;h=372c33d327142ccd8ba00ade0043faccb58fa7e7;hp=0779fa5999a26621062af6e670bec34fe433a1a8;hb=de9d037528895f7151a9aead6724ce2df95f9586;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c diff --git a/rt/lib/RT/Installer.pm b/rt/lib/RT/Installer.pm index 0779fa599..372c33d32 100644 --- a/rt/lib/RT/Installer.pm +++ b/rt/lib/RT/Installer.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -50,6 +50,8 @@ 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;