From 19f345c03d067b378abc3034478e15aa08b0aac9 Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Mon, 16 Dec 2019 10:57:22 +0100 Subject: [PATCH] Fix Redis Unix socket support Rebase and rewrite the @epma01 pull request, based on last Nextcloud Docker changes See: https://github.com/nextcloud/docker/pull/735 --- .config/redis.config.php | 8 ++++++-- docker-entrypoint.sh | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.config/redis.config.php b/.config/redis.config.php index 1967616093..9429c9013f 100644 --- a/.config/redis.config.php +++ b/.config/redis.config.php @@ -5,9 +5,13 @@ 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), - 'port' => getenv('REDIS_HOST_PORT') ?: 6379, 'password' => getenv('REDIS_HOST_PASSWORD'), ), ); -} + if (getenv('REDIS_HOST_PORT') !== false) { + $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); + } elseif (getenv('REDIS_HOST')[0] != '/') { + $CONFIG['redis']['port'] = 6379; + } +} diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 9514d881f0..0104bab6a9 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -25,8 +25,15 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "Configuring Redis as session handler" { echo 'session.save_handler = redis' + # check if redis host is an unix socket path + if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then + if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then + echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" + else + echo "session.save_path = \"unix://${REDIS_HOST}\"" + fi # check if redis password has been set - if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then + elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""