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
|
|
|
|
fi
|
|
|
|
|
|
|
|
docker run \
|
|
|
|
-v ${PWD}/data/conf/rspamd/override.d/:/etc/rspamd/override.d/ \
|
|
|
|
-v ${PWD}/data/conf/rspamd/local.d/:/etc/rspamd/local.d/ \
|
|
|
|
-v ${PWD}/data/conf/rspamd/lua/:/etc/rspamd/lua/ \
|
|
|
|
-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} \
|
|
|
|
--dns-search=${DOCKER_NETWORK} \
|
2016-12-10 03:39:02 +08:00
|
|
|
--network=${DOCKER_NETWORK} \
|
|
|
|
--network-alias rspamd \
|
|
|
|
-h rspamd \
|
|
|
|
--name ${NAME} \
|
|
|
|
-d rspamd
|
|
|
|
|
2016-12-11 04:49:41 +08:00
|
|
|
/bin/bash ./fix-permissions.sh
|
|
|
|
|