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

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

Class Method Summary collapse

Methods inherited from Specinfra::Command::Base

create, escape

Class Method Details

.add(group, options) ⇒ Object



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

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
# File 'lib/specinfra/command/base/group.rb', line 7

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

.get_gid(group) ⇒ Object



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

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

.update_gid(group, gid) ⇒ Object



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

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