Module: Pointer::RailsUser
- Included in:
- EasyDeploy
- Defined in:
- lib/pointer/rails_user.rb
Instance Method Summary collapse
- #add_sudo ⇒ Object
- #create_rails_user ⇒ Object
- #delete_rails_user ⇒ Object
- #print_deploy_key ⇒ Object
- #revoke_sudo ⇒ Object
- #upload_public_key ⇒ Object
Instance Method Details
#add_sudo ⇒ Object
30 31 32 33 |
# File 'lib/pointer/rails_user.rb', line 30 def add_sudo sudo_string = "rails ALL = NOPASSWD:ALL" ensure_file_contains('/etc/sudoers', sudo_string) end |
#create_rails_user ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/pointer/rails_user.rb', line 7 def create_rails_user if @ssh.exec!("id rails") =~ /No such user/ expect_empty @ssh.exec!("useradd rails -d /home/#{rails_user} -m -s /bin/bash") expect_empty @ssh.exec!("usermod -a -G sudo rails") what "User created: rails" else what "User exists: rails" end end |
#delete_rails_user ⇒ Object
3 4 5 |
# File 'lib/pointer/rails_user.rb', line 3 def delete_rails_user puts @ssh.exec!("userdel rails -f -r") end |
#print_deploy_key ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/pointer/rails_user.rb', line 39 def print_deploy_key id_rsa = '/home/rails/.ssh/id_rsa' if file_absent(id_rsa) what "Generating ssh key" puts @ssh.exec!("ssh-keygen -q -t rsa -f #{id_rsa} -N ''") end end |
#revoke_sudo ⇒ Object
35 36 37 |
# File 'lib/pointer/rails_user.rb', line 35 def revoke_sudo puts "revoke_sudo is not implemented" end |
#upload_public_key ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pointer/rails_user.rb', line 17 def upload_public_key ssh_dir = "/home/#{rails_user}/.ssh" = ssh_dir + '/authorized_keys' what "Uploading private key" @ssh.exec!("mkdir #{ssh_dir}") ensure_file_contains(, IO.read(File.(public_key))) expect_empty @ssh.exec!("chown rails:rails #{ssh_dir}") expect_empty @ssh.exec!("chown rails:rails #{}") expect_empty @ssh.exec!("chmod 0700 #{ssh_dir}") expect_empty @ssh.exec!("chmod 0600 #{}") end |