From c430d8eaf1d091ad27e842c0000b77d87d791da6 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 21 Apr 2022 22:57:55 +0200 Subject: Start refactor --- os/secretgen/passwd | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 os/secretgen/passwd (limited to 'os/secretgen/passwd') diff --git a/os/secretgen/passwd b/os/secretgen/passwd new file mode 100755 index 0000000..7cc80b6 --- /dev/null +++ b/os/secretgen/passwd @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +cd $(dirname $0) + +function usage { + echo "Usage: $0 " + echo "The cluster name must be the name of a subdirectory of cluster/" + exit 1 +} + +CLUSTER="$1" +if [ -z "$CLUSTER" ] || [ ! -d "cluster/$CLUSTER" ]; then + usage +fi + +USERNAME="$2" +if [ -z "$USERNAME" ]; then + usage +fi + +PREFIX="deuxfleurs/cluster/$CLUSTER" + +if ! EXISTING_PASSWORDS=$(pass $PREFIX/passwords | egrep -v "^$USERNAME:"); then + EXISTING_PASSWORDS="" +fi + +echo "Enter new password for user $USERNAME:" +NEW_PASSWD=$(openssl passwd -6) + +(echo $EXISTING_PASSWORDS; echo $USERNAME:$NEW_PASSWD) | pass insert -m $PREFIX/passwords -- cgit v1.2.3