Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prompt for command-line input #30

Closed
drewda opened this issue Jul 11, 2012 · 4 comments
Closed

prompt for command-line input #30

drewda opened this issue Jul 11, 2012 · 4 comments

Comments

@drewda
Copy link

drewda commented Jul 11, 2012

In the set of deploy scripts I currently use for most Rails projects I have Capistrano prompt for a password to insert into the database.yml file that will go on the server.

Here's the tutorial I originally followed: http://www.simonecarletti.com/blog/2009/06/capistrano-and-database-yml/ and here's the Cap command: Capistrano::CLI.ui.ask("Enter MySQL database password: ")

Before attempting to build a helper method like this for Mina I figured I'd just ask if anyone else has attempted this or has other preferred methods of getting passwords into config files.

(By the way, a big thanks to the folks who have been working on Mina. It's such a clean and well-documented library in comparison with Capistrano!)

@stas
Copy link

stas commented Jul 11, 2012

I'm not sure how this can fit into:

It generates an entire procedure as a Bash script and runs it remotely in the server.

All you need is probably

puts 'Enter MySQL database password: '
passwd = gets.strip

@rstacruz
Copy link
Member

@stas is correct, you may even want to try the highline gem for password input.

@drewda
Copy link
Author

drewda commented Jul 12, 2012

Thank you, @stas and @rstacruz! I'll give your suggestions a try.

@danielstockton
Copy link

The highline gem works well, as in the following example:

require 'highline/import'
ask "PostgreSQL password:" do |password|
    queue! %Q{sudo -u postgres psql -c "create user #{psql_user} with password '#{password}';"}
    queue! %Q{sudo -u postgres psql -c "create database #{app_name} owner #{psql_user};"}
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants