#!/usr/bin/env php
<?php
/**
 * This script finishes the installation of a horde bundle.
 */

// Enable error reporting.
$error_level = E_ALL & ~E_STRICT;
if (defined('E_DEPRECATED')) {
    $error_level &= ~E_DEPRECATED;
}
ini_set('error_reporting', $error_level);
ini_set('display_errors', 1);

require_once 'PEAR/Config.php';
$pear_config = PEAR_Config::singleton();
require_once $pear_config->get('horde_dir', null, 'pear.horde.org') . '/lib/Application.php';

// Load the CLI environment.
$cli = Horde_Core_Cli::init();
if (!$cli->runningFromCLI()) {
    $cli->fatal('This script must be run from the command line.');
}

// Start.
$cli->writeln();
$cli->writeln($cli->yellow($cli->bold('Installing ' . Horde_Bundle::FULLNAME)));

$bundle = new Horde_Bundle($cli, $pear_config->getConfFile('system'));
$bundle->init();
$bundle->configDb();
$bundle->migrateDb();
$bundle->writeAllConfigs();
$bundle->configAuth();

// Finished.
$cli->writeln();
$cli->writeln($cli->yellow($cli->bold('Thank you for using ' . Horde_Bundle::FULLNAME . '!')));
$cli->writeln();
