Sha256: 8d8b4a2a5d743c1fffdf736f1c1b832fef4d89445c947f4bf589aed771b610b4

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

module Helper
  class Smb
    attr_accessor :remote_path
    attr_accessor :local_path

    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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
depengine-3.0.23 lib/depengine/helper/smb.rb
depengine-3.0.22 lib/depengine/helper/smb.rb
depengine-3.0.21 lib/depengine/helper/smb.rb