dcape v3
This commit is contained in:
42
Makefile
42
Makefile
@@ -12,8 +12,14 @@ OBJECTSDIRECT = $(SOURCES:.sql=.direct)
|
|||||||
# app custom config
|
# app custom config
|
||||||
# comments prefixed with '#- ' will be copied to $(CFG).sample
|
# comments prefixed with '#- ' will be copied to $(CFG).sample
|
||||||
|
|
||||||
#- Postgresql container name (access via docker)
|
#- ACME zone suffix
|
||||||
PG_CONTAINER ?= dcape-db-1
|
ACME_DOMAIN ?=
|
||||||
|
|
||||||
|
#- This NS hostname for use in all SOA
|
||||||
|
NSERVER ?=
|
||||||
|
|
||||||
|
#- db container
|
||||||
|
DB_CONTAINER ?= #
|
||||||
|
|
||||||
#- PowerDNS DB user name
|
#- PowerDNS DB user name
|
||||||
PGUSER ?= pdns
|
PGUSER ?= pdns
|
||||||
@@ -23,29 +29,29 @@ PGDATABASE ?= pdns
|
|||||||
|
|
||||||
#- Used ONLY for direct DB access without docker (update-direct)
|
#- Used ONLY for direct DB access without docker (update-direct)
|
||||||
PGPASSWORD ?=
|
PGPASSWORD ?=
|
||||||
|
#- Used ONLY for direct DB access without docker (update-direct)
|
||||||
|
DB_PORT_LOCAL ?=
|
||||||
|
|
||||||
#- ACME zone suffix
|
USE_DCAPE_DC := no
|
||||||
ACME_DOMAIN ?=
|
|
||||||
|
|
||||||
#- This NS hostname for use in all SOA
|
|
||||||
NSERVER ?=
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
-include $(CFG).bak
|
-include $(CFG).bak
|
||||||
export
|
export
|
||||||
|
|
||||||
-include $(CFG)
|
|
||||||
export
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# dcape v1 comparibility
|
|
||||||
|
|
||||||
start-hook: update
|
ifneq ($(findstring $(MAKECMDGOALS),psql),)
|
||||||
|
USE_DB := yes
|
||||||
stop:
|
else ifneq ($(findstring $(MAKECMDGOALS),psql-local),)
|
||||||
|
USE_DB := yes
|
||||||
|
ifndef DB_PORT_LOCAL
|
||||||
|
$(error "DB_PORT_LOCAL must be set - $(MAKECMDGOALS)")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Find and include DCAPE_ROOT/Makefile
|
# Find and include DCAPE_ROOT/Makefile
|
||||||
|
#- dcape compose docker image
|
||||||
DCAPE_COMPOSE ?= dcape-compose
|
DCAPE_COMPOSE ?= dcape-compose
|
||||||
DCAPE_ROOT ?= $(shell docker inspect -f "{{.Config.Labels.dcape_root}}" $(DCAPE_COMPOSE))
|
DCAPE_ROOT ?= $(shell docker inspect -f "{{.Config.Labels.dcape_root}}" $(DCAPE_COMPOSE))
|
||||||
|
|
||||||
@@ -56,19 +62,23 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
## DB operations
|
||||||
|
#:
|
||||||
|
.PHONY: update
|
||||||
|
|
||||||
update: $(OBJECTS)
|
update: $(OBJECTS)
|
||||||
|
|
||||||
%.done: %.sql
|
%.done: %.sql
|
||||||
@echo "*** $< ***"
|
@echo "*** $< ***"
|
||||||
@csum=$$(md5sum $< | sed 's/ .*//') ; \
|
@csum=$$(md5sum $< | sed 's/ .*//') ; \
|
||||||
cat $< | docker exec -i $$PG_CONTAINER psql -U $$PGUSER -d $$PGDATABASE -vcsum=$$csum -vACME_DOMAIN=$(ACME_DOMAIN) -vNSERVER=$(NSERVER) > $@
|
cat $< | docker exec -i $$DB_CONTAINER psql -U $$PGUSER -d $$PGDATABASE -vcsum=$$csum -vACME_DOMAIN=$(ACME_DOMAIN) -vNSERVER=$(NSERVER) > $@
|
||||||
|
|
||||||
## Load updated zone files via psql connection
|
## Load updated zone files via psql connection
|
||||||
update-direct: $(CFG) $(OBJECTSDIRECT)
|
update-direct: $(CFG) $(OBJECTSDIRECT)
|
||||||
|
|
||||||
%.direct: %.sql
|
%.direct: %.sql
|
||||||
@echo "*** $< ***"
|
@echo "*** $< ***"
|
||||||
@source $(CFG) && cat $< | PGPASSWORD=$$PGPASSWORD psql -h localhost -U $$PGUSER > $@
|
@source $(CFG) && cat $< | PGPASSWORD=$${PGPASSWORD:?Must be set} psql -h localhost -U $$PGUSER -p $${DB_PORT_LOCAL:?Must be set} > $@
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ This project contains Makefile and sample sql zone definition for loading zones
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* [dcape](https://github.com/TenderPro/dcape) installed on remote host with pdns and gitea running
|
* linux 64bit (git, make, wget, gawk, openssl)
|
||||||
|
* [docker](http://docker.io)
|
||||||
|
* [dcape](https://github.com/dopos/dcape)
|
||||||
|
* Git service ([github](https://github.com), [gitea](https://gitea.io) or [gogs](https://gogs.io))
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user