2024-03-23 11:47:05 +01:00
|
|
|
all: build-server
|
2023-06-11 11:16:54 +02:00
|
|
|
|
2023-06-15 20:14:27 +02:00
|
|
|
# For requests where authentication is required.
|
|
|
|
LOGIN ?=
|
|
|
|
ifeq ($(LOGIN),)
|
|
|
|
LOGIN_OPT =
|
|
|
|
else
|
|
|
|
LOGIN_OPT = -l $(LOGIN)
|
|
|
|
endif
|
2023-05-08 21:42:05 +02:00
|
|
|
|
2024-06-02 01:58:56 +02:00
|
|
|
OPTS ?= --progress
|
2023-06-27 20:31:02 +02:00
|
|
|
Q ?= @
|
2023-05-08 21:42:05 +02:00
|
|
|
|
2024-06-22 00:50:15 +02:00
|
|
|
SOURCE_FILES = $(wildcard src/*.cr src/*/*.cr src/*/*/*.cr)
|
2024-03-12 21:51:59 +01:00
|
|
|
|
2023-06-15 20:14:27 +02:00
|
|
|
####################
|
|
|
|
### REQUEST EXAMPLES
|
|
|
|
####################
|
2023-05-08 21:42:05 +02:00
|
|
|
|
2023-06-15 20:14:27 +02:00
|
|
|
DOMAIN ?= example.com
|
2024-06-22 00:50:15 +02:00
|
|
|
bin/write-zone-file: tools/write-zone-file.cr
|
|
|
|
$(Q)-shards build write-zone-file $(OPTS)
|
|
|
|
build-write-zone-file: bin/write-zone-file
|
2023-06-28 02:26:12 +02:00
|
|
|
zone-file: build-write-zone-file
|
|
|
|
$(Q)./bin/write-zone-file $(DOMAIN)
|
|
|
|
|
2024-06-22 00:50:15 +02:00
|
|
|
bin/write-template-zone-file: tools/write-template-zone-file.cr
|
|
|
|
$(Q)-shards build write-template-zone-file $(OPTS)
|
|
|
|
build-write-template-zone-file: bin/write-template-zone-file
|
2023-06-28 02:26:12 +02:00
|
|
|
zone-basic-template-file: build-write-template-zone-file
|
|
|
|
$(Q)./bin/write-template-zone-file $(DOMAIN)
|
2023-05-08 21:42:05 +02:00
|
|
|
|
|
|
|
VERBOSITY ?= 4
|
2024-06-22 00:50:15 +02:00
|
|
|
run-client-verbosity:; $(Q)./bin/dnsmanager-client admin maintenance verbosity $(VERBOSITY) $(LOGIN_OPT)
|
|
|
|
run-client-domain-add:; $(Q)./bin/dnsmanager-client user domain add $(DOMAIN) $(LOGIN_OPT)
|
|
|
|
run-client-domain-del:; $(Q)./bin/dnsmanager-client user domain del $(DOMAIN) $(LOGIN_OPT)
|
|
|
|
run-client-domain-list:; $(Q)./bin/dnsmanager-client user domain list $(LOGIN_OPT)
|
|
|
|
run-client-zone-add:; $(Q)./bin/dnsmanager-client user zone add $(DOMAIN).json $(LOGIN_OPT)
|
|
|
|
run-client-zone-get:; $(Q)./bin/dnsmanager-client user zone get $(DOMAIN) $(LOGIN_OPT)
|
2023-06-27 13:06:05 +02:00
|
|
|
|
2023-05-08 21:42:05 +02:00
|
|
|
RRID ?= 1
|
|
|
|
NAME ?=
|
|
|
|
TTL ?= 3600
|
|
|
|
TARGET ?=
|
2024-06-22 00:50:15 +02:00
|
|
|
run-client-rr-add-a:; $(Q)./bin/dnsmanager-client user rr add A $(DOMAIN) $(NAME) $(TTL) $(TARGET) $(LOGIN_OPT)
|
|
|
|
run-client-rr-update-a:; $(Q)./bin/dnsmanager-client user rr update A $(DOMAIN) $(RRID) $(NAME) $(TTL) $(TARGET) $(LOGIN_OPT)
|
|
|
|
run-client-rr-del:; $(Q)./bin/dnsmanager-client user rr del $(DOMAIN) $(RRID) $(LOGIN_OPT)
|
|
|
|
run-client-genzones:; $(Q)./bin/dnsmanager-client admin genall $(LOGIN_OPT)
|
2024-04-28 12:56:45 +02:00
|
|
|
|
2023-06-15 20:14:27 +02:00
|
|
|
##################
|
|
|
|
### SETUP COMMANDS
|
|
|
|
##################
|
2023-05-08 21:42:05 +02:00
|
|
|
|
2023-07-07 20:23:06 +02:00
|
|
|
DBDIR=/tmp/DATA-dnsmanagerd
|
2024-06-22 00:50:15 +02:00
|
|
|
bin/dnsmanagerd: $(SOURCE_FILES); $(Q)shards build dnsmanagerd $(OPTS)
|
|
|
|
build-server: bin/dnsmanagerd
|
|
|
|
run-dnsmanagerd:; $(Q)./bin/dnsmanagerd -v $(VERBOSITY) -r $(DBDIR)
|
|
|
|
|
|
|
|
bin/dnsmanager-client: $(SOURCE_FILES); $(Q)shards build dnsmanager-client $(OPTS)
|
|
|
|
build-client: bin/dnsmanager-client
|
2023-06-15 20:14:27 +02:00
|
|
|
|
2024-03-14 23:11:51 +01:00
|
|
|
PORT ?= 8082
|
|
|
|
ADDR ?=
|
2024-06-22 00:50:15 +02:00
|
|
|
bin/token-handler: tools/token-handler.cr; $(Q)shards build token-handler $(OPTS)
|
|
|
|
build-token-handler: bin/token-handler
|
|
|
|
run-token-handler: bin/token-handler; $(Q)./bin/token-handler $(PORT) $(ADDR)
|
2023-06-15 20:14:27 +02:00
|
|
|
|
2024-03-12 21:51:59 +01:00
|
|
|
build: build-server build-client build-token-handler
|
2023-06-15 13:06:55 +02:00
|
|
|
|
2024-06-22 00:50:15 +02:00
|
|
|
print-messages:; cat src/requests/*.cr | ./bin/get-messages.awk
|
|
|
|
print-message-numbers:; make -s print-messages | grep -E "^[0-9]" | sort -n
|
|
|
|
print-messages-no-comments:; make -s print-messages | grep -vE '^[[:blank:]]+#'
|
|
|
|
print-response-messages:; cat src/responses/*.cr | ./bin/get-messages.awk
|
|
|
|
print-response-message-numbers:; make -s print-response-messages | grep -E "^[0-9]" | sort -n
|
|
|
|
print-response-messages-no-comments:; make -s print-response-messages | grep -vE '^[[:blank:]]+#'
|
2023-07-07 20:23:06 +02:00
|
|
|
|
2024-06-14 16:16:04 +02:00
|
|
|
# format: nb-domains <TAB> login <TAB> domain1 <TAB> domain2 <TAB> domain3
|
|
|
|
MIGRATION_FILE_TARGET = /tmp/dnsmanagerd-migration
|
|
|
|
SQLDB = /tmp/usrdb
|
2024-06-30 17:37:05 +02:00
|
|
|
POWERDNS_ZONEDIR = /var/powerdns
|
|
|
|
BINDDIR = /tmp/DATA-dnsmanagerd/bind9-zones
|
2024-06-14 16:16:04 +02:00
|
|
|
$(MIGRATION_FILE_TARGET):; ./bin/sql-to-migration-format.awk < $(SQLDB) > $(MIGRATION_FILE_TARGET)
|
2024-06-10 03:29:26 +02:00
|
|
|
run-migration-client:; ./bin/dnsmanager-client admin migration-script $(MIGRATION_FILE_TARGET) $(LOGIN)
|
2024-06-14 16:16:04 +02:00
|
|
|
migration-file: $(MIGRATION_FILE_TARGET)
|
2024-06-30 17:37:05 +02:00
|
|
|
copy-old-zones: ; cd $(BINDDIR) && for i in * ; do cp -v /tmp/rndczones/$$i . ; done
|
|
|
|
/tmp/rndczones:
|
|
|
|
@echo "you forgot to get a copy of old bind zones here: /tmp/rndczones"
|
|
|
|
exit 1
|
|
|
|
powerdns-create-zonedir:
|
|
|
|
-mkdir -p $(POWERDNS_ZONEDIR)
|
|
|
|
cp -v $(BINDDIR)/* $(POWERDNS_ZONEDIR)
|
|
|
|
powerdns-add-zones: powerdns-create-zonedir
|
|
|
|
cd $(POWERDNS_ZONEDIR) && for i in *; do pdns_control bind-add-zone $$i $(POWERDNS_ZONEDIR)/$$i; done
|
|
|
|
migration: build-client migration-file run-migration-client run-client-genzones copy-old-zones
|
2024-07-01 11:09:45 +02:00
|
|
|
@echo "next as root: make powerdns-add-zones"
|
2024-06-10 03:29:26 +02:00
|
|
|
|
|
|
|
doc:
|
|
|
|
crystal docs src/main.cr src/client.cr lib/authd/src/client.cr
|
|
|
|
|
2024-06-22 00:50:15 +02:00
|
|
|
HTTPD_ACCESS_LOGS ?= /tmp/access-dnsmanager-docs.log
|
2024-06-10 03:29:26 +02:00
|
|
|
HTTPD_ADDR ?= 127.0.0.1
|
|
|
|
HTTPD_PORT ?= 9001
|
|
|
|
DIR ?= docs
|
|
|
|
serve-doc:
|
|
|
|
darkhttpd $(DIR) --addr $(HTTPD_ADDR) --port $(HTTPD_PORT) --log $(HTTPD_ACCESS_LOGS)
|
|
|
|
|
2024-03-17 23:05:50 +01:00
|
|
|
wipe-db:
|
2023-07-07 20:23:06 +02:00
|
|
|
rm -r $(DBDIR)
|
2024-03-17 23:05:50 +01:00
|
|
|
|
|
|
|
release:
|
2024-06-01 03:35:53 +02:00
|
|
|
make build-server OPTS="--release --progress --no-debug"
|