-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
Copy pathstart-redis-with-password.sh
executable file
·30 lines (27 loc) · 1.45 KB
/
start-redis-with-password.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Default values for environment variables
REDIS_PORT="${ARGOCD_E2E_REDIS_PORT:-6379}"
REDIS_IMAGE_TAG=$(grep 'image: redis' manifests/base/redis/argocd-redis-deployment.yaml | cut -d':' -f3)
if [ "$ARGOCD_REDIS_LOCAL" = 'true' ]; then
if ! command -v redis-server &>/dev/null; then
echo "Redis server is not installed locally. Please install Redis or set ARGOCD_REDIS_LOCAL to false."
exit 1
fi
# Start local Redis server with password if defined
if [ -z "$REDIS_PASSWORD" ]; then
echo "Starting local Redis server without password."
redis-server --save '' --appendonly no --port "$REDIS_PORT"
else
echo "Starting local Redis server with password."
redis-server --save '' --appendonly no --port "$REDIS_PORT" --requirepass "$REDIS_PASSWORD"
fi
else
# Run Redis in a Docker container with password if defined
if [ -z "$REDIS_PASSWORD" ]; then
echo "Starting Docker container without password."
docker run --rm --name argocd-redis -i -p "$REDIS_PORT:$REDIS_PORT" docker.io/library/redis:"$REDIS_IMAGE_TAG" --save '' --appendonly no --port "$REDIS_PORT"
else
echo "Starting Docker container with password."
docker run --rm --name argocd-redis -i -p "$REDIS_PORT:$REDIS_PORT" -e REDIS_PASSWORD="$REDIS_PASSWORD" docker.io/library/redis:"$REDIS_IMAGE_TAG" redis-server --save '' --requirepass "$REDIS_PASSWORD" --appendonly no --port "$REDIS_PORT"
fi
fi