Skip to content

Commit 32916c0

Browse files
committed
added support for redis username/password to dockers
1 parent b197818 commit 32916c0

File tree

4 files changed

+92
-8
lines changed

4 files changed

+92
-8
lines changed

docker/openemr/7.0.0/openemr.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,30 @@ fi
196196

197197
if [ "$REDIS_SERVER" != "" ] &&
198198
[ ! -f /etc/php-redis-configured ]; then
199-
# Variable for $REDIS_SERVER is usually going to be something like 'redis'
199+
200+
# Support the following redis auth:
201+
# No username and No password set (using redis default user with nopass set)
202+
# Both username and password set (using the redis user and pertinent password)
203+
# Only password set (using redis default user and pertinent password)
204+
# NOTE that only username set is not supported (in this case will ignore the username
205+
# and use no username and no password set mode)
206+
REDIS_PATH="tcp://$REDIS_SERVER:6379"
207+
if [ "$REDIS_USERNAME" != "" ] &&
208+
[ "$REDIS_PASSWORD" != "" ]; then
209+
echo "redis setup with username and password"
210+
REDIS_PATH="$REDIS_PATH?auth[user]=$REDIS_USERNAME\&auth[pass]=$REDIS_PASSWORD"
211+
elif [ "$REDIS_PASSWORD" != "" ]; then
212+
echo "redis setup with password"
213+
# only a password, thus using the default user which redis has set a password for
214+
REDIS_PATH="$REDIS_PATH?auth[pass]=$REDIS_PASSWORD"
215+
else
216+
# no user or password, thus using the default user which is set to nopass in redis
217+
# so just keeping original REDIS_PATH: REDIS_PATH="$REDIS_PATH"
218+
echo "redis setup"
219+
fi
220+
200221
sed -i "[email protected]_handler = [email protected]_handler = redis@" /etc/php8/php.ini
201-
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"tcp://$REDIS_SERVER:6379\"@" /etc/php8/php.ini
222+
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"$REDIS_PATH\"@" /etc/php8/php.ini
202223
# Ensure only configure this one time
203224
touch /etc/php-redis-configured
204225
fi

docker/openemr/flex-3.15-8/openemr.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,30 @@ rm -f /var/www/localhost/htdocs/auto_configure.php
356356

357357
if [ "$REDIS_SERVER" != "" ] &&
358358
[ ! -f /etc/php-redis-configured ]; then
359-
# Variable for $REDIS_SERVER is usually going to be something like 'redis'
359+
360+
# Support the following redis auth:
361+
# No username and No password set (using redis default user with nopass set)
362+
# Both username and password set (using the redis user and pertinent password)
363+
# Only password set (using redis default user and pertinent password)
364+
# NOTE that only username set is not supported (in this case will ignore the username
365+
# and use no username and no password set mode)
366+
REDIS_PATH="tcp://$REDIS_SERVER:6379"
367+
if [ "$REDIS_USERNAME" != "" ] &&
368+
[ "$REDIS_PASSWORD" != "" ]; then
369+
echo "redis setup with username and password"
370+
REDIS_PATH="$REDIS_PATH?auth[user]=$REDIS_USERNAME\&auth[pass]=$REDIS_PASSWORD"
371+
elif [ "$REDIS_PASSWORD" != "" ]; then
372+
echo "redis setup with password"
373+
# only a password, thus using the default user which redis has set a password for
374+
REDIS_PATH="$REDIS_PATH?auth[pass]=$REDIS_PASSWORD"
375+
else
376+
# no user or password, thus using the default user which is set to nopass in redis
377+
# so just keeping original REDIS_PATH: REDIS_PATH="$REDIS_PATH"
378+
echo "redis setup"
379+
fi
380+
360381
sed -i "[email protected]_handler = [email protected]_handler = redis@" /etc/php8/php.ini
361-
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"tcp://$REDIS_SERVER:6379\"@" /etc/php8/php.ini
382+
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"$REDIS_PATH\"@" /etc/php8/php.ini
362383
# Ensure only configure this one time
363384
touch /etc/php-redis-configured
364385
fi

docker/openemr/flex-3.17/openemr.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,30 @@ rm -f /var/www/localhost/htdocs/auto_configure.php
356356

357357
if [ "$REDIS_SERVER" != "" ] &&
358358
[ ! -f /etc/php-redis-configured ]; then
359-
# Variable for $REDIS_SERVER is usually going to be something like 'redis'
359+
360+
# Support the following redis auth:
361+
# No username and No password set (using redis default user with nopass set)
362+
# Both username and password set (using the redis user and pertinent password)
363+
# Only password set (using redis default user and pertinent password)
364+
# NOTE that only username set is not supported (in this case will ignore the username
365+
# and use no username and no password set mode)
366+
REDIS_PATH="tcp://$REDIS_SERVER:6379"
367+
if [ "$REDIS_USERNAME" != "" ] &&
368+
[ "$REDIS_PASSWORD" != "" ]; then
369+
echo "redis setup with username and password"
370+
REDIS_PATH="$REDIS_PATH?auth[user]=$REDIS_USERNAME\&auth[pass]=$REDIS_PASSWORD"
371+
elif [ "$REDIS_PASSWORD" != "" ]; then
372+
echo "redis setup with password"
373+
# only a password, thus using the default user which redis has set a password for
374+
REDIS_PATH="$REDIS_PATH?auth[pass]=$REDIS_PASSWORD"
375+
else
376+
# no user or password, thus using the default user which is set to nopass in redis
377+
# so just keeping original REDIS_PATH: REDIS_PATH="$REDIS_PATH"
378+
echo "redis setup"
379+
fi
380+
360381
sed -i "[email protected]_handler = [email protected]_handler = redis@" /etc/php81/php.ini
361-
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"tcp://$REDIS_SERVER:6379\"@" /etc/php81/php.ini
382+
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"$REDIS_PATH\"@" /etc/php81/php.ini
362383
# Ensure only configure this one time
363384
touch /etc/php-redis-configured
364385
fi

docker/openemr/flex-edge/openemr.sh

+23-2
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,30 @@ rm -f /var/www/localhost/htdocs/auto_configure.php
356356

357357
if [ "$REDIS_SERVER" != "" ] &&
358358
[ ! -f /etc/php-redis-configured ]; then
359-
# Variable for $REDIS_SERVER is usually going to be something like 'redis'
359+
360+
# Support the following redis auth:
361+
# No username and No password set (using redis default user with nopass set)
362+
# Both username and password set (using the redis user and pertinent password)
363+
# Only password set (using redis default user and pertinent password)
364+
# NOTE that only username set is not supported (in this case will ignore the username
365+
# and use no username and no password set mode)
366+
REDIS_PATH="tcp://$REDIS_SERVER:6379"
367+
if [ "$REDIS_USERNAME" != "" ] &&
368+
[ "$REDIS_PASSWORD" != "" ]; then
369+
echo "redis setup with username and password"
370+
REDIS_PATH="$REDIS_PATH?auth[user]=$REDIS_USERNAME\&auth[pass]=$REDIS_PASSWORD"
371+
elif [ "$REDIS_PASSWORD" != "" ]; then
372+
echo "redis setup with password"
373+
# only a password, thus using the default user which redis has set a password for
374+
REDIS_PATH="$REDIS_PATH?auth[pass]=$REDIS_PASSWORD"
375+
else
376+
# no user or password, thus using the default user which is set to nopass in redis
377+
# so just keeping original REDIS_PATH: REDIS_PATH="$REDIS_PATH"
378+
echo "redis setup"
379+
fi
380+
360381
sed -i "[email protected]_handler = [email protected]_handler = redis@" /etc/php82/php.ini
361-
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"tcp://$REDIS_SERVER:6379\"@" /etc/php82/php.ini
382+
sed -i "s@;session.save_path = \"/tmp\"@session.save_path = \"$REDIS_PATH\"@" /etc/php82/php.ini
362383
# Ensure only configure this one time
363384
touch /etc/php-redis-configured
364385
fi

0 commit comments

Comments
 (0)