Sha256: 9176f89c3762c1cc5141e3d02479c25b8dd1e1b031f87eb105cc4b1d69085363

Contents?: true

Size: 1.79 KB

Versions: 51

Compression:

Stored size: 1.79 KB

Contents

# See http://sambala.rubyforge.org/ruby-doc/
module Publisher
  class Samba
    attr_accessor :samba_share
    attr_accessor :samba_mountpoints
    attr_accessor :worker

    def copy(source, target, options={})
      Helper.validates_presence_of samba_mountpoints, "Samba mountpoints not set"
      Helper.validates_presence_of samba_share, "Samba Share not set"

      begin
        begin
          # mount
          worker.samba_mount(samba_share,"#{samba_mountpoints}/#{samba_share}")

          to = "#{samba_mountpoints}/#{samba_share}/#{target}"
          ### create target directory
          if not File.directory?(to)
            if not FileUtils.mkdir_p(to)
              $log.writer.error "Unable to create target directory #{to}"
              exit 1
            end
          end

          # local rsync
          shell_cmd = "rsync -a --delete #{source} #{to}"
          $log.writer.debug "Execute command: #{shell_cmd}"
          output = system shell_cmd
          if not output
            $log.writer.error "#{method} #{shell_cmd} failed"
            exit 1
          end
          $log.writer.info output

          # umount
          worker.samba_umount("#{samba_mountpoints}/#{samba_share}")

        rescue Exception => e
          $log.writer.error "Can not publish files using samba"
          $log.writer.error e.message
          $log.writer.error e.backtrace.join("\n")
          worker.samba_umount("#{samba_mountpoints}/#{samba_share}")
          exit 1
        end

      rescue Exception => e
        $log.writer.error "Can not upload files to #{target}"
        $log.writer.error e.message
        $log.writer.error e.backtrace.join("\n")
        exit 1
      end

    end

    def chmod(path, permissions, options={})
      $log.writer.fatal "Not yet implemented"
      exit 1
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
depengine-3.0.20 lib/depengine/publisher/samba.rb
depengine-3.0.19 lib/depengine/publisher/samba.rb
depengine-3.0.18 lib/depengine/publisher/samba.rb
depengine-3.0.17 lib/depengine/publisher/samba.rb
depengine-3.0.16 lib/depengine/publisher/samba.rb
depengine-3.0.15 lib/depengine/publisher/samba.rb
depengine-3.0.14 lib/depengine/publisher/samba.rb
depengine-3.0.13 lib/depengine/publisher/samba.rb
depengine-3.0.12 lib/depengine/publisher/samba.rb
depengine-3.0.11 lib/depengine/publisher/samba.rb
depengine-3.0.10 lib/depengine/publisher/samba.rb
depengine-3.0.9 lib/depengine/publisher/samba.rb
depengine-3.0.8 lib/depengine/publisher/samba.rb
depengine-3.0.7 lib/depengine/publisher/samba.rb
depengine-3.0.6 lib/depengine/publisher/samba.rb
depengine-3.0.5 lib/depengine/publisher/samba.rb
depengine-3.0.4 lib/depengine/publisher/samba.rb
depengine-3.0.3 lib/depengine/publisher/samba.rb
depengine-3.0.2 lib/depengine/publisher/samba.rb
depengine-3.0.1 lib/depengine/publisher/samba.rb