Created
May 18, 2010 10:49
-
-
Save tfoldi/404869 to your computer and use it in GitHub Desktop.
smbclient based sync between windows and unix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# Foldi Tamas <[email protected]>, BSDL | |
require "yaml" | |
# read configuration | |
@yxlan_dir = File.dirname($0) + "/../" | |
@conf = YAML::load_file( @yxlan_dir + 'etc/yxlon.conf' ) | |
@filename = @yxlan_dir + "log/yxlon_cron.log" | |
def logger(s) | |
f = File.open(@filename,'a') | |
f.puts "#{get_formatted_time} #{s}" | |
f.close | |
end | |
def get_formatted_time | |
t = Time.now | |
t.strftime("%Y.%m.%d. %H:%M:%S") | |
end | |
@conf["gepek"].each do |gep| | |
# create timestamp file if it does not exist | |
unless File.exist?( "#{@yxlan_dir}var/#{gep['nev']}.tar" ) | |
system "touch -t 8001010000 #{@yxlan_dir}var/#{gep['nev']}.tar" | |
end | |
# get new files | |
logger "Getting files from \\\\#{gep['ip']}\\#{gep['konyvtar']}" | |
system "smbclient '\\\\#{gep['ip']}\\#{gep['konyvtar']}' '#{gep['pass'] || ''}' -U #{gep['user']} -TcN #{@yxlan_dir}var/#{gep['nev']}.tar #{@yxlan_dir}var/#{gep['nev']}.tar\n" | |
# extracting files | |
logger "Extracting file to #{@conf['samba_dir']}" | |
system "tar -C #{@conf['samba_dir']}/#{gep['nev']} -xvf #{@yxlan_dir}var/#{gep['nev']}.tar" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yxlon_dir: /opt/yxlon | |
samba_dir: /samba/yxlon | |
gepek: | |
- nev: RA1HOST | |
ip: 10.124.1.10 | |
konyvtar: ExportStatistics | |
user: xxx | |
pass: xxx | |
- nev: RA3HOST | |
ip: 10.124.3.10 | |
konyvtar: ExportStatistics | |
user: xxx | |
pass: xxx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment