Exemplo n.º 1
0
 * @copyright 2010 Sourcefabric O.P.S.
 * @license http://www.gnu.org/licenses/gpl.txt
 */
set_include_path(__DIR__ . '/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
require_once dirname(__FILE__) . '/../../include/AirtimeInstall.php';
global $CC_CONFIG;
function load_airtime_config()
{
    $ini_array = parse_ini_file('/etc/airtime/airtime.conf', true);
    return $ini_array;
}
$values = load_airtime_config();
$CC_CONFIG = array('webServerUser' => $values['general']['web_server_user'], 'rabbitmq' => $values['rabbitmq'], 'baseFilesDir' => $values['general']['base_files_dir'], 'storageDir' => $values['general']['base_files_dir'] . "/stor", 'dsn' => array('username' => $values['database']['dbuser'], 'password' => $values['database']['dbpass'], 'hostspec' => $values['database']['host'], 'phptype' => 'pgsql', 'database' => $values['database']['dbname']), 'tblNamePrefix' => 'cc_', 'apiKey' => array($values['general']['api_key']), 'apiPath' => '/api/', 'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A', 'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs', 'soundcloud-connection-retries' => $values['soundcloud']['connection_retries'], 'soundcloud-connection-wait' => $values['soundcloud']['time_between_retries'], "rootDir" => __DIR__ . "/../..", 'pearPath' => dirname(__FILE__) . '/../../library/pear', 'zendPath' => dirname(__FILE__) . '/../../library/Zend', 'phingPath' => dirname(__FILE__) . '/../../library/phing');
AirtimeInstall::DbConnect(true);
echo PHP_EOL . "*** Updating Database Tables ***" . PHP_EOL;
if (AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
    $migrations = array('20110312121200', '20110331111708', '20110402164819');
    foreach ($migrations as $migration) {
        AirtimeInstall::BypassMigrations(__DIR__, $migration);
    }
}
AirtimeInstall::MigrateTablesToVersion(__DIR__, '20110406182005');
//setting data for new aggregate show length column.
$sql = "SELECT id FROM cc_show_instances";
$show_instances = $CC_DBC->GetAll($sql);
foreach ($show_instances as $show_instance) {
    $sql = "UPDATE cc_show_instances SET time_filled = (SELECT SUM(clip_length) FROM cc_schedule WHERE instance_id = {$show_instance["id"]}) WHERE id = {$show_instance["id"]}";
    $CC_DBC->query($sql);
}
//end setting data for new aggregate show length column.
exec("rm -fr /opt/pypo");
Exemplo n.º 2
0
//------------------------------------------------------------------------
if ($dbDeleteFailed) {
    echo " * Couldn't delete the database, so deleting all the DB tables..." . PHP_EOL;
    $connected = AirtimeInstall::DbConnect(false);
    if ($connected) {
        $con = Propel::getConnection();
        $sql = "select * from pg_tables where tableowner = 'airtime'";
        try {
            $rows = $con->query($sql)->fetchAll();
        } catch (Exception $e) {
            $rows = array();
        }
        foreach ($rows as $row) {
            $tablename = $row["tablename"];
            echo "   * Removing database table {$tablename}...";
            if (AirtimeInstall::DbTableExists($tablename)) {
                $sql = "DROP TABLE {$tablename} CASCADE";
                AirtimeInstall::InstallQuery($sql, false);
                AirtimeInstall::DropSequence($tablename . "_id");
            }
            echo "done." . PHP_EOL;
        }
    }
}
//------------------------------------------------------------------------
// Delete the user
//------------------------------------------------------------------------
echo " * Deleting database user '{$CC_CONFIG['dsn']['username']}'..." . PHP_EOL;
$command = "echo \"DROP USER IF EXISTS {$CC_CONFIG['dsn']['username']}\" | su postgres -c psql >/dev/null 2>&1";
@exec($command, $output, $results);
if ($results == 0) {