[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] Script to fix existing RaQ3 sites for catch-all



I threw together a script that will go through and setup the necessary
aliases for existing users so that catch-all email addresses will work
(after applying Duncan Laurie's patch).  It seems to work fine on my
RaQ3s, but of course there is no warrenty (if it formats your hard
drive, you're on your own :-) ).
-- 
Chris Adams <cmadams@xxxxxxxxxx>
Systems and Network Administrator - HiWAAY Information Services
I don't speak for anybody but myself - that's enough trouble.


#!/usr/bin/perl -w

# Script to fixup RaQ3 accounts so catch-all email addresses don't catch
# all email for the domain.
#
# Just run this script as root on a RaQ3.
#
# You should first apply Duncan Laurie's patch, available from
# ftp://ftp.cobaltnet.com/pub/users/duncan/raq3/raq3-catchall.patch.bz2
#
# Chris Adams <cmadams@xxxxxxxxxx>
# HiWAAY Information Services

use DB_File;
use Cobalt::Email;
use strict;

my $debug = 0;
if (@ARGV && ($ARGV[0] eq "-d")) {
	$debug = 1;
	shift @ARGV;
}

my %virt = Cobalt::Email::mail_virtuser_list_alias;
my %routes = Cobalt::Email::mail_virtuser_list_route;

opendir (S, "/home/sites") or die "/home/sites: $!";
while (defined (my $f = readdir (S))) {
	next if ($f =~ /^\.{1,2}$/);
	next if ($f eq "home");
	next if ($f =~ /^site\d+$/);

	opendir (U, "/home/sites/$f/users") or die "/home/sites/$f/users: $!";
	while (defined (my $u = readdir (U))) {
		next if ($u =~ /^\.{1,2}$/);
		next if ($u eq "admin");
		next if (! getpwnam ($u));

		my $virt = $u . "\@" . $f;
		next if (defined ($virt{$virt}));
		$virt{$virt} = $u;
		print "Adding $virt => $u\n" if ($debug);
	}
	closedir (U);
}
closedir (S);

Cobalt::Email::mail_build_virtusertable (\%virt, \%routes) if (! $debug);