@@ -91,37 +91,37 @@ get_enabled_apps() {
9191
9292# Write PHP session config for Redis to /usr/local/etc/php/conf.d/redis-session.ini
9393configure_redis_session () {
94+ local redis_save_path
95+ local redis_auth=' '
96+
9497 echo " => Configuring PHP session handler..."
98+
9599 if [ -z " ${REDIS_HOST:- } " ]; then
96100 echo " ==> Using default PHP session handler"
97101 return 0
98102 fi
99103
104+ file_env REDIS_HOST_PASSWORD
105+
106+ case " $REDIS_HOST " in
107+ /* )
108+ redis_save_path=" unix://${REDIS_HOST} "
109+ ;;
110+ * )
111+ redis_save_path=" tcp://${REDIS_HOST} :${REDIS_HOST_PORT:= 6379} "
112+ ;;
113+ esac
114+
115+ if [ -n " ${REDIS_HOST_PASSWORD+x} " ] && [ -n " ${REDIS_HOST_USER+x} " ]; then
116+ redis_auth=" ?auth[]=${REDIS_HOST_USER} &auth[]=${REDIS_HOST_PASSWORD} "
117+ elif [ -n " ${REDIS_HOST_PASSWORD+x} " ]; then
118+ redis_auth=" ?auth=${REDIS_HOST_PASSWORD} "
119+ fi
120+
100121 echo " ==> Using Redis as PHP session handler..."
101122 {
102- file_env REDIS_HOST_PASSWORD
103123 echo ' session.save_handler = redis'
104- # check if redis host is a unix socket path
105- if [ " $( echo " $REDIS_HOST " | cut -c1-1) " = " /" ]; then
106- if [ -n " ${REDIS_HOST_PASSWORD+x} " ]; then
107- if [ -n " ${REDIS_HOST_USER+x} " ]; then
108- echo " session.save_path = \" unix://${REDIS_HOST} ?auth[]=${REDIS_HOST_USER} &auth[]=${REDIS_HOST_PASSWORD} \" "
109- else
110- echo " session.save_path = \" unix://${REDIS_HOST} ?auth=${REDIS_HOST_PASSWORD} \" "
111- fi
112- else
113- echo " session.save_path = \" unix://${REDIS_HOST} \" "
114- fi
115- # check if redis password has been set
116- elif [ -n " ${REDIS_HOST_PASSWORD+x} " ]; then
117- if [ -n " ${REDIS_HOST_USER+x} " ]; then
118- echo " session.save_path = \" tcp://${REDIS_HOST} :${REDIS_HOST_PORT:= 6379} ?auth[]=${REDIS_HOST_USER} &auth[]=${REDIS_HOST_PASSWORD} \" "
119- else
120- echo " session.save_path = \" tcp://${REDIS_HOST} :${REDIS_HOST_PORT:= 6379} ?auth=${REDIS_HOST_PASSWORD} \" "
121- fi
122- else
123- echo " session.save_path = \" tcp://${REDIS_HOST} :${REDIS_HOST_PORT:= 6379} \" "
124- fi
124+ echo " session.save_path = \" ${redis_save_path}${redis_auth} \" "
125125 echo " redis.session.locking_enabled = 1"
126126 echo " redis.session.lock_retries = -1"
127127 # redis.session.lock_wait_time is specified in microseconds.
0 commit comments