Migration makefile.

migration
Philippe Pittoli 2024-11-17 18:07:32 +01:00
parent b7a724b5d6
commit b9b130e008
2 changed files with 32 additions and 6 deletions

View File

@ -43,12 +43,6 @@ register:; $(Q)./bin/authc user register $(NAME) $(EMAIL)
validate:; $(Q)./bin/authc user validate $(NAME) $(ACTIVATION_KEY) validate:; $(Q)./bin/authc user validate $(NAME) $(ACTIVATION_KEY)
get-user:; $(Q)./bin/authc user get $(NAME) $(LOGIN_OPT) get-user:; $(Q)./bin/authc user get $(NAME) $(LOGIN_OPT)
USER_DB ?= /tmp/migration-authd-user-db.txt
$(USER_DB): ; ./bin/migration-filter.awk < /tmp/usrdb | grep -a -v "^INVALID" | sort | uniq > $(USER_DB)
migration-file: $(USER_DB)
migrate-user:; ./bin/authc user migrate $(NAME) $(PASSWORD_HASH) $(LOGIN_OPT)
migrate-all-users:; ./bin/authc migration-script $(USER_DB) $(LOGIN_OPT)
SERVICE ?= 'auth' SERVICE ?= 'auth'
RESOURCE ?= '*' RESOURCE ?= '*'
UID ?= 1000 UID ?= 1000
@ -89,3 +83,5 @@ wipe-db:
release: release:
make build-server OPTS="--progress --release" make build-server OPTS="--progress --release"
-include migration.mk

30
migration.mk Normal file
View File

@ -0,0 +1,30 @@
# This is the migration makefile.
#
# WHAT IS NEEDED FOR THE MIGRATION:
#
# - $(SQLDB): a dump of the SQL database (format: login password domain)
#
# HOW MIGRATION WORKS, STEP BY STEP (`migration` rule):
#
# 1. migration-file -> create the $(USER_DB) file
# 2. migrate-all-users -> migrate all user accounts
#
# AFTER THE `migration` RULE: go to the dnsmanagerd repository and follow instructions.
# DB from SQL, format: login password domain
SQLDB ?= /tmp/usrdb
USER_DB ?= /tmp/migration-authd-user-db.txt
$(USER_DB):
./bin/migration-filter.awk < $(SQLDB) | grep -a -v "^INVALID" | sort | uniq > $(USER_DB)
migration-file: $(USER_DB)
migrate-user:
./bin/authc user migrate $(NAME) $(PASSWORD_HASH) $(LOGIN_OPT)
migrate-all-users:
./bin/authc migration-script $(USER_DB) $(LOGIN_OPT)
migration: migration-file migrate-all-users