mailcow/004-build-redis.sh

39 lines
874 B
Bash
Raw Normal View History

2016-12-10 03:39:02 +08:00
#!/bin/bash
. mailcow.conf
NAME="redis-mailcow"
client() {
docker exec -it ${NAME} /bin/bash -c "redis-cli"
}
if [[ ${1} == "--client" ]]; then
client
exit 0
2016-12-11 21:13:17 +08:00
elif [[ ! -z ${1} ]]; then
echo "Unknown parameter"
exit 1
2016-12-10 03:39:02 +08:00
fi
echo "Stopping and removing containers with name tag ${NAME}..."
if [[ ! -z $(docker ps -af "name=${NAME}" -q) ]]; then
docker stop $(docker ps -af "name=${NAME}" -q)
docker rm $(docker ps -af "name=${NAME}" -q)
fi
if [[ ! -z "$(docker images -q redis:${DBVERS})" ]]; then
2016-12-10 03:52:19 +08:00
read -r -p "Found image locally. Delete local image and repull? [y/N] " response
2016-12-10 03:39:02 +08:00
response=${response,,}
if [[ $response =~ ^(yes|y)$ ]]; then
docker rmi redis:${DBVERS}
fi
fi
docker run \
-v ${PWD}/data/db/redis/:/data/ \
--network=${DOCKER_NETWORK} \
-h redis \
--name=${NAME} \
-d redis:${REDISVERS} --appendonly yes