useful makefiles for dnsmanager deployment

master
Philippe Pittoli 2024-11-21 02:49:51 +01:00
commit 9745a1e9f3
5 changed files with 115 additions and 0 deletions

5
all.mk Normal file
View File

@ -0,0 +1,5 @@
-include ./mk/local.mk
-include ./mk/dev.mk
-include ./mk/ws.mk
-include ./mk/authd.mk
-include ./mk/dnsmanagerd.mk

28
authd.mk Normal file
View File

@ -0,0 +1,28 @@
ADMIN_NAME ?= dnsmanager
create-admin-account:
@echo "SETUP ACCOUNT: dnsmanager"
cd $(DIR_AUTHD) && make add-first-user NAME=$(ADMIN_NAME) EMAIL='root@localhost'
create-user-account:
@echo "SETUP ACCOUNT: karchnu"
cd $(DIR_AUTHD) && make add-user NAME=karchnu EMAIL=karchnu@karchnu.fr LOGIN=$(ADMIN_NAME)
UID ?= 0
setup-dnsmanagerd-admin-permissions:
[ "$(UID)" = "0" ] && echo "Error: default UID, please change the UID variable" && exit 1
@echo "SETUP permissions: admin on 'dnsmanager' '*' to user-id $(UID)"
@echo "(this can be setup with the UID var)"
cd $(DIR_AUTHD) && make permission-set UID=$(UID) SERVICE="dnsmanager" RESOURCE='\*' PERMISSION="Admin" LOGIN=$(ADMIN_NAME)
setup-dnsmanagerd-admin-permissions-dnsmanager:
@echo "SETUP dnsmanagerd administrator account permissions in authd (account named 'dnsmanager', UID 1000)"
@#make setup-dnsmanagerd-admin-permissions UID=1000
cd $(DIR_AUTHD) && make permission-set UID=1000 SERVICE="dnsmanager" RESOURCE='\*' PERMISSION="Admin" LOGIN=$(ADMIN_NAME)
setup-a-few-accounts: create-admin-account create-user-account setup-dnsmanagerd-admin-permissions-dnsmanager
# The two most useful rules.
setup-admin-account: create-admin-account setup-dnsmanagerd-admin-permissions-dnsmanager
run-authd:
cd $(DIR_AUTHD) && make run-authd

52
dev.mk Normal file
View File

@ -0,0 +1,52 @@
DIR ?= ~/tmp/
REPOSITORY_HOST = ssh://_gitea@$(BAGUETTE)
DIR_WEBCLIENT = $(DIR)/webclient
DIR_DNSMANAGER = $(DIR)/dnsmanager
DIR_AUTHD = $(DIR)/authd
DIR_PARSER = $(DIR)/parser
setup-dev-env: $(DIR) clone-repos checkouts build
@echo 'Next steps:'
@echo '1. setup authd: "make run-authd" then "make setup-a-few-accounts"'
@echo '2. setup dnsmanagerd: "make run-dnsmanagerd"'
@echo '3. setup websocket proxies: "make init-ws-auth" and "make init-ws-dnsmanager"'
@echo '4. serve the website: "make server-website" and eventually "make serve-doc"'
$(DIR):
mkdir -p $(DIR)
serve-website:
-cd $(DIR)/webclient && make serve
serve-doc:
-cd $(DIR)/webclient && make serve-doc
# History.
#checkout-dev:
# @#-cd $(DIR)/dnsmanager-interface && git checkout -b dev && git pull --set-upstream origin dev
# -cd $(DIR)/halogen-websocket-ipc-playzone && git checkout -b dev && git pull --set-upstream origin dev
# @#git clone $(REPOSITORY_HOST)/Baguette/libipc-examples.git
# @#git clone $(REPOSITORY_HOST)/karchnu/dnsmanager-interface.git
# @#git clone $(REPOSITORY_HOST)/karchnu/halogen-websocket-ipc-playzone.git
# @#-cd $(DIR)/dnsmanager-interface && make
# @#-cd $(DIR)/halogen-websocket-ipc-playzone && make bundle
checkouts:
-cd $(DIR_WEBCLIENT) && git checkout caa
-cd $(DIR_AUTHD) && git checkout migration
-cd $(DIR_DNSMANAGER) && git checkout migration
clone-repos-parser:
git clone $(REPOSITORY_HOST)/Baguette/parser.git $(DIR_PARSER)
clone-repos: clone-repos-parser
git clone $(REPOSITORY_HOST)/Baguette/dnsmanager-webclient.git $(DIR_WEBCLIENT)
git clone $(REPOSITORY_HOST)/Baguette/dnsmanager.git $(DIR_DNSMANAGER)
git clone $(REPOSITORY_HOST)/Baguette/authd.git $(DIR_AUTHD)
build:
-cd $(DIR_DNSMANAGER) && make
-cd $(DIR_AUTHD) && make && make build-client
-cd $(DIR_WEBCLIENT) && make bundle

20
dnsmanagerd.mk Normal file
View File

@ -0,0 +1,20 @@
tdir=$(DIR_DNSMANAGER)/templates/
a=example.com
b=netlib.re
c=codelib.re
build-template-zones:
[ ! -f $(tdir)$(a).json ] &&\
cd $(DIR_DNSMANAGER) &&\
make zone-basic-template-file DOMAIN=$(a) &&\
mv $(a).json templates/ || :
[ ! -f $(tdir)$(b).json ] &&\
cd $(DIR_DNSMANAGER) &&\
make zone-basic-template-file DOMAIN=$(b) &&\
mv $(b).json templates/ || :
[ ! -f $(tdir)$(c).json ] &&\
cd $(DIR_DNSMANAGER) &&\
make zone-basic-template-file DOMAIN=$(c) &&\
mv $(c).json templates/ || :
run-dnsmanagerd: build-template-zones
cd $(DIR_DNSMANAGER) && make run-dnsmanagerd

10
ws.mk Normal file
View File

@ -0,0 +1,10 @@
WS_PORT ?= 8080
WS_SERVICE ?= 127.0.0.1:$(WS_PORT)
WS_TARGET_SERVICE ?= pong
WS_TARGET ?= unix:/tmp/.libipc-run/$(WS_TARGET_SERVICE)
init-websocket-tcpd:
@# '-b' binary, '-E' quit on end-of-file, 'ws-l' websocket URI to listen
@# each connection is redirected to last parameter
websocat -b -E ws-l:$(WS_SERVICE) $(WS_TARGET)