How would I get my Vagrant shell script to supply the password when creating a user while provisioning phpPgAdmin?
ie. when I supply this command sudo htpasswd -c /etc/phppgadmin/.htpasswd vagrant
it prompts for a password for the vagrant user so I can login to phpPgAdmin. How can I script this into my shell provisioning script that goes with my Vagrantfile?
Best How To :
First, you need to force htpasswd
to read passwords from stdin. It can be done by supplying -i
switch.
Second, you need to pass a string into htpasswd
stdin. This can be achieved in numerous ways. For example you can redirect stdout of echo
into stdin of htpasswd
.
So resulting command would look like this
echo "123456" | htpasswd -i -c /etc/phppgadmin/.htpasswd vagrant