From b9b130e0086e59e134da5e5d5319efa6d13615e7 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sun, 17 Nov 2024 18:07:32 +0100 Subject: [PATCH] Migration makefile. --- makefile | 8 ++------ migration.mk | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 migration.mk diff --git a/makefile b/makefile index f155f5c..cc8b326 100644 --- a/makefile +++ b/makefile @@ -43,12 +43,6 @@ register:; $(Q)./bin/authc user register $(NAME) $(EMAIL) validate:; $(Q)./bin/authc user validate $(NAME) $(ACTIVATION_KEY) 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' RESOURCE ?= '*' UID ?= 1000 @@ -89,3 +83,5 @@ wipe-db: release: make build-server OPTS="--progress --release" + +-include migration.mk diff --git a/migration.mk b/migration.mk new file mode 100644 index 0000000..40463cd --- /dev/null +++ b/migration.mk @@ -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