react-project/portainer/gen-admin-passwd.sh

19 lines
505 B
Bash
Raw Permalink Normal View History

2024-02-28 12:42:50 +02:00
#!/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"