1
1
Fork 0

added htpasswd.sh

This commit is contained in:
david 2021-09-13 13:20:05 +02:00
parent b528232bd2
commit 89e5a2a948
1 changed files with 30 additions and 0 deletions

30
htpasswd.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
function usage {
echo "./htpasswd.sh <username> <file>"
}
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