head	1.1;
access;
symbols
	TIGRIS_1_1_0RC2:1.1.2.1
	TIGRIS_1_1_0RC1:1.1.2.1
	TIGRIS_1_1:1.1.2.1.0.2
	TIGRIS_1_0_8:1.1.2.1
	TIGRIS_1_0_8RC3:1.1.2.1
	TIGRIS_1_0_8RC2:1.1.2.1
	TIGRIS_1_0_8RC1:1.1.2.1
	TIGRIS_1_0_7:1.1.2.1
	TIGRIS_1_0_7RC3:1.1.2.1
	TIGRIS_1_0_7RC2:1.1.2.1
	TIGRIS_1_0_7RC1:1.1.2.1
	TIGRIS_1_0_6:1.1.2.1
	TIGRIS_1_0_6RC5:1.1.2.1
	TIGRIS_1_0_6RC4:1.1.2.1
	TIGRIS_1_0_6RC3:1.1.2.1
	TIGRIS_1_0_6RC2:1.1.2.1
	TIGRIS_1_0_6RC1:1.1.2.1
	TIGRIS_1_0_5:1.1.2.1
	TIGRIS_1_0_5RC6:1.1.2.1
	TIGRIS_1_0_5RC5:1.1.2.1
	TIGRIS_1_0_5RC4:1.1.2.1
	TIGRIS_1_0_5RC3:1.1.2.1
	TIGRIS_1_0_5RC2:1.1.2.1
	TIGRIS_1_0:1.1.0.2;
locks; strict;
comment	@# @;


1.1
date	2001.05.17.17.02.51;	author edk;	state Exp;
branches
	1.1.2.1;
next	;

1.1.2.1
date	2001.05.17.17.41.35;	author edk;	state Exp;
branches;
next	;


desc
@@


1.1
log
@for anzu, list type names should be changed when upgrading from 0.8.4
to 0.9.2
@
text
@#!/usr/bin/perl

use Getopt::Long;
use strict;
use DBI;  
END { $main::dbh->disconnect if $main::dbh }

main();

sub main
{
    $main::options = getOptions();

    my $domains = readDomainDirs();

    renameOldTypes($domains);
}

sub readDomainDirs
{
    opendir(DIR, "$ENV{SANDBOX}/data/anzu/domains");
    my @@domain_dirs =
        map ("$ENV{SANDBOX}/data/anzu/domains/$_",
            grep (!/^\./, readdir(DIR)));
    closedir(DIR);
    return \@@domain_dirs;
}

sub renameOldTypes
{
    my ($domain_dirs) = @@_;
    foreach my $domain_dir (@@$domain_dirs) {
        opendir(DIR, "$domain_dir/list_types");
        my @@list_types = grep (!/^\./, readdir(DIR));
        closedir(DIR);
        foreach my $list_type (@@list_types) {
            $list_type =~ m/^(.+?)(-private)?$/
                or die "couldn't parse list type $list_type";
            next if ($1 eq 'discuss');
            my $new_list_type = $2;
            if ($1 eq 'announce')
            {
                $new_list_type = "moderated".$new_list_type;
            }
            elsif ($1 eq 'automated-notification')
            {
                $new_list_type = "unmoderated".$new_list_type;
            }
            else
            {
                warn "unknown list type ($1/$2), skipping: $list_type\n";
                next;
            }
            my $dir = "$domain_dir/list_types";
            warn "renaming $list_type to $new_list_type"
                if $main::options->{debug};
            rename ("$dir/$list_type", "$dir/$new_list_type");
        }
    }
}

sub getOptions
{
    my %options;
    if (!GetOptions(\%options,
                "debug",
                "help")
            or $options{help}) {
        showUsage();
    }

    return \%options;
}

sub showUsage
{
    my ($message) = @@_;
    print <<EOM;
Usage: update_anzu [--debug] [--help]
        help            show this message
        debug           include debugging output

This script is designed to change from 0.8.4 list type names to the ones
used in 0.9.2.  You must have sourced env.sh before you can use it.

EOM

    print "\n\tERROR MESSAGE\n\t$message\n" if ($message);

    exit;
}

@


1.1.2.1
log
@upgrade mailing list type names
Submitted by:  Ed Korthof <edk@@collab.net>
Reviewed by:   Michael Stack <stack@@collab.net>
@
text
@@

