dags/fugu/acme_refresh/Makefile

49 lines
1.2 KiB
Makefile
Raw Normal View History

2022-09-23 10:38:10 +02:00
# Note: since I am assuming GNU Make and this host runs OpenBSD, remember to
# run this dag using `gmake` instead of `make`
2022-09-16 17:26:21 +02:00
WD=/var/lib/dags/acme_refresh
2022-09-16 16:20:06 +02:00
2022-09-16 17:26:21 +02:00
SMTPD_RESTART=$(WD)/smtpd_restart
DOVECOT_RELOAD=$(WD)/dovecot_reload
.PHONY: all
2022-09-16 16:20:06 +02:00
all: $(SMTPD_RESTART) $(DOVECOT_RELOAD)
2022-09-16 17:26:21 +02:00
2022-09-16 16:20:06 +02:00
###############################################################################
2022-09-16 18:27:15 +02:00
ACME_DIR=/srv/certs/acme
DOMAIN=monotremata.xyz
2023-07-12 16:10:44 +02:00
MAIL_CERT_PATH=$(ACME_DIR)/mail.$(DOMAIN)
MAIL_CERT=$(MAIL_CERT_PATH)/fullchain.pem
MAIL_KEY=$(MAIL_CERT_PATH)/key.pem
2022-09-16 16:20:06 +02:00
2022-09-16 17:26:21 +02:00
###############################################################################
SSL_PATH=/etc/ssl
2023-07-12 16:10:44 +02:00
CERT_DEST=$(SSL_PATH)/fullchain.pem
KEY_DEST=$(SSL_PATH)/private/key.pem
2022-09-16 17:26:21 +02:00
2023-07-12 16:10:44 +02:00
$(CERT_DEST): $(MAIL_CERT)
2022-09-16 17:26:21 +02:00
install -m 444 $< $@
2023-07-12 16:10:44 +02:00
$(KEY_DEST): $(MAIL_KEY)
2022-09-16 17:26:21 +02:00
install -m 400 $< $@
###############################################################################
$(SMTPD_RESTART): $(CERT_DEST) $(KEY_DEST)
mkdir -p $(@D)
rcctl restart smtpd
touch $@
###############################################################################
$(DOVECOT_RELOAD): $(CERT_DEST) $(KEY_DEST)
mkdir -p $(@D)
rcctl reload dovecot
touch $@
###############################################################################