HEX
Server: Apache/2.4.67 (Debian)
System: Linux wordpress-f784ddd76-2rt5j 6.1.175-219.357.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 16 03:47:47 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //init-scripts/enable_redis.sh
#!/usr/bin/env bash

if [ -z $REDIS_ENABLED ]; then
    export REDIS_ENABLED='no'
fi

cd /var/www/html

while(true); do
    if nc -z localhost 80; then
        echo "Server Started .. proceeding"
        break
    else
        echo "Server not yet started ... waiting ..."
        sleep 5s
    fi
done


if [ $REDIS_ENABLED == 'yes' ]; then
    echo "Waiting until wordpress is available before trying to enable redis cache";
    while ! nc -z localhost 80; do
    echo "Waiting until wordpress is available before trying to enable redis cache";
    sleep 1;
    done;

    echo "Checking if redis-cache plugin is installed and active."


    if [ -f /var/www/html/wp-content/object-cache.php ]; then
      echo "redis-cache plugin already enabled."
    else
      wp redis enable --allow-root;
      if [ $? -ne 0 ]; then
        echo "Error enabling Redis cache ... TERMINATING!"
        exit 1
      fi
      echo "Redis Enabled successfully"
    fi
else
    echo "Disabling Redis"
    if [ -f /var/www/html/wp-content/object-cache.php ]; then
      wp redis disable --allow-root 
      if [ $? -ne 0 ]; then
        echo "Error enabling Redis cache ... TERMINATING!"
        exit 1
      fi
    else
      echo "Redis is already disabled"
    fi
    
fi