-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate.rb
47 lines (40 loc) · 1.04 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env ruby
def wait_for_enter
gets.chomp
end
def create_ssh_keypair(username)
puts 'Run:'
puts " ssh-keygen -t rsa -f ~/#{username}"
wait_for_enter
end
def git_commit(username)
puts 'Copy ~/new_key.pub into the `user_keys` Git repository, then run:'
puts " git commit #{username}"
puts ' git push'
wait_for_enter
end
def wait_for_build
build_url = 'http://example.com/builds/user_keys'
puts "Wait for the build job at #{build_url} to finish"
wait_for_enter
end
def retrieve_user_email(username)
dir_url = 'http://example.com/directory'
puts "Go to #{dir_url}"
puts "Find the email address for user `#{username}`"
puts 'Paste the email address and press enter: '
gets.chomp
end
def send_private_key(email)
puts 'Go to 1Password'
puts 'Paste the contents of ~/new_key into a new document'
puts "Share the document with #{email}"
wait_for_enter
end
username = ARGV[0]
create_ssh_keypair(username)
git_commit(username)
wait_for_build
email = retrieve_user_email(username)
send_private_key(email)
puts 'Done.'