From 9b10e938cf5fd46dcafe25ed1c16237a3ebe4156 Mon Sep 17 00:00:00 2001 From: Michael Wyraz Date: Tue, 19 Nov 2019 12:22:09 +0100 Subject: [PATCH] Make roundcube db configurable --- webmails/roundcube/config.inc.php | 2 +- webmails/roundcube/start.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/webmails/roundcube/config.inc.php b/webmails/roundcube/config.inc.php index eff8ffa2..09a743d7 100644 --- a/webmails/roundcube/config.inc.php +++ b/webmails/roundcube/config.inc.php @@ -3,7 +3,7 @@ $config = array(); // Generals -$config['db_dsnw'] = 'sqlite:////data/roundcube.db'; +$config['db_dsnw'] = getenv('DB_DSNW');; $config['temp_dir'] = '/tmp/'; $config['des_key'] = getenv('SECRET_KEY'); $config['cipher_method'] = 'AES-256-CBC'; diff --git a/webmails/roundcube/start.py b/webmails/roundcube/start.py index 55832dd0..7851921a 100755 --- a/webmails/roundcube/start.py +++ b/webmails/roundcube/start.py @@ -9,6 +9,29 @@ log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576)) +db_flavor=os.environ.get("ROUNDCUBE_DB_FLAVOR","sqlite") +if db_flavor=="sqlite": + os.environ["DB_DSNW"]="sqlite:////data/roundcube.db" +elif db_flavor=="mysql": + os.environ["DB_DSNW"]="mysql://%s:%s@%s/%s" % ( + os.environ.get("ROUNDCUBE_DB_USER","roundcube"), + os.environ.get("ROUNDCUBE_DB_PW"), + os.environ.get("ROUNDCUBE_DB_HOST","database"), + os.environ.get("ROUNDCUBE_DB_NAME","roundcube") + ) +elif db_flavor=="postgresql": + os.environ["DB_DSNW"]="pgsql://%s:%s@%s/%s" % ( + os.environ.get("ROUNDCUBE_DB_USER","roundcube"), + os.environ.get("ROUNDCUBE_DB_PW"), + os.environ.get("ROUNDCUBE_DB_HOST","database"), + os.environ.get("ROUNDCUBE_DB_NAME","roundcube") + ) +else: + print("Unknown ROUNDCUBE_DB_FLAVOR: %s",db_flavor) + exit(1) + + + conf.jinja("/php.ini", os.environ, "/usr/local/etc/php/conf.d/roundcube.ini") # Fix some permissions