Class: Bard::Provision::User
- Inherits:
-
Bard::Provision
- Object
- Struct
- Bard::Provision
- Bard::Provision::User
- Defined in:
- lib/bard/provision/user.rb
Overview
rename user
Instance Attribute Summary
Attributes inherited from Bard::Provision
Instance Method Summary collapse
Methods inherited from Bard::Provision
Instance Method Details
#call ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bard/provision/user.rb', line 4 def call print "User:" if !ssh_with_user?(provision_server.ssh_uri, user: new_user) if !ssh_with_user?(provision_server.ssh_uri) raise "can't ssh in with user #{new_user} or #{old_user}" end print " Adding user #{new_user}," provision_server.run! [ "sudo useradd -m -s /bin/bash #{new_user}", "sudo usermod -aG sudo #{new_user}", "echo \"#{new_user} ALL=(ALL) NOPASSWD:ALL\" | sudo tee -a /etc/sudoers", "sudo mkdir -p ~#{new_user}/.ssh", "sudo cp ~/.ssh/authorized_keys ~#{new_user}/.ssh/authorized_keys", "sudo chown -R #{new_user}:#{new_user} ~#{new_user}/.ssh", "sudo chmod +rx ~#{new_user}", # so nginx and passenger can read it ].join("; "), home: true end # provision with new user from now on ssh_url.gsub!("#{old_user}@", "#{new_user}@") puts " ✓" end |