From 3a224f2111c6024f29e4c77c10a778c7382ca3a3 Mon Sep 17 00:00:00 2001 From: inexcode Date: Wed, 6 Apr 2022 15:50:45 +0300 Subject: [PATCH] Decode password from base64 --- nixos-infect | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nixos-infect b/nixos-infect index b820f41..c759267 100755 --- a/nixos-infect +++ b/nixos-infect @@ -5,9 +5,14 @@ set -e -o pipefail makeConf() { - export HASHED_PASSWORD=$( mkpasswd -m sha-512 "$PASSWORD" ) # Skip everything if main config already present [[ -e /etc/nixos/configuration.nix ]] && return 0 + if [[ $PASSWORD == null ]]; then + export PASSWORD=$(printf $ENCODED_PASSWORD | base64 --decode) + + export ESCAPED_PASSWORD=$(printf $ENCODED_PASSWORD | base64 --decode | jq -Rs .) + export HASHED_PASSWORD=$( mkpasswd -m sha-512 "$PASSWORD" ) + # NB <<"EOF" quotes / $ ` in heredocs, <