Sha256: b2197ed5850906ad8e16e6d9c7bb2f7c3b61155bd3823d84981f7befc461f46a
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
class Account include DataMapper::Resource property :id, Serial belongs_to :user belongs_to :server def add_user self.server.execute_command("sudo /usr/sbin/useradd -m #{self.user.name}") end def add_ssh_directory self.server.execute_command("sudo mkdir #{self.user.ssh_config_directory_path}") self.server.execute_command("sudo chown #{self.user.name} #{user.ssh_config_directory_path}") self.server.execute_command("sudo chmod 700 #{self.user.ssh_config_directory_path}") end def write_ssh_key self.server.execute_command("sudo touch #{self.user.authorized_keys_file_path}") self.server.execute_command("echo '#{self.user.authorized_keys_file}' | sudo tee #{self.user.authorized_keys_file_path}") self.set_ssh_key_permissions end def add_to_groups self.server.execute_command("sudo /usr/sbin/usermod -a -G #{self.user.groups.collect(&:name).join(',')} #{self.user.name}") end protected def set_ssh_key_permissions self.server.execute_command("sudo chown #{self.user.name} #{self.user.authorized_keys_file_path}") self.server.execute_command("sudo chmod 600 #{self.user.authorized_keys_file_path}") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fabric-0.4.4 | lib/fabric/account.rb |
fabric-0.4.2 | lib/fabric/account.rb |