+=head2 LoadConfig
+
+Load RT's config file. First, the site configuration file
+(C<RT_SiteConfig.pm>) is loaded, in order to establish overall site
+settings like hostname and name of RT instance. Then, the core
+configuration file (C<RT_Config.pm>) is loaded to set fallback values
+for all settings; it bases some values on settings from the site
+configuration file.
+
+In order for the core configuration to not override the site's
+settings, the function C<Set> is used; it only sets values if they
+have not been set already.
+
+=cut
+
+sub LoadConfig {
+ local *Set = sub { $_[0] = $_[1] unless defined $_[0] };
+
+ my $username = getpwuid($>);
+ my $group = getgrgid($();
+ my $message = <<EOF;
+
+RT couldn't load RT config file %s as:
+ user: $username
+ group: $group
+
+The file is owned by user %s and group %s.
+
+This usually means that the user/group your webserver is running
+as cannot read the file. Be careful not to make the permissions
+on this file too liberal, because it contains database passwords.
+You may need to put the webserver user in the appropriate group
+(%s) or change permissions be able to run succesfully.
+EOF
+
+
+ if ( -f "$SITE_CONFIG_FILE" ) {
+ eval { require $SITE_CONFIG_FILE };
+ if ($@) {
+ my ($fileuid,$filegid) = (stat($SITE_CONFIG_FILE))[4,5];
+ my $fileusername = getpwuid($fileuid);
+ my $filegroup = getgrgid($filegid);
+ my $errormessage = sprintf($message, $SITE_CONFIG_FILE,
+ $fileusername, $filegroup, $filegroup);
+ die ("$errormessage\n$@");
+ }
+ }
+ eval { require $CORE_CONFIG_FILE };
+ if ($@) {
+ my ($fileuid,$filegid) = (stat($SITE_CONFIG_FILE))[4,5];
+ my $fileusername = getpwuid($fileuid);
+ my $filegroup = getgrgid($filegid);
+ my $errormessage = sprintf($message, $SITE_CONFIG_FILE,
+ $fileusername, $filegroup, $filegroup);
+ die ("$errormessage '$CORE_CONFIG_FILE'\n$@")
+ }
+
+ # RT::Essentials mistakenly recommends that WebPath be set to '/'.
+ # If the user does that, do what they mean.
+ $RT::WebPath = '' if ($RT::WebPath eq '/');
+
+ $ENV{'TZ'} = $RT::Timezone if ($RT::Timezone);
+
+ RT::I18N->Init;
+}
+
+=head2 Init
+
+Conenct to the database, set up logging.