Class: Specinfra::Command::Darwin::Base::Group

Inherits:
Base::Group show all
Defined in:
lib/specinfra/command/darwin/base/group.rb

Class Method Summary collapse

Methods inherited from Base::Group

check_exists, check_has_gid, check_is_system_group

Methods inherited from Base

create, escape

Class Method Details

.add(group, options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/specinfra/command/darwin/base/group.rb', line 11

def add(group, options)
  group_name = escape(group)
                  
  record_path = "/Groups/#{group_name}"
  dscl_create = "dscl . -create #{record_path}"
  command = [dscl_create]
  command << "#{dscl_create} PrimaryGroupID #{escape(options[:gid])}"    if options[:gid]
  command << "#{dscl_create} RecordName #{escape(options[:groupname])}"  if options[:groupname]
  command.join(' && ')
end

.get_gid(group) ⇒ Object



4
5
6
# File 'lib/specinfra/command/darwin/base/group.rb', line 4

def get_gid(group)
  "dscl . -read /Groups/#{escape(group)} PrimaryGroupID | awk '{ print $2 }'" 
end

.update_gid(group, gid) ⇒ Object



8
9
10
# File 'lib/specinfra/command/darwin/base/group.rb', line 8

def update_gid(group, gid)
  "dscl . -create /Groups/#{escape(group)} PrimaryGroupID #{escape(gid)}"
end