blob: 7cc80b6d22733a908fdefc25e5a4170b8e55c4f5 (
plain) (
tree)
|
|
#!/usr/bin/env sh
cd $(dirname $0)
function usage {
echo "Usage: $0 <cluster name> <username>"
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
|