From ee31e594c9810e914d048e68143babf0750580cd Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Tue, 21 Feb 2023 20:38:05 +0900 Subject: Make bcrypt script more user friendly --- irc.nix | 21 ++++++++++++++++++--- matrix.nix | 4 ++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/irc.nix b/irc.nix index e8bdb09..2d03c5c 100644 --- a/irc.nix +++ b/irc.nix @@ -25,9 +25,24 @@ in { name = "sojupw"; text = '' #!/bin/sh - read password - ${pkgs.apacheHttpd}/bin/htpasswd -bnBC 10 "" $password | tr -d ':\n' - echo + printf 'soju password: ' + read -rs password + printf '\nretype soju password: ' + read -rs confirmation + + file=$(mktemp) + trap 'rm $file' EXIT + htpasswd -bBC 10 $file "" $password 2> /dev/null + if htpasswd -bv $file "" $confirmation 2> /dev/null + then + printf '\nbcrypt: ' + cat $file | tr -d ':\n' + echo + exit 0 + else + printf '\nsorry, passwords do not match\n' + exit 1 + fi ''; executable = true; destination = "/bin/${name}"; diff --git a/matrix.nix b/matrix.nix index cdd75cc..b42ca07 100644 --- a/matrix.nix +++ b/matrix.nix @@ -105,8 +105,8 @@ in { postgresql = { ensureDatabases = [ "dendrite" ]; ensureUsers = [ { - name = "dendrite"; - ensurePermissions."DATABASE dendrite" = "ALL PRIVILEGES"; + name = "dendrite"; + ensurePermissions."DATABASE dendrite" = "ALL PRIVILEGES"; } ]; }; }; -- cgit 1.4.1