# Use the database access data created by dbconfig-common.

diff -Naur otrs-5.0.1.orig/Kernel/Config.pm.dist otrs-5.0.1/Kernel/Config.pm.dist
--- otrs-5.0.1.orig/Kernel/Config.pm.dist	2015-10-22 09:55:47.522492326 +0200
+++ otrs-5.0.1/Kernel/Config.pm.dist	2015-10-22 09:58:10.386055589 +0200
@@ -17,10 +17,24 @@
 
 package Kernel::Config;
 
-use strict;
+#use strict;
 use warnings;
 use utf8;
 
+BEGIN {
+	if (-f '/etc/otrs/database.pm') {
+		require '/etc/otrs/database.pm';
+		if ($dbtype eq 'pgsql') {
+			$dbport ||= '5432';
+			our $dsn = "DBI:Pg:dbname";
+		}
+		else {
+			$dbport ||= '3306';
+			our $dsn = "DBI:mysql:database";
+		}
+	}
+}
+
 sub Load {
     my $Self = shift;
 
@@ -29,20 +43,20 @@
     # ---------------------------------------------------- #
 
     # The database host
-    $Self->{DatabaseHost} = '127.0.0.1';
+    $Self->{DatabaseHost} = $dbserver || '127.0.0.1';
 
     # The database name
-    $Self->{Database} = 'otrs';
+    $Self->{Database} = $dbname || 'otrs';
 
     # The database user
-    $Self->{DatabaseUser} = 'otrs';
+    $Self->{DatabaseUser} = $dbuser || 'otrs';
 
     # The password of database user. You also can use bin/otrs.Console.pl Maint::Database::PasswordCrypt
     # for crypted passwords
-    $Self->{DatabasePw} = 'some-pass';
+    $Self->{DatabasePw} = $dbpass || 'some-pass';
 
     # The database DSN for MySQL ==> more: "perldoc DBD::mysql"
-    $Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";
+    $Self->{DatabaseDSN} = "$dsn=$Self->{Database};host=$Self->{DatabaseHost};port=$dbport;";
 
     # The database DSN for PostgreSQL ==> more: "perldoc DBD::Pg"
     # if you want to use a local socket connection
