added htpasswd.sh
This commit is contained in:
parent
b528232bd2
commit
89e5a2a948
|
@ -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
|
Loading…
Reference in New Issue