ufw rules
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
CMDARGS += ufw ufw-docker
|
||||
UFW_UPDATE ?= $(or $(SERVICE),$(DOCKER_SERVICES))
|
||||
|
||||
ifeq ($(SETUP_UFW),true)
|
||||
|
||||
# function ufw: Exec command ufw with args 1
|
||||
define ufw
|
||||
$(call INFO,ufw,$(1)$(comma))
|
||||
$(call app-bootstrap,ufw-docker)
|
||||
$(call app-exec,,ufw $(1))
|
||||
endef
|
||||
|
||||
# function ufw-docker: Exec command ufw-docker with args 1
|
||||
define ufw-docker
|
||||
$(call INFO,ufw-docker,$(1)$(comma))
|
||||
$(call app-bootstrap,ufw-docker)
|
||||
$(call app-exec,,ufw-docker $(1))
|
||||
endef
|
||||
|
||||
endif
|
||||
|
||||
@@ -1,5 +1,37 @@
|
||||
# target ufw: Call ufw ARGS
|
||||
.PHONY: ufw
|
||||
ufw:
|
||||
$(call ufw,$(ARGS))
|
||||
|
||||
# target ufw-delete: Fire ufw-update UFW_DELETE=true
|
||||
.PHONY: ufw-delete
|
||||
ufw-delete: UFW_DELETE := true
|
||||
ufw-delete: ufw-update
|
||||
|
||||
# target ufw-docker: Call ufw-docker ARGS
|
||||
.PHONY: ufw-docker
|
||||
ufw-docker:
|
||||
$(call ufw-docker,$(ARGS))
|
||||
|
||||
# target ufw-docker: Call ufw and ufw-docker foreach service UFW_UPDATE
|
||||
.PHONY: ufw-update
|
||||
ufw-update:
|
||||
$(foreach update,$(UFW_UPDATE), \
|
||||
$(foreach port,$(UFW_DOCKER_$(DOCKER_COMPOSE_PROJECT_NAME)-$(update)), \
|
||||
$(call ufw-docker,$(if $(UFW_DELETE),delete) allow $(DOCKER_COMPOSE_PROJECT_NAME)-$(update) $(port)) \
|
||||
) \
|
||||
$(foreach port,$(UFW_UPDATE_$(DOCKER_COMPOSE_PROJECT_NAME)-$(update)), \
|
||||
$(call ufw,$(if $(UFW_DELETE),delete) allow $(port)) \
|
||||
) \
|
||||
)
|
||||
|
||||
## ex: ufw-node-up will update ufw rules for stack node
|
||||
.PHONY: stack-%
|
||||
ufw-%:
|
||||
$(eval stack := $(subst -$(lastword $(subst -, ,$*)),,$*))
|
||||
$(eval command := $(lastword $(subst -, ,$*)))
|
||||
$(if $(findstring -,$*), \
|
||||
$(if $(filter ufw-$(command),$(MAKE_TARGETS)), \
|
||||
$(call make,ufw-$(command) STACK="$(stack)") \
|
||||
) \
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user