#!/usr/bin/perl -w

sub do_system
{
    my ($command) = @_;
    system ($command);
    if ($? != 0) {
	die "Command failed: $command";
    }
}

$filename = `/usr/local/libexec/evolution/3.2/evolution-addressbook-export`;
if ($? != 0) {
    $! = $?;
    die $!;
}

$HOME = $ENV{"HOME"};

system ("/usr/local/libexec/evolution/3.2/killev");
do_system ("/bin/mv ${HOME}/.evolution/addressbook/local/system/addressbook.db ${HOME}/.evolution/addressbook/local/system/addressbook-backup.db");
do_system ("/usr/local/libexec/evolution/3.2/evolution-addressbook-import --input-file $filename");
do_system ("/bin/rm $filename");

