File: group.rb

package info (click to toggle)
ruby-specinfra 2.89.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,412 kB
  • sloc: ruby: 10,338; sh: 4; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 778 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Specinfra::Command::Darwin::Base::Group < Specinfra::Command::Base::Group
  class << self

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

    def update_gid(group, gid)
      "dscl . -create /Groups/#{escape(group)} PrimaryGroupID #{escape(gid)}"
    end
    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
  end
end