test/config backup & restore (#907)

* backup and restore of test/config folder as done for the regular config folder as well.
* permissions fix
* preserving permissions and ownership
* new backup rule
This commit is contained in:
17Halbe 2018-03-21 19:55:41 +01:00 committed by Johan Smits
parent ee4b434a5c
commit a7589aa353
2 changed files with 18 additions and 17 deletions

View file

@ -1,8 +1,8 @@
NAME = tvial/docker-mailserver:testing
all: build-no-cache generate-accounts run generate-accounts-after-run fixtures tests clean
all-fast: build generate-accounts run generate-accounts-after-run fixtures tests clean
no-build: generate-accounts run generate-accounts-after-run fixtures tests clean
all: build-no-cache backup generate-accounts run generate-accounts-after-run fixtures tests clean
all-fast: build backup generate-accounts run generate-accounts-after-run fixtures tests clean
no-build: backup generate-accounts run generate-accounts-after-run fixtures tests clean
build-no-cache:
cd test/docker-openldap/ && docker build -f Dockerfile -t ldap --no-cache .
@ -12,6 +12,15 @@ build:
cd test/docker-openldap/ && docker build -f Dockerfile -t ldap .
docker build -t $(NAME) .
backup:
# if backup directories exist, clean hasn't been called, therefore we shouldn't overwrite it. It still contains the original content.
@if [ ! -d config.bak ]; then\
cp -rp config config.bak; \
fi
@if [ ! -d testconfig.bak ]; then\
cp -rp test/config testconfig.bak ;\
fi
generate-accounts:
docker run --rm -e MAIL_USER=user1@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' > test/config/postfix-accounts.cf
docker run --rm -e MAIL_USER=user2@otherdomain.tld -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf
@ -205,7 +214,6 @@ generate-accounts-after-run:
sleep 10
fixtures:
cp -r config config.bak
# Setup sieve & create filtering folder (INBOX/spam)
docker cp "`pwd`/test/config/sieve/dovecot.sieve" mail:/var/mail/localhost.localdomain/user1/.dovecot.sieve
docker exec mail /bin/sh -c "maildirmake.dovecot /var/mail/localhost.localdomain/user1/.INBOX.spam"
@ -262,16 +270,11 @@ clean:
mail_override_hostname
@if [ -d config.bak ]; then\
sudo rm -rf config ;\
rm -rf config ;\
mv config.bak config ;\
fi
-sudo rm -rf test/onedir \
test/config/empty \
test/config/keyDefault \
test/config/key2048 \
test/config/key1024 \
test/config/without-accounts \
test/config/without-virtual \
test/config/with-domain \
test/config/dovecot-lmtp/userdb \
test/config/postfix-*-access.cf*
@if [ -d testconfig.bak ]; then\
rm -rf test/config ;\
mv testconfig.bak test/config ;\
fi
-sudo rm -rf test/onedir

View file

@ -1,2 +0,0 @@
user1@localhost.localdomain:{SHA512-CRYPT}$6$pnBf.UoYuOJ0EcxA$AY.2iRKsDftvCs5u2u72jgKcQHdN/tLguweV08YuBNaZGN4Xn9N8ES0NPxErqRR433vqBFUMmOiVNVF3JgMpB.:5000:5000::/var/mail/localhost.localdomain/user1::
user2@otherdomain.tld:{SHA512-CRYPT}$6$xkJ0klS8NqpoGeVB$jKmC1YE03GeLtrcwgnQ14AG.nYm8Vj0l0BqUVM.VQ3MVBwYoooJL7JS7czR17gfwM9SRB/311OP8nF/GpNKr5.:5000:5000::/var/mail/otherdomain.tld/user2::