mirror of
https://github.com/nextcloud/docker.git
synced 2026-04-09 15:51:17 +02:00
refactor(redis): reduce nesting/improve code clarity
Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
parent
725e8f2f11
commit
6f8df59432
@ -85,37 +85,37 @@ file_env() {
|
||||
|
||||
# Write PHP session config for Redis to /usr/local/etc/php/conf.d/redis-session.ini
|
||||
configure_redis_session() {
|
||||
local redis_save_path
|
||||
local redis_auth=''
|
||||
|
||||
echo "=> Configuring PHP session handler..."
|
||||
|
||||
if [ -z "${REDIS_HOST:-}" ]; then
|
||||
echo "==> Using default PHP session handler"
|
||||
return 0
|
||||
fi
|
||||
|
||||
file_env REDIS_HOST_PASSWORD
|
||||
|
||||
case "$REDIS_HOST" in
|
||||
/*)
|
||||
redis_save_path="unix://${REDIS_HOST}"
|
||||
;;
|
||||
*)
|
||||
redis_save_path="tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "${REDIS_HOST_PASSWORD+x}" ] && [ -n "${REDIS_HOST_USER+x}" ]; then
|
||||
redis_auth="?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}"
|
||||
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
|
||||
redis_auth="?auth=${REDIS_HOST_PASSWORD}"
|
||||
fi
|
||||
|
||||
echo "==> Using Redis as PHP session handler..."
|
||||
{
|
||||
file_env REDIS_HOST_PASSWORD
|
||||
echo 'session.save_handler = redis'
|
||||
# check if redis host is a unix socket path
|
||||
if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then
|
||||
if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
|
||||
if [ -n "${REDIS_HOST_USER+x}" ]; then
|
||||
echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
|
||||
else
|
||||
echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\""
|
||||
fi
|
||||
else
|
||||
echo "session.save_path = \"unix://${REDIS_HOST}\""
|
||||
fi
|
||||
# check if redis password has been set
|
||||
elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then
|
||||
if [ -n "${REDIS_HOST_USER+x}" ]; then
|
||||
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\""
|
||||
else
|
||||
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\""
|
||||
fi
|
||||
else
|
||||
echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\""
|
||||
fi
|
||||
echo "session.save_path = \"${redis_save_path}${redis_auth}\""
|
||||
echo "redis.session.locking_enabled = 1"
|
||||
echo "redis.session.lock_retries = -1"
|
||||
# redis.session.lock_wait_time is specified in microseconds.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user