Module: Exec

Included in:
Freydis::Cryptsetup, Freydis::Rsync
Defined in:
lib/mods/exec.rb

Instance Method Summary collapse

Instance Method Details

#bsdtar(args) ⇒ Object



21
22
23
# File 'lib/mods/exec.rb', line 21

def bsdtar(args)
  x "bsdtar #{args}"
end

#mkdir(dir) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/mods/exec.rb', line 13

def mkdir(dir)
  if Process.uid == 0
    FileUtils.mkdir_p dir
  else
    x "mkdir -p #{dir}"
  end
end

#shred(*keys) ⇒ Object



25
26
27
28
# File 'lib/mods/exec.rb', line 25

def shred(*keys)
  keys_join = keys * ' '
  x "shred -u #{keys_join}"
end

#x(command) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/mods/exec.rb', line 4

def x(command)
  sudo = Process.uid != 0 ? 'sudo' : ''
  cmd = "#{sudo} #{command}"
  unless system(cmd)
    warn "[-] Execute: #{cmd}"
    exit 1
  end
end