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

Inherits:
Specinfra::Command::Base show all
Defined in:
lib/specinfra/command/base/group.rb

Direct Known Subclasses

Aix::Base::Group, Solaris::Base::Group

Class Method Summary collapse

Methods inherited from Specinfra::Command::Base

create, escape

Class Method Details

.add(group, options) ⇒ Object


20
21
22
23
24
25
# File 'lib/specinfra/command/base/group.rb', line 20

def add(group, options)
  command = ['groupadd']
  command << '-g' << escape(options[:gid])  if options[:gid]
  command << escape(group)
  command.join(' ')
end

.check_exists(group) ⇒ Object


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

def check_exists(group)
  "getent group #{escape(group)}"
end

.check_has_gid(group, gid) ⇒ Object


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

def check_has_gid(group, gid)
  regexp = "^#{group}"
  "getent group | grep -w -- #{escape(regexp)} | cut -f 3 -d ':' | grep -w -- #{escape(gid)}"
end

.get_gid(group) ⇒ Object


12
13
14
# File 'lib/specinfra/command/base/group.rb', line 12

def get_gid(group)
  "getent group #{escape(group)} | cut -f 3 -d ':'"
end

.update_gid(group, gid) ⇒ Object


16
17
18
# File 'lib/specinfra/command/base/group.rb', line 16

def update_gid(group, gid)
  "groupmod -g #{escape(gid)} #{escape(group)}"
end