summaryrefslogtreecommitdiff
path: root/make/nginx.mk
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-07-01 18:31:34 +0100
committerJoe Carstairs <me@joeac.net>2026-07-01 18:31:34 +0100
commitc7c8a96a572dd04c3aff44284c4c46da04deaa37 (patch)
tree9318ff98f197a1a948e651d12116983019dedcb6 /make/nginx.mk
parentf73512107c7cf8d95fb1f97fa69706a1519e5ca3 (diff)
moves helper makefiles into make/ dir
Diffstat (limited to 'make/nginx.mk')
-rw-r--r--make/nginx.mk39
1 files changed, 39 insertions, 0 deletions
diff --git a/make/nginx.mk b/make/nginx.mk
new file mode 100644
index 0000000..c78f20b
--- /dev/null
+++ b/make/nginx.mk
@@ -0,0 +1,39 @@
+define install_nginx_module_rule =
+.PHONY: install_nginx_$(module)
+install_nginx_$(module): $(if $(SUBDOMAIN_$(module)),/etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf)
+endef
+
+define reinstall_nginx_module_rule =
+.PHONY: reinstall_nginx_$(module)
+reinstall_nginx_$(module): $(if $(SUBDOMAIN_$(module)),/etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf)
+endef
+
+define uninstall_nginx_module_rule =
+.PHONY: uninstall_nginx_$(module)
+uninstall_nginx_$(module):
+endef
+
+$(foreach module,$(MODULES),$(eval $(install_nginx_module_rule)))
+
+/etc/nginx/http.d/%.joeac.net.conf: nginx/http.d/%.joeac.net.conf /etc/nginx/http.d /etc/nginx/nginx.conf
+ sudo cp $< $@
+ sudo rc-service nginx restart
+
+/etc/nginx/http.d:
+ sudo mkdir -p /etc/nginx/http.d
+
+.PHONY: uninstall_nginx
+uninstall_nginx: $(foreach module,$(MODULES),uninstall_nginx_$(module))
+ifeq ($(shell test -d /etc/nginx/nginx.joeac.net-backup && echo 1 || echo 0),0)
+ $(warn No nginx backup config detected: doing nothing)
+else
+ sudo mv /etc/nginx/nginx.joeac.net-backup /etc/nginx/nginx.conf
+ sudo rc-service nginx restart
+endif
+
+/etc/nginx/nginx.conf: nginx/nginx.conf /etc/nginx/nginx.joeac.net-backup
+ sudo cp $< $@
+ sudo rc-service nginx restart
+
+/etc/nginx/nginx.joeac.net-backup:
+ sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.joeac.net-backup