Method: Specinfra::Command::Freebsd::Base::User.add

Defined in:
lib/specinfra/command/freebsd/base/user.rb

.add(user, options) ⇒ Object


35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/specinfra/command/freebsd/base/user.rb', line 35

def add(user, options)
  command = ['pw', 'user', 'add', escape(user)]
  command << '-g' << escape(options[:gid])            if options[:gid]
  command << '-d' << escape(options[:home_directory]) if options[:home_directory]
  command << '-s' << escape(options[:shell])          if options[:shell]
  command << '-m' if options[:create_home]
  command << '-r' if options[:system_user]
  command << '-u' << escape(options[:uid])            if options[:uid]
  if options[:password]
    command.concat(['&&', 'chpass', '-p', "\'#{options[:password]}\'", escape(user)])
  end
  command.join(' ')
end