dcape v3
This commit is contained in:
56
Makefile
56
Makefile
@@ -12,40 +12,46 @@ OBJECTSDIRECT = $(SOURCES:.sql=.direct)
|
||||
# app custom config
|
||||
# comments prefixed with '#- ' will be copied to $(CFG).sample
|
||||
|
||||
#- Postgresql container name (access via docker)
|
||||
PG_CONTAINER ?= dcape-db-1
|
||||
|
||||
#- PowerDNS DB user name
|
||||
PGUSER ?= pdns
|
||||
|
||||
#- PowerDNS DB name
|
||||
PGDATABASE ?= pdns
|
||||
|
||||
#- Used ONLY for direct DB access without docker (update-direct)
|
||||
PGPASSWORD ?=
|
||||
|
||||
#- ACME zone suffix
|
||||
ACME_DOMAIN ?=
|
||||
ACME_DOMAIN ?=
|
||||
|
||||
#- This NS hostname for use in all SOA
|
||||
NSERVER ?=
|
||||
NSERVER ?=
|
||||
|
||||
#- db container
|
||||
DB_CONTAINER ?= #
|
||||
|
||||
#- PowerDNS DB user name
|
||||
PGUSER ?= pdns
|
||||
|
||||
#- PowerDNS DB name
|
||||
PGDATABASE ?= pdns
|
||||
|
||||
#- Used ONLY for direct DB access without docker (update-direct)
|
||||
PGPASSWORD ?=
|
||||
#- Used ONLY for direct DB access without docker (update-direct)
|
||||
DB_PORT_LOCAL ?=
|
||||
|
||||
USE_DCAPE_DC := no
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
-include $(CFG).bak
|
||||
export
|
||||
|
||||
-include $(CFG)
|
||||
export
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# dcape v1 comparibility
|
||||
|
||||
start-hook: update
|
||||
|
||||
stop:
|
||||
ifneq ($(findstring $(MAKECMDGOALS),psql),)
|
||||
USE_DB := yes
|
||||
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
|
||||
#- dcape compose docker image
|
||||
DCAPE_COMPOSE ?= dcape-compose
|
||||
DCAPE_ROOT ?= $(shell docker inspect -f "{{.Config.Labels.dcape_root}}" $(DCAPE_COMPOSE))
|
||||
|
||||
@@ -56,19 +62,23 @@ else
|
||||
endif
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
## DB operations
|
||||
#:
|
||||
.PHONY: update
|
||||
|
||||
update: $(OBJECTS)
|
||||
|
||||
%.done: %.sql
|
||||
@echo "*** $< ***"
|
||||
@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
|
||||
update-direct: $(CFG) $(OBJECTSDIRECT)
|
||||
|
||||
%.direct: %.sql
|
||||
@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
|
||||
|
||||
* [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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user