Class: Vagabund::Squatter::User
- Inherits:
-
Object
- Object
- Vagabund::Squatter::User
- Defined in:
- lib/vagabund/squatter/user.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#home ⇒ Object
Returns the value of attribute home.
-
#password ⇒ Object
Returns the value of attribute password.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#shell ⇒ Object
Returns the value of attribute shell.
-
#ssh_config ⇒ Object
Returns the value of attribute ssh_config.
-
#sudo ⇒ Object
Returns the value of attribute sudo.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def group @group end |
#groups ⇒ Object
Returns the value of attribute groups.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def groups @groups end |
#home ⇒ Object
Returns the value of attribute home.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def home @home end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def password @password end |
#public_key ⇒ Object
Returns the value of attribute public_key.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def public_key @public_key end |
#shell ⇒ Object
Returns the value of attribute shell.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def shell @shell end |
#ssh_config ⇒ Object
Returns the value of attribute ssh_config.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def ssh_config @ssh_config end |
#sudo ⇒ Object
Returns the value of attribute sudo.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def sudo @sudo end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/vagabund/squatter/user.rb', line 4 def username @username end |
Instance Method Details
#create? ⇒ Boolean
44 45 46 |
# File 'lib/vagabund/squatter/user.rb', line 44 def create? !username.nil? end |
#pubkeys ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vagabund/squatter/user.rb', line 14 def pubkeys unless @public_key.nil? [@public_key].flatten.map do |pubkey| begin File.read(File.(pubkey)).chomp rescue Exception => e pubkey end end.join($/) end end |
#ssh_conf_str ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/vagabund/squatter/user.rb', line 26 def ssh_conf_str unless @ssh_config.nil? begin File.read(File.(@ssh_config)).chomp rescue Exception => e @ssh_config end end end |
#to_s ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/vagabund/squatter/user.rb', line 36 def to_s cmd_str = "useradd -m -s #{shell}" cmd_str += " -d #{home}" cmd_str += " -g #{group}" unless group.nil? cmd_str += " -G #{[groups].flatten.join(',')}" unless groups.nil? cmd_str += " #{username}" end |