I have a script which I run on halt which backs up the SQL databases of the vagrant machine. I'd like to ask the user for the MySQL password rather than store it in the script. My question is: Is there a way to run scripts on the VM interactively?
My halt script is:
read -s -p "Please enter the MySQL root password: " mysqlRootPassword
while ! mysql -u root -p$mysqlRootPassword -e ";" ; do
read -p "Can't connect, please retry: " mysqlRootPassword
done
mysqldump -uroot -p"$mysqlRootPassword" "mydb" > /var/www/vagrant/backup/database/mydb.sql
And my trigger is:
config.trigger.before :halt do
run_remote "bash /var/www/vagrant/triggers/vagrant_halt"
end
The script triggers correctly but it repeatedly asks for the password without letting me type anything. I just get a stream of Error: Access denied ... Enter Password: messages and all I can do is press ctrl-c to force quit.
Hi. Thanks for the great plugin.
I have a script which I run on
halt
which backs up the SQL databases of the vagrant machine. I'd like to ask the user for the MySQL password rather than store it in the script. My question is: Is there a way to run scripts on the VM interactively?My halt script is:
And my trigger is:
The script triggers correctly but it repeatedly asks for the password without letting me type anything. I just get a stream of
Error: Access denied ... Enter Password:
messages and all I can do is pressctrl-c
to force quit.Any advice would be much appreciated!