23
.drone.yml
23
.drone.yml
@@ -1,23 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: powerdns
|
||||
|
||||
steps:
|
||||
|
||||
- name: deploy_local
|
||||
pull: never
|
||||
image: ${DCAPE_COMPOSE}
|
||||
commands:
|
||||
- . setup config
|
||||
- make update
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
|
||||
volumes:
|
||||
- name: dockersock
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
# docker run powerdns pdnsutil check-zone
|
||||
18
.woodpecker.yml
Normal file
18
.woodpecker.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
variables:
|
||||
- &dcape_img 'dcape-compose'
|
||||
|
||||
clone:
|
||||
git:
|
||||
image: drone/git
|
||||
settings:
|
||||
lfs: false
|
||||
tags: false
|
||||
|
||||
pipeline:
|
||||
deploy:
|
||||
image: *dcape_img
|
||||
commands:
|
||||
- make .config-link
|
||||
- make update
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
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"
|
||||
|
||||
2
_lib.sql
2
_lib.sql
@@ -41,7 +41,7 @@ SELECT x, soa_upd(x) FROM unnest(ARRAY[
|
||||
*/
|
||||
|
||||
-- result was changed to bigint
|
||||
DROP FUNCTION IF EXISTS domain_id(text,text);
|
||||
-- DROP FUNCTION IF EXISTS domain_id(text,text);
|
||||
|
||||
CREATE OR REPLACE FUNCTION domain_id(a_name TEXT, a_type TEXT DEFAULT 'NATIVE') RETURNS BIGINT AS $_$
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user