Class: Flow::Base
- Inherits:
-
Object
- Object
- Flow::Base
- Defined in:
- lib/yorobot.rb
Instance Method Summary collapse
-
#step_adduser ⇒ Object
# check ssh if [ ! -d ~/.ssh ]; then mkdir ~/.ssh; fi echo “$SSH_KEY” > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa echo “ssh directory - ~/.ssh:” ls -la ~/.ssh # ssh -vT [email protected].
Instance Method Details
#step_adduser ⇒ Object
# check ssh
if [ ! -d ~/.ssh ]; then mkdir ~/.ssh; fi
echo "$SSH_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "ssh directory - ~/.ssh:"
ls -la ~/.ssh
# ssh -vT [email protected]
# check git
git --version
git config --global user.name "Yo Robot"
git config --global user.email "[email protected]"
git config -l --show-origin
39 40 41 42 43 44 45 46 47 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 |
# File 'lib/yorobot.rb', line 39 def step_adduser ############## ## setup ssh 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.( '~/.ssh' ) if File.exist?( "#{ssh_path}/id_rsa" ) STDERR.puts "!! ERROR - ssh key >#{ssh_path}/id_rsa< already exists" exit 1 end ## make sure path exists FileUtils.mkdir_p( ssh_path ) unless Dir.exist?( ssh_path ) puts "--> writing ssh key to >#{ssh_path}/id_rsa<..." File.open( "#{ssh_path}/id_rsa", 'w:utf-8' ) do |f| f.write( ssh_key ) end ## note: ssh key must be "private" only access by owner (otherwise) WILL NOT work ## res = File.chmod( 0600, "#{ssh_path}/id_rsa" ) ## puts res ## returns number of files processed; should be 1 - assert - why? why not? Computer::Shell.run( %Q{chmod 600 #{ssh_path}/id_rsa} ) Computer::Shell.run( %Q{ls -la #{ssh_path}} ) # ssh -vT [email protected] ##### ## setup git ## git --version Git.version user_name = ENV['YOROBOT_NAME'] || ENV['YO_NAME'] || 'Yo Robot' user_email = ENV['YOROBOT_EMAIL'] || ENV['YO_EMAIL'] || '[email protected]' 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 |