fix: support database port
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Markus Pesch 2021-09-11 13:43:29 +02:00
parent 68e4b27300
commit 8d48d4d458
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 7 additions and 3 deletions

View File

@ -25,6 +25,7 @@ $ docker run \
--rm \
--env DATABASE_TYPE: Pg \
--env DATABASE_HOST: postgres \
--env DATABASE_PORT: 5432 \
--env DATABASE_NAME: postgres \
--env DATABASE_USER: fetchmail \
--env DATABASE_PASSWORD: MySecretPassword \
@ -39,6 +40,7 @@ $ docker run \
--rm \
--env DATABASE_TYPE: my \
--env DATABASE_HOST: root \
--env DATABASE_PORT: 3306 \
--env DATABASE_NAME: mysql \
--env DATABASE_USER: fetchmail \
--env DATABASE_PASSWORD: MySecretPassword \
@ -62,6 +64,7 @@ services:
environment:
- DATABASE_TYPE=${DATABASE_TYPE}
- DATABASE_HOST=${DATABASE_HOST}
- DATABASE_HOST=${DATABASE_PORT}
- DATABASE_NAME=${DATABASE_NAME}
- DATABASE_USER=${DATABASE_USER}
- DATABASE_PASSWORD=${DATABASE_PASSWORD}

View File

@ -15,10 +15,11 @@ use LockFile::Simple qw(lock trylock unlock);
# database backend - uncomment one of these
our $db_type=$ENV{'DATABASE_TYPE'};
our $db_host=$ENV{'DATABASE_HOST'};
our $db_name=$ENV{'DATABASE_NAME'};
our $db_username=$ENV{'DATABASE_USER'};
our $db_password=$ENV{'DATABASE_PASSWORD'};
our $db_host=$ENV{'DATABASE_HOST'};
our $db_port=$ENV{'DATABASE_PORT'};
our $db_name=$ENV{'DATABASE_NAME'};
# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/fetchmail.conf
# just use perl syntax there to fill the variables listed above (without the "our" keyword). Example:
@ -60,7 +61,7 @@ if (-e $configfile) {
}
if($db_type eq "Pg" || $db_type eq "mysql") {
$dsn = "DBI:$db_type:database=$db_name;host=$db_host";
$dsn = "DBI:$db_type:database=$db_name;host=$db_host;port=$db_port";
} else {
log_and_die "unsupported db_type $db_type";
}