diff --git a/Makefile b/Makefile index 1dd0512..e75cc8f 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,6 @@ RESTART_NGINX := sudo rc-service nginx restart ############# container_image_name = $(REGISTRY_DOMAIN)/$(REGISTRY_USER)/joeac.net-$(module) -nginx_module_target = $(if $(SUBDOMAIN_$(module)),/etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf) dyndns_module_target = $(if $(SUBDOMAIN_$(module)),/etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net) openrc_module_target = $(if $(filter $(COMPOSE_SERVICES),$(module)),~/.config/rc/init.d/joeac.net.$(module)) install_submake_file = $(shell [ -f "$(module)/install.mk" ] && echo "$(module)/install.mk") @@ -50,13 +49,13 @@ endef define install_module_rule = .PHONY: install_$(module) -install_$(module): install_openrc_$(module) $(nginx_module_target) $(dyndns_module_target) $(install_submake_file) +install_$(module): install_openrc_$(module) install_nginx_module_$(module) $(dyndns_module_target) $(install_submake_file) $(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) install) endef define reinstall_module_rule = .PHONY: reinstall_$(module) -reinstall_$(module): reinstall_openrc_$(module) $(nginx_module_target) $(dyndns_module_target) $(install_submake_file) +reinstall_$(module): reinstall_openrc_$(module) reinstall_nginx_module_$(module) $(dyndns_module_target) $(install_submake_file) $(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) reinstall) endef diff --git a/nginx.mk b/nginx.mk index 8ae9076..a97957f 100644 --- a/nginx.mk +++ b/nginx.mk @@ -19,10 +19,3 @@ $(NGINX_CONFIG_BACKUP): $(NGINX_CONFIG): $(NGINX_CONFIG_SRC) $(NGINX_CONFIG_BACKUP) sudo cp $< $@ $(RESTART_NGINX) - -/etc/nginx/http.d/%joeac.net.conf: nginx/http.d/%joeac.net.conf /etc/nginx/http.d $(NGINX_CONFIG) - sudo cp $< $@ - $(RESTART_NGINX) - -/etc/nginx/http.d: - sudo mkdir -p /etc/nginx/http.d diff --git a/nginx_module.mk b/nginx_module.mk new file mode 100644 index 0000000..0b1a2c5 --- /dev/null +++ b/nginx_module.mk @@ -0,0 +1,24 @@ +define install_nginx_module_rule = +.PHONY: install_nginx_module_rule +install_nginx_module_rule: $(if $(SUBDOMAIN_$(module)),/etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf) +endef + +define reinstall_nginx_module_rule = +.PHONY: reinstall_nginx_module_rule +reinstall_nginx_module_rule: $(if $(SUBDOMAIN_$(module)),/etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf) +endef + +define uninstall_nginx_module_rule = +.PHONY: uninstall_nginx_module_rule +uninstall_nginx_module_rule: + $(if $(SUBDOMAIN_$(module)),rm -f /etc/nginx/http.d/$(SUBDOMAIN_$(module)).joeac.net.conf) +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 $(NGINX_CONFIG) + sudo cp $< $@ + $(RESTART_NGINX) + +/etc/nginx/http.d: + sudo mkdir -p /etc/nginx/http.d