diff --git a/htpasswd.sh b/htpasswd.sh new file mode 100755 index 0000000..ba27130 --- /dev/null +++ b/htpasswd.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function usage { + echo "./htpasswd.sh " +} + +if [ $1 ]; then + USER=$1 +else + USER=$(whoami) +fi + +SUCCESS=1 +while [ $SUCCESS -ne 0 ]; do + PASSWD=$(openssl passwd -apr1) + if [ $? -eq 0 ]; then + SUCCESS=0 + fi +done + +if [ $2 ]; then + FILE=$2 + if [ $FILE ]; then + echo "$USER:$PASSWD" >> $FILE + fi +else + echo "$USER:$PASSWD" +fi + +exit 0