Fix passwd script

This commit is contained in:
Alex 2022-05-04 16:41:07 +02:00
parent 9cae8c8fc2
commit 72ed2517a9
Signed by: lx
GPG key ID: 0E496D15096376BE

9
passwd
View file

@ -20,11 +20,12 @@ fi
PREFIX="deuxfleurs/cluster/$CLUSTER" PREFIX="deuxfleurs/cluster/$CLUSTER"
if ! EXISTING_PASSWORDS=$(pass $PREFIX/passwords | egrep -v "^$USERNAME:"); then EXISTING_PASSWORDS=$(mktemp)
EXISTING_PASSWORDS="" pass $PREFIX/passwords | egrep -v "^$USERNAME:" > $EXISTING_PASSWORDS
fi
echo "Enter new password for user $USERNAME:" echo "Enter new password for user $USERNAME:"
NEW_PASSWD=$(openssl passwd -6) NEW_PASSWD=$(openssl passwd -6)
(echo $EXISTING_PASSWORDS; echo $USERNAME:$NEW_PASSWD) | pass insert -m $PREFIX/passwords (cat $EXISTING_PASSWORDS; echo $USERNAME:$NEW_PASSWD) | pass insert -m $PREFIX/passwords
rm $EXISTING_PASSWORDS