Show prefs_depth.pl syntax highlighted
#!/usr/bin/perl -w
use strict;
# Usage:
# This utility migrates preferences from pre-0.9924 format to 0.9924 and above.
#
# 1. Change the host variable to match an MX that has pref files
# 2. Set $newbase to the location you want to use as your new prefs
# 3. cd to your old prefs directory.
# 4. Run this utility.
# 5. Update your alphamail config to point to the new prefs directory
our $host = "uoregon.edu";
our $newbase = "/var/alphamail/prefs";
our $depth = 3;
sub gen_depth
{
my $base = shift; # The base to start with
my $username = shift; # Actual user object
my $mx = shift; # MX
my $depth = shift;
my $dir;
$dir = $base;
if(!-d $dir) {
mkdir $dir or die("Could not create $dir");
}
# First, tack on the MX
$dir .= "/" . $mx;
if(!-d $dir) {
mkdir $dir or die("Could not create $dir");
}
# Now tack on the depth parts
for(my $d = 0; $d < $depth; $d++) {
last if(length($username) <= $d);
$dir .= "/" . substr($username, $d, 1);
if(!-d $dir) {
mkdir $dir or die("Could not create $dir");
}
}
# Now tack on the actual user name
$dir .= "/" . $username;
if(!-d $dir) {
mkdir $dir or die("Could not create $dir");
}
return $dir;
}
opendir DIR, ".";
my $entry;
my ($username, $suffix, $dest);
while($entry = readdir DIR)
{
$entry =~ m/^(.*)_\Q$host\E\.(prefs|addressbook|sigs)$/;
$username = $1;
$suffix = $2;
if(!$1) {
print "Skipping $entry\n";
next;
}
$dest = gen_depth($newbase, $username, $host, $depth);
if($suffix eq 'prefs') {
qx(cp "$entry" "$dest/preferences")
} elsif($suffix eq 'addressbook') {
qx(cp "$entry" "$dest/addressbook")
} elsif($suffix eq 'sigs') {
qx(cp "$entry" "$dest/signatures")
} else {
print "Error working on $entry\n";
}
}
See more files for this project here
AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.
Project homepage:
http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other
init.d/
alphamail_tmpfs
imap_webcache
sandbox/
Makefile.am
sandbox.cc
Makefile.am
alphamail_genconfig
awstats_gen
garbage_sweeper
hang_detector
logrotate.conf
prefs_depth.pl
size_vs_time.pl
stats.pl
update_prefs
webcache_watcher