about summary refs log tree commit diff
path: root/irc.nix
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2023-02-21 20:38:05 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2023-02-21 20:38:05 +0900
commitee31e594c9810e914d048e68143babf0750580cd (patch)
treec372a4c2f7a4305a1288c5f7239073667cf73933 /irc.nix
parent867177bdd1deb000d17090af9f5a1967ee91b71a (diff)
downloadnixos-conf-ee31e594c9810e914d048e68143babf0750580cd.tar.gz
Make bcrypt script more user friendly
Diffstat (limited to 'irc.nix')
-rw-r--r--irc.nix21
1 files changed, 18 insertions, 3 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}";