Skip to content
This repository was archived by the owner on Nov 1, 2019. It is now read-only.

Commit 8136f5d

Browse files
authored
merge(): pull request #18 from navossoc/master
PostgreSQL support
2 parents e7a9f69 + 2245a99 commit 8136f5d

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ RUN echo "@community https://nl.alpinelinux.org/alpine/v3.7/community" >> /etc/a
2222
php7@community \
2323
php7-fpm@community \
2424
php7-imap@community \
25+
php7-pgsql@community \
2526
php7-mysqli@community \
2627
php7-session@community \
2728
php7-mbstring@community \

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PostfixAdmin is a web based interface used to manage mailboxes, virtual domains
1111
- Lightweight & secure image (no root process)
1212
- Based on Alpine Linux
1313
- Latest Postfixadmin version (3.1)
14-
- MySQL/Mariadb driver
14+
- MariaDB/PostgreSQL driver
1515
- With PHP7
1616

1717
### Built-time variables
@@ -30,10 +30,12 @@ PostfixAdmin is a web based interface used to manage mailboxes, virtual domains
3030
| -------- | ----------- | ---- | ------------- |
3131
| **UID** | postfixadmin user id | *optional* | 991
3232
| **GID** | postfixadmin group id | *optional* | 991
33-
| **DBHOST** | MariaDB instance ip/hostname | *optional* | mariadb
34-
| **DBUSER** | MariaDB database username | *optional* | postfix
35-
| **DBNAME** | MariaDB database name | *optional* | postfix
36-
| **DBPASS** | MariaDB database password or location of a file containing it | **required** | null
33+
| **DBDRIVER** | Database type: mysql, pgsql | optional | mysql
34+
| **DBHOST** | Database instance ip/hostname | *optional* | mariadb
35+
| **DBPORT** | Database instance port **DOES NOT WORK ON MYSQL FOR NOW** | optional | 3306
36+
| **DBUSER** | Database database username | *optional* | postfix
37+
| **DBNAME** | Database database name | *optional* | postfix
38+
| **DBPASS** | Database database password or location of a file containing it | **required** | null
3739
| **SMTPHOST** | SMTP server ip/hostname | *optional* | mailserver
3840
| **DOMAIN** | Mail domain | *optional* | `domainname` value
3941
| **ENCRYPTION** | Passwords encryption method | *optional* | `dovecot:SHA512-CRYPT`
@@ -56,7 +58,7 @@ postfixadmin:
5658
- DBPASS=xxxxxxx
5759
depends_on:
5860
- mailserver
59-
- mariadb
61+
- mariadb # postgres (adjust accordingly)
6062
```
6163
6264
### How to setup

bin/run.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
GID=${GID:-991}
44
UID=${UID:-991}
55
DOMAIN=${DOMAIN:-$(hostname --domain)}
6+
DBDRIVER=${DBDRIVER:-mysql}
67
DBHOST=${DBHOST:-mariadb}
8+
DBPORT=${DBPORT:-3306}
79
DBUSER=${DBUSER:-postfix}
810
DBNAME=${DBNAME:-postfix}
911
DBPASS=$([ -f "$DBPASS" ] && cat "$DBPASS" || echo "${DBPASS:-}")
@@ -15,7 +17,7 @@ PASSVAL_MIN_CHAR=${PASSVAL_MIN_CHAR:-3}
1517
PASSVAL_MIN_DIGIT=${PASSVAL_MIN_DIGIT:-2}
1618

1719
if [ -z "$DBPASS" ]; then
18-
echo "Mariadb database password must be set !"
20+
echo "MariaDB/PostgreSQL database password must be set !"
1921
exit 1
2022
fi
2123

@@ -25,16 +27,22 @@ mkdir -p /postfixadmin/templates_c
2527
# Set permissions
2628
chown -R $UID:$GID /postfixadmin
2729

30+
# MySQL/MariaDB should use mysqli driver
31+
case "$DBDRIVER" in
32+
mysql) DBDRIVER=mysqli;
33+
esac
34+
2835
# Local postfixadmin configuration file
2936
cat > /postfixadmin/config.local.php <<EOF
3037
<?php
3138
\$CONF['configured'] = true;
3239
33-
\$CONF['database_type'] = 'mysqli';
40+
\$CONF['database_type'] = '${DBDRIVER}';
3441
\$CONF['database_host'] = '${DBHOST}';
3542
\$CONF['database_user'] = '${DBUSER}';
3643
\$CONF['database_password'] = '${DBPASS}';
3744
\$CONF['database_name'] = '${DBNAME}';
45+
\$CONF['database_port'] = '${DBPORT}';
3846
3947
\$CONF['encrypt'] = '${ENCRYPTION}';
4048
\$CONF['dovecotpw'] = "/usr/bin/doveadm pw";

0 commit comments

Comments
 (0)