19 lines
505 B
Bash
19 lines
505 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
USERNAME="admin"
|
||
|
PASSWORD="$1"
|
||
|
if [ -z "\${PASSWORD}" ]; then
|
||
|
echo -e "\\nPlease call '\$0 <password>' to run this command!\\n"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
which htpasswd
|
||
|
if [ "$?" -gt "0" ]
|
||
|
then
|
||
|
PASS=$(docker run --entrypoint htpasswd httpd:2 -bn -B ${USERNAME} ${PASSWORD} | cut -d ":" -f 2 )
|
||
|
else
|
||
|
PASS=$(htpasswd -nb -B admin ${PASSWORD} | cut -d ":" -f 2)
|
||
|
fi
|
||
|
|
||
|
echo "plaintext encryption: ${PASS}"
|
||
|
echo "docker-compse.yml escaped: ${PASS}"|sed -e "s@\\\$@\\\$\\\$@g"
|