#!/usr/bin/php
<?php 
/**
 * 
 * Third part of the Mail export : rsync mailboxes, which you can use multiple times
 * 
 * @since 2015-10-15
 * @author Alban
 * @license GPL v2
 */
// Load bootstrap for autoload and logger
set_include_path(".:" . get_include_path());
require_once "bootstrap.php";
// Instanciate export service
$service = new Alternc_Tools_Mailbox_Import(array("db" => $db));
// Instanciate command line parser
$consoleParser = new Console_CommandLine(array("description" => "Synchronizes mailboxes using an old => new mapper."));
// Configure command line parser
$consoleParser->add_version_option = false;
$consoleParser->addOption("input_file", array("help_name" => "/tmp/rsyncData.json", "short_name" => "-i", "long_name" => "--input-file", "description" => "Input file name and path", 'default' => $service->default_output));
$consoleParser->addOption("rsync_log", array("help_name" => "/tmp/rsyncLog.json", "short_name" => "-l", "long_name" => "--rsync-log", "description" => "Rsync log files", 'default' => $service->default_rsync_log));
$consoleParser->addArgument("source", array("help_name" => "source.server.fqdn", "description" => "Origin/Source server, IP or FQDN"));
// Run the command line parser
try {
    $commandLineResult = $consoleParser->parse();
    // Run the service
    if (!($result = $service->rsync($commandLineResult))) {
        throw new \Exception("Import process failed");
    }
    $message = $result["message"];
    $logger->logMessage(Logger\AbstractLogger::INFO, $message);
#!/usr/bin/php
<?php 
/**
 * @since 2015-10-15
 * @author Alban
 * @license GPL v2
 */
// Load bootstrap for autoload and logger
set_include_path(".:" . get_include_path());
require_once "bootstrap.php";
// Instanciate export service
$service = new Alternc_Tools_Mailbox_Import(array("db" => $db));
// Instanciate command line parser
$consoleParser = new Console_CommandLine(array("description" => "Imports Alternc mailboxes from a file for import and gets ready for sync."));
// Configure command line parser
$consoleParser->add_version_option = false;
$consoleParser->addOption("ignore_login", array("help_name" => "true", "long_name" => "--ignore-login", "description" => "Ignore the email's source AlternC login and use the new domain owner", 'default' => false));
$consoleParser->addOption("input_file", array("help_name" => "/tmp/out.json", "short_name" => "-i", "long_name" => "--input-file", "description" => "Input file name and path", 'default' => $service->default_input));
$consoleParser->addOption("output_file", array("help_name" => "/tmp/out.json", "short_name" => "-o", "long_name" => "--output-file", "description" => "Export file name and path", 'default' => $service->default_output));
// Run the command line parser
try {
    $commandLineResult = $consoleParser->parse();
    // Run the service
    if (!($result = $service->import($commandLineResult))) {
        throw new \Exception("Import process failed");
    }
    $message = "";
    $level = Logger\AbstractLogger::INFO;
    if (isset($result["message"])) {
        $message .= $result["message"] . "\n";
    }