Class: Helper::Smb

Inherits:
Object
  • Object
show all
Defined in:
lib/depengine/helper/smb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#local_pathObject

Returns the value of attribute local_path.



4
5
6
# File 'lib/depengine/helper/smb.rb', line 4

def local_path
  @local_path
end

#remote_pathObject

Returns the value of attribute remote_path.



3
4
5
# File 'lib/depengine/helper/smb.rb', line 3

def remote_path
  @remote_path
end

Instance Method Details

#samba_mountObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/depengine/helper/smb.rb', line 6

def samba_mount
  Helper.validates_presence_of remote_path, 'Samba remote_path not set'
  Helper.validates_presence_of local_path, 'Samba mountpoint not set'

  $log.writer.debug "Mount samba share #{remote_path} to #{local_path}"

  # Check if already mounted (heuristik!)
  return unless File.stat('/').dev == File.stat(local_path).dev
  # Have to mount

  #### create mountpoint directory
  unless File.directory?(local_path)
    unless FileUtils.mkdir_p(local_path)
      $log.writer.error "Unable to create mountpoint directory #{local_path}"
      exit 1
    end
  end

  shell_cmd = "/sbin/mount.cifs #{remote_path}  #{local_path}"
  $log.writer.debug "Execute command: #{shell_cmd}"
  output = system(shell_cmd)
  return if output
  $log.writer.error "#{shell_cmd} failed"
  fail "#{shell_cmd} failed"
end

#samba_umountObject



32
33
34
35
# File 'lib/depengine/helper/smb.rb', line 32

def samba_umount
  Helper.validates_presence_of local_path, 'Samba mountpoint not set'
  $log.writer.debug 'Not yet implemented'
end