diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2023-02-21 20:38:05 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2023-02-21 20:38:05 +0900 |
commit | ee31e594c9810e914d048e68143babf0750580cd (patch) | |
tree | c372a4c2f7a4305a1288c5f7239073667cf73933 | |
parent | 867177bdd1deb000d17090af9f5a1967ee91b71a (diff) | |
download | nixos-conf-ee31e594c9810e914d048e68143babf0750580cd.tar.gz |
Make bcrypt script more user friendly
-rw-r--r-- | irc.nix | 21 | ||||
-rw-r--r-- | 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"; } ]; }; }; |