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.



6
7
8
# File 'lib/depengine/helper/smb.rb', line 6

def local_path
  @local_path
end

#remote_pathObject

Returns the value of attribute remote_path.



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

def remote_path
  @remote_path
end

Instance Method Details

#samba_mountObject



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

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!)
  if File.stat('/').dev == File.stat(local_path).dev
    # Have to mount

    #### create mountpoint directory
    if not File.directory?(local_path)
      if not 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
    if not output
      $log.writer.error "#{shell_cmd} failed"
      exit 1
    end
  end
end

#samba_umountObject



36
37
38
39
# File 'lib/depengine/helper/smb.rb', line 36

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