Class: Publisher::Samba
- Inherits:
-
Object
- Object
- Publisher::Samba
- Defined in:
- lib/depengine/publisher/samba.rb
Instance Attribute Summary collapse
-
#samba_mountpoints ⇒ Object
Returns the value of attribute samba_mountpoints.
-
#samba_share ⇒ Object
Returns the value of attribute samba_share.
-
#worker ⇒ Object
Returns the value of attribute worker.
Instance Method Summary collapse
Instance Attribute Details
#samba_mountpoints ⇒ Object
Returns the value of attribute samba_mountpoints.
5 6 7 |
# File 'lib/depengine/publisher/samba.rb', line 5 def samba_mountpoints @samba_mountpoints end |
#samba_share ⇒ Object
Returns the value of attribute samba_share.
4 5 6 |
# File 'lib/depengine/publisher/samba.rb', line 4 def samba_share @samba_share end |
#worker ⇒ Object
Returns the value of attribute worker.
6 7 8 |
# File 'lib/depengine/publisher/samba.rb', line 6 def worker @worker end |
Instance Method Details
#chmod(_path, _permissions, _options = {}) ⇒ Object
55 56 57 58 |
# File 'lib/depengine/publisher/samba.rb', line 55 def chmod(_path, , = {}) $log.writer.fatal 'Not yet implemented' exit 1 end |
#copy(source, target, _options = {}) ⇒ Object
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/depengine/publisher/samba.rb', line 8 def copy(source, target, = {}) 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 unless File.directory?(to) unless 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 unless output $log.writer.error "#{method} #{shell_cmd} failed" exit 1 end $log.writer.info output # umount worker.samba_umount("#{samba_mountpoints}/#{samba_share}") rescue => e $log.writer.error 'Can not publish files using samba' $log.writer.error e. $log.writer.error e.backtrace.join("\n") worker.samba_umount("#{samba_mountpoints}/#{samba_share}") exit 1 end rescue => e $log.writer.error "Can not upload files to #{target}" $log.writer.error e. $log.writer.error e.backtrace.join("\n") exit 1 end end |