#!/usr/pkg/bin/ruby18 # # move_old_mailboxes.rb # # by Eric Shane Radman # Last Updated: 2008-05-21 require "dbi" require "find" def move_boxes() dbh = DBI.connect('DBI:Pg:system') sq_paths = ['/var/mail/webmail.teisprint.com/data/', '/var/mail/webmail.ezaccess.net/data/'] sql = %{ SELECT email FROM users WHERE username=? AND mail='t' } for sq_path in sq_paths conn = dbh.prepare(sql) Find.find(sq_path) do |path| if not File.directory?(path) then parts = path.split('/') file = parts[parts.length-1] user = file.chomp(".abook").chomp(".pref").chomp(".sig").chomp(".si1").chomp(".si2") conn.execute(user) users = conn.fetch if not users then print file sleep(0.5) print " ... moving" print `mv #{path} /archive/www/` puts else puts 'Skipping ' + file end end end end end if $0 == __FILE__ move_boxes() end