v3 support
This commit is contained in:
64
Makefile
64
Makefile
@@ -1,9 +1,10 @@
|
||||
# app custom Makefile
|
||||
# app dcape v3 dns-config Makefile.
|
||||
|
||||
SHELL = /bin/sh
|
||||
CFG = .env
|
||||
CFG_BAK ?= $(CFG).bak
|
||||
|
||||
SOURCES ?= $(wildcard *.sql)
|
||||
SOURCES ?= _lib.sql $(wildcard *.sql)
|
||||
OBJECTS = $(SOURCES:.sql=.done)
|
||||
OBJECTSDIRECT = $(SOURCES:.sql=.direct)
|
||||
|
||||
@@ -12,7 +13,7 @@ OBJECTSDIRECT = $(SOURCES:.sql=.direct)
|
||||
# comments prefixed with '#- ' will be copied to $(CFG).sample
|
||||
|
||||
#- Postgresql container name (access via docker)
|
||||
PG_CONTAINER ?= dcape_db_1
|
||||
PG_CONTAINER ?= dcape-db-1
|
||||
|
||||
#- PowerDNS DB user name
|
||||
PGUSER ?= pdns
|
||||
@@ -30,8 +31,8 @@ ACME_DOMAIN ?=
|
||||
NSERVER ?=
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
all: help
|
||||
-include $(CFG).bak
|
||||
export
|
||||
|
||||
-include $(CFG)
|
||||
export
|
||||
@@ -44,10 +45,17 @@ start-hook: update
|
||||
stop:
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
## Usage
|
||||
#:
|
||||
# Find and include DCAPE_ROOT/Makefile
|
||||
DCAPE_COMPOSE ?= dcape-compose
|
||||
DCAPE_ROOT ?= $(shell docker inspect -f "{{.Config.Labels.dcape_root}}" $(DCAPE_COMPOSE))
|
||||
|
||||
## Load updated zone files via running PG container
|
||||
ifeq ($(shell test -e $(DCAPE_ROOT)/Makefile.app && echo -n yes),yes)
|
||||
include $(DCAPE_ROOT)/Makefile.app
|
||||
else
|
||||
include /opt/dcape/Makefile.app
|
||||
endif
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
update: $(OBJECTS)
|
||||
|
||||
%.done: %.sql
|
||||
@@ -62,48 +70,8 @@ update-direct: $(CFG) $(OBJECTSDIRECT)
|
||||
@echo "*** $< ***"
|
||||
@source $(CFG) && cat $< | PGPASSWORD=$$PGPASSWORD psql -h localhost -U $$PGUSER > $@
|
||||
|
||||
## Run psql via running PG container
|
||||
psql:
|
||||
@docker exec -it $$PG_CONTAINER psql -U $$PGUSER $$PGDATABASE
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
## Other
|
||||
#:
|
||||
|
||||
# This code generates $(CFG).sample from Makefile vars with previous comment line(s)
|
||||
# See https://gist.github.com/LeKovr/2697fe02504d7c081b0bf79427c93db6
|
||||
|
||||
# Internal: generate config sample data
|
||||
.env.temp.mk:
|
||||
@echo "define CFVAR" > $@
|
||||
@grep -A 1 -h "^#- " $(MAKEFILE_LIST) | grep -vE "^--" \
|
||||
| sed -E 's/^([^\n ]+)\ *\??=([^\n]*)$$/\1=$$(\1)\n/ ; s/^(#)-/\1/' >> $@
|
||||
@echo "endef" >> $@
|
||||
|
||||
ifneq ($(findstring $(MAKECMDGOALS),config $(CFG).sample),)
|
||||
include .env.temp.mk
|
||||
endif
|
||||
|
||||
# Internal: generate config sample
|
||||
$(CFG).sample: .env.temp.mk
|
||||
@echo "# dcape-dns config file, generated by 'make config'\n" > $@
|
||||
@echo "$$CFVAR" >> $@
|
||||
@rm -f $<
|
||||
|
||||
## generate sample config
|
||||
config: $(CFG).sample
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
## Remove .done files
|
||||
clean:
|
||||
rm -rf $(OBJECTS)
|
||||
|
||||
# This code handles group header and target comment with one or two lines only
|
||||
## list Makefile targets
|
||||
## (this is default target)
|
||||
help:
|
||||
@grep -A 1 -h "^## " $(MAKEFILE_LIST) \
|
||||
| sed -E 's/^--$$// ; /./{H;$$!d} ; x ; s/^\n## ([^\n]+)\n(## (.+)\n)*(.+):(.*)$$/" " "\4" "\1" "\3"/' \
|
||||
| sed -E 's/^" " "#" "(.+)" "(.*)"$$/"" "" "" ""\n"\1 \2" "" "" ""/' \
|
||||
| xargs printf "%s\033[36m%-15s\033[0m %s %s\n"
|
||||
|
||||
Reference in New Issue
Block a user