48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/yorobot.rb', line 48
def step_adduser
ssh_key = ENV['SSH_KEY']
if ssh_key.nil?
STDERR.puts "!! ERROR - required SSH_KEY env(ironment) variable missing"
exit 1
end
ssh_path = File.expand_path( '~/.ssh' )
if File.exist?( "#{ssh_path}/id_ed25519" )
STDERR.puts "!! ERROR - ssh key >#{ssh_path}/id_ed25519< already exists"
exit 1
end
FileUtils.mkdir_p( ssh_path ) unless Dir.exist?( ssh_path )
puts "--> writing ssh key to >#{ssh_path}/id_ed25519<..."
File.open( "#{ssh_path}/id_ed25519", 'w:utf-8' ) do |f|
f.write( ssh_key )
end
Computer::Shell.run( %Q{chmod 600 #{ssh_path}/id_ed25519} )
Computer::Shell.run( %Q{ls -la #{ssh_path}} )
Git.version
user_name = ENV['YOROBOT_NAME'] || ENV['YO_NAME'] || 'Yo Robot'
user_email = ENV['YOROBOT_EMAIL'] || ENV['YO_EMAIL'] || 'gerald.bauer+yorobot@gmail.com'
Computer::Shell.run( %Q{git config --global user.name "#{user_name}"} )
Computer::Shell.run( %Q{git config --global user.email "#{user_email}"} )
Computer::Shell.run( %Q{git config -l --show-origin} )
end
|