2010-11-04 23:01:31 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2011-01-05 23:44:23 +01:00
|
|
|
* @package Airtime
|
2011-04-16 00:23:51 +02:00
|
|
|
* @copyright 2011 Sourcefabric O.P.S.
|
2010-11-04 23:01:31 +01:00
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt
|
|
|
|
*/
|
2012-04-02 05:39:15 +02:00
|
|
|
require_once(__DIR__.'/AirtimeIni.php');
|
|
|
|
require_once(__DIR__.'/AirtimeInstall.php');
|
2012-05-09 00:11:24 +02:00
|
|
|
require_once(__DIR__.'/airtime-constants.php');
|
2011-11-18 20:06:42 +01:00
|
|
|
|
2011-05-25 04:26:57 +02:00
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// The only way we get here is if we are doing a new install or a reinstall.
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2012-05-09 00:11:24 +02:00
|
|
|
$iniExists = file_exists("/etc/airtime/airtime.conf");
|
|
|
|
if ($iniExists){
|
|
|
|
//reinstall, Will ask if we should rewrite config files.
|
|
|
|
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
|
|
|
require_once 'propel/runtime/lib/Propel.php';
|
|
|
|
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
|
|
|
$version = AirtimeInstall::GetVersionInstalled();
|
|
|
|
$newInstall = is_null($version);
|
|
|
|
} else {
|
|
|
|
//create config files without asking
|
2011-05-20 18:25:50 +02:00
|
|
|
$newInstall = true;
|
|
|
|
}
|
2011-05-20 17:22:46 +02:00
|
|
|
|
2011-04-16 00:23:51 +02:00
|
|
|
$overwrite = false;
|
2011-11-30 23:59:00 +01:00
|
|
|
if (getenv("overwrite") == "t" || $newInstall == true) {
|
2011-04-16 00:23:51 +02:00
|
|
|
$overwrite = true;
|
2011-11-30 23:59:00 +01:00
|
|
|
} else if (getenv("preserve") == "f" && getenv("overwrite") == "f" && getenv("reinstall") == "t") {
|
2011-05-20 17:22:46 +02:00
|
|
|
if (AirtimeIni::IniFilesExist()) {
|
2011-04-16 00:23:51 +02:00
|
|
|
$userAnswer = "x";
|
|
|
|
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
|
|
|
|
echo PHP_EOL."You have existing config files. Do you want to (O)verwrite them, or (P)reserve them? (o/P) ";
|
|
|
|
$userAnswer = trim(fgets(STDIN));
|
|
|
|
}
|
|
|
|
if (in_array($userAnswer, array("o", "O"))) {
|
|
|
|
$overwrite = true;
|
|
|
|
}
|
2011-10-27 20:01:59 +02:00
|
|
|
} else {
|
2011-04-18 23:50:04 +02:00
|
|
|
$overwrite = true;
|
2011-04-18 23:15:51 +02:00
|
|
|
}
|
2011-04-16 00:23:51 +02:00
|
|
|
}
|
2011-04-18 23:50:04 +02:00
|
|
|
|
2011-04-16 00:23:51 +02:00
|
|
|
if ($overwrite) {
|
|
|
|
echo "* Creating INI files".PHP_EOL;
|
|
|
|
AirtimeIni::CreateIniFiles();
|
2011-04-16 00:37:24 +02:00
|
|
|
echo "* Initializing INI files".PHP_EOL;
|
|
|
|
AirtimeIni::UpdateIniFiles();
|
|
|
|
}
|
2012-05-09 00:11:24 +02:00
|
|
|
if (!$iniExists){
|
|
|
|
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
|
|
|
require_once 'propel/runtime/lib/Propel.php';
|
|
|
|
Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php");
|
|
|
|
}
|
2011-02-22 22:16:37 +01:00
|
|
|
|
2011-04-15 00:55:04 +02:00
|
|
|
echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL;
|
2011-03-30 17:01:23 +02:00
|
|
|
|
2011-06-23 17:51:38 +02:00
|
|
|
AirtimeInstall::InstallStorageDirectory();
|
|
|
|
|
2012-05-09 00:11:24 +02:00
|
|
|
$db_install = getenv("nodb")!="t";
|
2011-05-10 23:10:46 +02:00
|
|
|
if ($db_install) {
|
2011-05-20 18:25:50 +02:00
|
|
|
if($newInstall) {
|
2011-10-27 20:01:59 +02:00
|
|
|
//call external script. "y" argument means force creation of database tables.
|
2011-10-04 20:01:48 +02:00
|
|
|
passthru('php '.__DIR__.'/airtime-db-install.php y');
|
2011-06-21 17:40:07 +02:00
|
|
|
} else {
|
2011-05-20 18:25:50 +02:00
|
|
|
require_once('airtime-db-install.php');
|
|
|
|
}
|
2011-05-10 23:10:46 +02:00
|
|
|
}
|