From 01f50c82edd57ba00497441276cc05d80435f10c Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 18 Oct 2006 13:18:51 +0000 Subject: Move stuff to logs-archive git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@206 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- bin/weblogs-rotate | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/bin/weblogs-rotate b/bin/weblogs-rotate index 98e969f..594e0dc 100755 --- a/bin/weblogs-rotate +++ b/bin/weblogs-rotate @@ -15,28 +15,33 @@ ARGV.options do |opts| end -root = '/srv/www/vhosts' +root = '/srv/www/vhosts/' +archive_dir = "/logs-archive/" +logs_dir = "/logs/" + Dir.chdir(root) today = Time.new.strftime("%Y-%m-%d"); Dir.glob("*").each{ |client| Dir.chdir(root) next unless File.stat( client ).directory? - next unless File.exist?( client + "/logs" ) - next unless File.stat( client + "/logs" ).directory? - - logroot = root+"/"+client+"/logs" - Dir.chdir(logroot) + next unless File.exist?( client + logs_dir ) + next unless File.stat( client + logs_dir ).directory? + next unless File.stat( client + archive_dir ).directory? + + root_logs_dir = root+"/"+client+logs_dir + root_archive_dir = root+"/"+client+archive_dir + + Dir.chdir(root_logs_dir) Dir.glob("*.log").each{ |filename| targetname = filename +"."+ today - - if File.exist?(targetname) or - File.exist?(targetname+".gz") or - File.exist?(targetname+".bz2") + if File.exist?(root_archive_dir+targetname) or + File.exist?(root_archive_dir+targetname+".gz") or + File.exist?(root_archive_dir+targetname+".bz2") STDERR.puts("Not moving #{filename}: Target exists."); else puts "Moving #{filename}" if $VERBOSE - File.rename( filename , targetname ); + File.rename( filename , root_archive_dir+targetname ); end } } -- cgit v1.2.3