617715f9da
This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/redis.git#e946b7e0cd1311dae3cc19195ed2d17b163ac5c7
41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Wrapper to close properly redis and sentinel
|
|
test x"$REDIS_DEBUG" != x && set -x
|
|
|
|
REDIS_CLI=/usr/bin/redis-cli
|
|
|
|
# Retrieve service name
|
|
SERVICE_NAME="$1"
|
|
if [ -z "$SERVICE_NAME" ]; then
|
|
SERVICE_NAME=redis
|
|
fi
|
|
|
|
# Get the proper config file based on service name
|
|
CONFIG_FILE="/etc/redis/$SERVICE_NAME.conf"
|
|
|
|
# Use awk to retrieve host, port from config file
|
|
HOST=`awk '/^[[:blank:]]*bind/ { print $2 }' $CONFIG_FILE | tail -n1`
|
|
PORT=`awk '/^[[:blank:]]*port/ { print $2 }' $CONFIG_FILE | tail -n1`
|
|
PASS=`awk '/^[[:blank:]]*requirepass/ { print $2 }' $CONFIG_FILE | tail -n1`
|
|
SOCK=`awk '/^[[:blank:]]*unixsocket\s/ { print $2 }' $CONFIG_FILE | tail -n1`
|
|
|
|
# Just in case, use default host, port
|
|
HOST=${HOST:-127.0.0.1}
|
|
if [ "$SERVICE_NAME" = redis ]; then
|
|
PORT=${PORT:-6379}
|
|
else
|
|
PORT=${PORT:-26739}
|
|
fi
|
|
|
|
# Setup additional parameters
|
|
# e.g password-protected redis instances
|
|
[ -z "$PASS" ] || ADDITIONAL_PARAMS="-a $PASS"
|
|
|
|
# shutdown the service properly
|
|
if [ -e "$SOCK" ] ; then
|
|
$REDIS_CLI -s $SOCK $ADDITIONAL_PARAMS shutdown
|
|
else
|
|
$REDIS_CLI -h $HOST -p $PORT $ADDITIONAL_PARAMS shutdown
|
|
fi
|