aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2023-08-30 11:40:19 +0200
committerWojtek Kosior <koszko@koszko.org>2023-08-30 11:40:19 +0200
commit9e71165dd3fa31accbcce8d5875aa774ab8b8fe1 (patch)
tree6de9d1246e80fd8ad391840c5da47aca24999592 /Makefile
parent41d988a7ae42eb5038be051d208a6164b576e189 (diff)
downloadkoszko-org-server-9e71165dd3fa31accbcce8d5875aa774ab8b8fe1.tar.gz
koszko-org-server-9e71165dd3fa31accbcce8d5875aa774ab8b8fe1.zip
run Exim in container
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile55
1 files changed, 45 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 1acdba5..0bea659 100644
--- a/Makefile
+++ b/Makefile
@@ -34,9 +34,10 @@ ALL_EGG_INFOS = \
$(HYDRILLA_WEBSITE_INFO) \
$(HYDRILLA_INFO)
-CONTAINER_PREREQUISITES = container.scm $(ALL_EGG_INFOS) hydrilla-wsgi.py
+CONTAINER_PREREQUISITES = container.scm $(ALL_EGG_INFOS) hydrilla-wsgi.py \
+ exim.conf
-TEST_ROOT_DIR = "/tmp/$$(pwd | sed 's|/|!|g')"'!!test-root'
+TEST_ROOT_DIR = "/tmp/$$(pwd | sed 's|/|!|g')"'!!test-root/current'
all: | container-runner.touchfile log sample-malcontent
@@ -59,7 +60,7 @@ hosts: hosts-extra /etc/hosts
cat $^ > $@
log:
- ln -sf $(TEST_ROOT_DIR)/var/log/guix-container $@
+ ln -sf test-root/var/log/guix-container $@
sample-malcontent:
mkdir $@
@@ -68,12 +69,31 @@ sample-malcontent:
make -C subrepos/hydrilla shell-with-hydrilla-only
LETSENCRYPT_ETC_DIR = $(TEST_ROOT_DIR)/etc/letsencrypt
+EXIM_ETC_DIR = $(TEST_ROOT_DIR)/etc/exim
HYDRILLA_WEBSITE_ETC_DIR = $(TEST_ROOT_DIR)/etc/guix-container/hydrilla-website
MALCONTENT_DIR = $(TEST_ROOT_DIR)/var/lib/hydrilla/malcontent_dirs
GITOLITE_DIR = $(TEST_ROOT_DIR)/var/lib/gitolite3
+EXIM_SPOOL_DIR = $(TEST_ROOT_DIR)/var/spool/exim
+
+test-root: sample-malcontent Makefile
+ rm -f $@
+ ln -sf $(TEST_ROOT_DIR) $@
+ $(MAKE) prepare-test-root
+
+.PHONY: ensure-test-root
+ensure-test-root:
+ $(MAKE) test-root
+ if [ \! -e $(TEST_ROOT_DIR) ]; then \
+ $(MAKE) prepare-test-root; \
+ fi
+.PHONY: prepare-test-root
prepare-test-root: sample-malcontent
- rm -rf $(TEST_ROOT_DIR)
+ @# Move the old test root
+ if [ -e $(TEST_ROOT_DIR) ]; then \
+ mv $(TEST_ROOT_DIR) \
+ $(TEST_ROOT_DIR)/../"old-$$(date --iso-8601=seconds)"; \
+ fi
@# Prepare replacement `/var/www`
for WWW_SUBDIR in \
koszko.org/html \
@@ -92,6 +112,17 @@ prepare-test-root: sample-malcontent
printf 'test secret\n' > $(LETSENCRYPT_ETC_DIR)/dummy-keys-and-stuff.txt
chmod 540 $(LETSENCRYPT_ETC_DIR)/dummy-keys-and-stuff.txt
chgrp 1001 $(LETSENCRYPT_ETC_DIR)/dummy-keys-and-stuff.txt
+ @# Prepare replacement `/etc/exim`
+ mkdir --mode=755 -p $(EXIM_ETC_DIR)
+ guix shell openssl -- openssl genrsa -out $(EXIM_ETC_DIR)/dkim.pem 2048
+ chmod 640 $(EXIM_ETC_DIR)/dkim.pem
+ chown 106:113 $(EXIM_ETC_DIR)/dkim.pem
+ printf koszko: > $(EXIM_ETC_DIR)/passwd
+ printf silnehaslo | guix shell whois -- mkpasswd --method=sha-256 -s \
+ >> $(EXIM_ETC_DIR)/passwd
+ echo >> $(EXIM_ETC_DIR)/passwd
+ chmod 640 $(EXIM_ETC_DIR)/passwd
+ chown 106:113 $(EXIM_ETC_DIR)/passwd
@# Prepare replacement `/etc`
mkdir --mode=750 -p $(HYDRILLA_WEBSITE_ETC_DIR)
printf 'test non-secret\n' > $(HYDRILLA_WEBSITE_ETC_DIR)/secret.txt
@@ -108,18 +139,23 @@ prepare-test-root: sample-malcontent
printf "sheets-websites.git\n" > $(GITOLITE_DIR)/projects.list
chmod -R o-rwx,g-w $(GITOLITE_DIR)
chgrp -R 118 $(GITOLITE_DIR)
+ @# Prepare replacement `/var/spool/exim`
+ mkdir -p $(EXIM_SPOOL_DIR)
+ chmod 750 $(EXIM_SPOOL_DIR)
+ chown 106:113 $(EXIM_SPOOL_DIR)
-GUIX_CONTAINER_FLAGS = -e ./container-runner -p ./pidfile -r $(TEST_ROOT_DIR)
+GUIX_CONTAINER_FLAGS = -e ./container-runner -p ./pidfile \
+ -r "$$(realpath test-root)"
-start-container: guix-container.sh container-runner.touchfile \
- prepare-test-root | log
+start-container: guix-container.sh container-runner.touchfile ensure-test-root \
+ | log
./$< start $(GUIX_CONTAINER_FLAGS)
stop-container: guix-container.sh
./$< stop $(GUIX_CONTAINER_FLAGS)
restart-container: guix-container.sh container-runner.touchfile \
- prepare-test-root | log
+ ensure-test-root | log
./$< restart $(GUIX_CONTAINER_FLAGS)
enter-container: pidfile
@@ -152,11 +188,10 @@ clean: clean-runner
for SUBREPO in $(SUBREPOS_WITH_MAKEFILE); do \
$(MAKE) -C subrepos/"$$SUBREPO" clean; \
done
- rm -rf log hosts schemas sample-malcontent
+ rm -rf log test-root hosts schemas sample-malcontent
.PHONY: all \
clean-runner clean \
- prepare-test-root \
start-container stop-container restart-container \
enter-container fake-client \
install \