tripleo-common/healthcheck/redis
Pablo Iranzo Gómez 37a5c78673
Fix formatting options
Fix tabs<->spaces and other bashate complains
	Change mode to +x to scripts missing it
	Force shell to be /bin/bash for compatibility

Change-Id: Ied5979f2d886c15b273956a9828d9e0484368bab
Signed-off-by: Pablo Iranzo Gómez <Pablo.Iranzo@gmail.com>
2018-09-11 17:15:11 +02:00

28 lines
876 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