2016-12-10 03:39:02 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
. mailcow.conf
|
|
|
|
|
|
|
|
NAME="rspamd-mailcow"
|
|
|
|
|
|
|
|
build() {
|
2016-12-10 03:52:19 +08:00
|
|
|
docker build --no-cache -t rspamd data/Dockerfiles/rspamd/.
|
2016-12-10 03:39:02 +08:00
|
|
|
}
|
|
|
|
|
2016-12-12 01:58:29 +08:00
|
|
|
PDNS_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pdns-mailcow 2> /dev/null)
|
|
|
|
if [[ ! ${PDNS_IP} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
|
|
echo "Cannot determine Powerdns Recursor ip address. Is the container running?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-12-10 03:39:02 +08:00
|
|
|
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 rspamd)" ]]; then
|
2016-12-10 03:52:19 +08:00
|
|
|
read -r -p "Found image locally. Delete local and rebuild without cache anyway? [y/N] " response
|
2016-12-10 03:39:02 +08:00
|
|
|
response=${response,,}
|
|
|
|
if [[ $response =~ ^(yes|y)$ ]]; then
|
|
|
|
docker rmi rspamd
|
|
|
|
build
|
|
|
|
fi
|
2016-12-12 17:01:27 +08:00
|
|
|
else
|
|
|
|
build
|
2016-12-10 03:39:02 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
docker run \
|
2016-12-13 04:53:58 +08:00
|
|
|
-v ${PWD}/data/conf/rspamd/override.d/:/etc/rspamd/override.d/ro \
|
|
|
|
-v ${PWD}/data/conf/rspamd/local.d/:/etc/rspamd/local.d/ro \
|
|
|
|
-v ${PWD}/data/conf/rspamd/lua/:/etc/rspamd/lua/:ro \
|
2016-12-10 03:39:02 +08:00
|
|
|
-v ${PWD}/data/dkim/txt/:/etc/rspamd/dkim/txt/:ro \
|
|
|
|
-v ${PWD}/data/dkim/keys/:/etc/rspamd/dkim/keys/:ro \
|
2016-12-12 01:58:29 +08:00
|
|
|
--dns=${PDNS_IP} \
|
2016-12-13 04:53:58 +08:00
|
|
|
--dns-search=${DOCKER_NETWORK} \
|
2016-12-10 03:39:02 +08:00
|
|
|
--network=${DOCKER_NETWORK} \
|
|
|
|
-h rspamd \
|
|
|
|
--name ${NAME} \
|
|
|
|
-d rspamd
|
|
|
|
|
2016-12-11 04:49:41 +08:00
|
|
|
/bin/bash ./fix-permissions.sh
|
|
|
|
|