c10d309678
nc is not installed in the containers by default, but socat is available so lets use that instead. Change-Id: Ib98e06531d414f62498fd7c1130899f74a066957 Closes-Bug: #1771705
28 lines
856 B
Bash
Executable File
28 lines
856 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if parse_out=$(cat "/etc/redis.conf" | egrep "^bind +.*$"); then
|
|
redis_host=$(echo -n $parse_out | awk '{print $2}')
|
|
else
|
|
redis_host=127.0.0.1
|
|
fi
|
|
|
|
if parse_out=$(cat "/etc/redis.conf" | egrep "^port +.*$"); then
|
|
redis_port=$(echo -n $parse_out | awk '{print $2}')
|
|
else
|
|
redis_port=6379
|
|
fi
|
|
|
|
if parse_out=$(cat "/etc/redis.conf" | egrep "^requirepass +.*$"); then
|
|
redis_pass=$(echo -n $parse_out | awk '{print $2}')
|
|
result=$(printf "*2\r\n\$4\r\nAUTH\r\n\$${#redis_pass}\r\n${redis_pass}\r\n*1\r\n\$4\r\nPING\r\n" | socat - TCP:$redis_host:$redis_port)
|
|
else
|
|
result=$(printf "*1\r\n\$4\r\nPING\r\n" | socat - TCP:$redis_host:$redis_port)
|
|
fi
|
|
|
|
if echo $result | grep -q '+PONG'; then
|
|
echo "Redis server responded correctly on ${redis_host}:${redis_port}."
|
|
else
|
|
echo "Redis server does not respond correctly: ${result}"
|
|
exit 1
|
|
fi
|