refactor bin/setup_heroku so button users get admin accounts

This commit is contained in:
Andrew Cantino 2014-09-22 22:19:49 -07:00
parent ab82683216
commit ca0234b02d
2 changed files with 31 additions and 21 deletions

View file

@ -15,7 +15,7 @@
<ul>
<li>Read <a href="https://github.com/cantino/huginn/wiki/Run-Huginn-for-free-on-Heroku" target="_target">this document</a> carefully if you are going to try out Huginn for free on <a href="https://id.heroku.com/" target="_target">Heroku</a>.</li>
<li>Install the <a href="https://toolbelt.heroku.com/" target="_target">Heroku Toolbelt</a> and run <kbd>heroku login</kbd> if you haven't already.</li>
<li>Install the <a href="https://toolbelt.heroku.com/" target="_target">Heroku Toolbelt</a> and run <kbd>heroku login</kbd>, if you haven't already.</li>
<li>Run the following commands:<br />
<%= content_tag :pre do -%>
@ -25,7 +25,7 @@ bundle
bin/setup_heroku
<%- end %>
<li>Get back to this page and sign up with the invitation code shown by the last command.</li>
<li>This command will create an admin account for you.</li>
</ul>
</div>
<% end %>
@ -78,4 +78,4 @@ bin/setup_heroku
</div>
</div>
</div>
</div>
</div>

View file

@ -138,19 +138,6 @@ unless $config['SMTP_DOMAIN'] && $config['SMTP_USER_NAME'] && $config['SMTP_PASS
end
end
if first_time
puts "Restarting..."
puts capture("heroku restart")
puts "Done!"
puts
puts "Visit https://#{app_name}.herokuapp.com/users/sign_up and use the invitation code shown below:"
puts
puts "\t#{$config['INVITATION_CODE']}"
exit
end
branch = capture("git rev-parse --abbrev-ref HEAD")
if yes?("Should I push your current branch (#{branch}) to heroku?")
puts "This may take a moment..."
@ -158,21 +145,44 @@ if yes?("Should I push your current branch (#{branch}) to heroku?")
puts "Running database migrations..."
puts capture("heroku run rake db:migrate")
end
if first_time
puts "Restarting..."
puts capture("heroku restart")
puts "Done!"
puts
puts
puts "I can make an admin user on your new Huginn instance and setup some example Agents."
if yes?("Should I create a new admin user and some example Agents?")
seed_email = nag "Okay, what is your email address?"
seed_username = nag "And what username would you like to login as?"
seed_password = nag "Finally, what password would you like to use?", noecho: true
puts "\nJust a moment..."
done = false
while !done
seed_email = nag "Okay, what is your email address?"
seed_username = nag "And what username would you like to login as?"
seed_password = nag "Finally, what password would you like to use?", noecho: true
puts "\nJust a moment..."
capture("heroku run rake db:seed SEED_EMAIL=#{seed_email} SEED_USERNAME=#{seed_username} SEED_PASSWORD=#{seed_password}")
result = capture("heroku run rake db:seed SEED_EMAIL=#{seed_email} SEED_USERNAME=#{seed_username} SEED_PASSWORD=#{seed_password}")
if result =~ /Validation failed/
puts "ERROR:"
puts
puts result
puts
else
done = true
end
end
puts
puts
puts "Okay, you should be all set! Visit https://#{app_name}.herokuapp.com and login as '#{seed_username}' with your password."
puts
puts "If you'd like to make more users, you can visit https://#{app_name}.herokuapp.com/users/sign_up and use the invitation code:"
else
puts
puts "Visit https://#{app_name}.herokuapp.com/users/sign_up and use the invitation code shown below:"
end
puts
puts "\t#{$config['INVITATION_CODE']}"
end
puts