Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
Conflicts: airtime_mvc/application/controllers/PreferenceController.php airtime_mvc/application/models/Preference.php
This commit is contained in:
commit
05dc48fa71
55 changed files with 907 additions and 664 deletions
|
@ -27,6 +27,7 @@ class AirtimeIni
|
|||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
|
||||
const CONF_FILE_MONIT = "/etc/monit/conf.d/airtime-monit.cfg";
|
||||
|
||||
public static function IniFilesExist()
|
||||
{
|
||||
|
@ -75,10 +76,21 @@ class AirtimeIni
|
|||
exit(1);
|
||||
}
|
||||
if (!copy(__DIR__."/../../python_apps/media-monitor/media-monitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
|
||||
echo "Could not copy MediaMonitor.cfg to /etc/airtime/. Exiting.";
|
||||
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function CreateMonitFile(){
|
||||
if (!copy(__DIR__."/../../python_apps/monit/airtime-monit.cfg", AirtimeIni::CONF_FILE_MONIT)){
|
||||
echo "Could not copy airtime-monit.cfg to /etc/monit/conf.d/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function RemoveMonitFile(){
|
||||
@unlink("/etc/monit/conf.d/airtime-monit.cfg");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function removes /etc/airtime and the configuration
|
||||
|
@ -187,7 +199,6 @@ class AirtimeIni
|
|||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_PYPO, 'api_key', "'$api_key'");
|
||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_RECORDER, 'api_key', "'$api_key'");
|
||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_MEDIAMONITOR, 'api_key', "'$api_key'");
|
||||
AirtimeIni::UpdateIniValue(AirtimeInstall::CONF_DIR_WWW.'/build/build.properties', 'project.home', AirtimeInstall::CONF_DIR_WWW);
|
||||
}
|
||||
|
||||
public static function ReadPythonConfig($p_filename)
|
||||
|
|
|
@ -290,7 +290,7 @@ class AirtimeInstall
|
|||
|
||||
public static function DeleteFilesRecursive($p_path)
|
||||
{
|
||||
$command = "rm -rf $p_path";
|
||||
$command = "rm -rf \"$p_path\"";
|
||||
exec($command);
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ class AirtimeInstall
|
|||
public static function UninstallPhpCode()
|
||||
{
|
||||
echo "* Removing PHP code from ".AirtimeInstall::CONF_DIR_WWW.PHP_EOL;
|
||||
exec("rm -rf ".AirtimeInstall::CONF_DIR_WWW);
|
||||
exec('rm -rf "'.AirtimeInstall::CONF_DIR_WWW.'"');
|
||||
}
|
||||
|
||||
public static function InstallBinaries()
|
||||
|
@ -349,7 +349,7 @@ class AirtimeInstall
|
|||
public static function UninstallBinaries()
|
||||
{
|
||||
echo "* Removing Airtime binaries from ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
|
||||
exec("rm -rf ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
exec('rm -rf "'.AirtimeInstall::CONF_DIR_BINARIES.'"');
|
||||
}
|
||||
|
||||
public static function DirCheck()
|
||||
|
@ -399,6 +399,6 @@ class AirtimeInstall
|
|||
$path = AirtimeInstall::CONF_DIR_LOG;
|
||||
echo "* Removing logs directory ".$path.PHP_EOL;
|
||||
|
||||
exec("rm -rf $path");
|
||||
exec("rm -rf \"$path\"");
|
||||
}
|
||||
}
|
||||
|
|
142
install/include/airtime-install.php
Normal file
142
install/include/airtime-install.php
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @copyright 2011 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*
|
||||
* Checks if a previous version of Airtime is currently installed, upgrades Airtime if so.
|
||||
* Performs a new install (new configs, database install) if a version of Airtime is not found
|
||||
* If the current version is found to be installed the User is presented with the help menu and can choose -r to reinstall.
|
||||
*/
|
||||
set_include_path(__DIR__.'/../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php');
|
||||
|
||||
AirtimeInstall::ExitIfNotRoot();
|
||||
|
||||
$newInstall = false;
|
||||
$version = AirtimeInstall::GetVersionInstalled();
|
||||
|
||||
require_once('Zend/Loader/Autoloader.php');
|
||||
$autoloader = Zend_Loader_Autoloader::getInstance();
|
||||
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(
|
||||
array(
|
||||
'help|h' => 'Displays usage information.',
|
||||
'overwrite|o' => 'Overwrite any existing config files.',
|
||||
'preserve|p' => 'Keep any existing config files.',
|
||||
'no-db|n' => 'Turn off database install.',
|
||||
'reinstall|r' => 'Force a fresh install of this Airtime Version'
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
}
|
||||
catch (Zend_Console_Getopt_Exception $e) {
|
||||
exit($e->getMessage() ."\n\n". $e->getUsageMessage());
|
||||
}
|
||||
|
||||
if (isset($opts->h)) {
|
||||
echo $opts->getUsageMessage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// The current version is already installed.
|
||||
if(isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) {
|
||||
echo "Airtime $version is already installed.".PHP_EOL;
|
||||
echo $opts->getUsageMessage();
|
||||
exit(1);
|
||||
}
|
||||
// A previous version exists - if so, upgrade.
|
||||
if(isset($version) && ($version != false) && ($version < AIRTIME_VERSION)) {
|
||||
echo "Airtime version $version found.".PHP_EOL;
|
||||
require_once("airtime-upgrade.php");
|
||||
|
||||
//Make sure to exit with non-zero error code so that airtime-install
|
||||
//shell script does not continue with installing pypo, show-recorder,
|
||||
//media-monitor etc.
|
||||
exit(2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// The only way we get here is if we are doing a new install or a reinstall.
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if(is_null($version)) {
|
||||
$newInstall = true;
|
||||
}
|
||||
|
||||
$db_install = true;
|
||||
if (is_null($opts->r) && isset($opts->n)){
|
||||
$db_install = false;
|
||||
}
|
||||
|
||||
$overwrite = false;
|
||||
if (isset($opts->o) || $newInstall == true) {
|
||||
$overwrite = true;
|
||||
}
|
||||
else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
|
||||
if (AirtimeIni::IniFilesExist()) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$overwrite = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($overwrite) {
|
||||
echo "* Creating INI files".PHP_EOL;
|
||||
AirtimeIni::CreateIniFiles();
|
||||
}
|
||||
AirtimeIni::CreateMonitFile();
|
||||
|
||||
|
||||
AirtimeInstall::InstallPhpCode();
|
||||
AirtimeInstall::InstallBinaries();
|
||||
|
||||
if ($overwrite) {
|
||||
echo "* Initializing INI files".PHP_EOL;
|
||||
AirtimeIni::UpdateIniFiles();
|
||||
}
|
||||
|
||||
// Update the build.properties file to point to the correct directory.
|
||||
AirtimeIni::UpdateIniValue(AirtimeInstall::CONF_DIR_WWW.'/build/build.properties', 'project.home', AirtimeInstall::CONF_DIR_WWW);
|
||||
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
|
||||
echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL;
|
||||
|
||||
if ($db_install) {
|
||||
if($newInstall) {
|
||||
system('php airtime-db-install.php y');
|
||||
}
|
||||
else {
|
||||
require_once('airtime-db-install.php');
|
||||
}
|
||||
}
|
||||
|
||||
AirtimeInstall::InstallStorageDirectory();
|
||||
|
||||
AirtimeInstall::CreateSymlinksToUtils();
|
||||
|
||||
AirtimeInstall::CreateZendPhpLogFile();
|
||||
|
||||
AirtimeInstall::SetUniqueId();
|
||||
|
||||
$h = rand(0,23);
|
||||
$m = rand(0,59);
|
||||
|
||||
$fp = fopen('/etc/cron.d/airtime-crons','a');
|
||||
fwrite($fp, "$m $h * * * root /usr/lib/airtime/utils/phone_home_stat\n");
|
||||
fclose($fp);
|
||||
|
||||
/* FINISHED AIRTIME PHP INSTALLER */
|
95
install/include/airtime-uninstall.php
Normal file
95
install/include/airtime-uninstall.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
// Need to check that we are superuser before running this.
|
||||
AirtimeInstall::ExitIfNotRoot();
|
||||
|
||||
if (!file_exists(AirtimeIni::CONF_FILE_AIRTIME)) {
|
||||
echo PHP_EOL."Airtime config file '".AirtimeIni::CONF_FILE_AIRTIME."' does not exist.".PHP_EOL;
|
||||
echo "Most likely this means that Airtime is not installed, so there is nothing to do.".PHP_EOL.PHP_EOL;
|
||||
exit();
|
||||
}
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php');
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
|
||||
echo PHP_EOL;
|
||||
echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL;
|
||||
AirtimeInstall::UninstallPhpCode();
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Delete the database
|
||||
// Note: Do not put a call to AirtimeInstall::DbConnect()
|
||||
// before this function, even if you called $CC_DBC->disconnect(), there will
|
||||
// still be a connection to the database and you wont be able to delete it.
|
||||
//------------------------------------------------------------------------
|
||||
echo " * Dropping the database '".$CC_CONFIG['dsn']['database']."'...".PHP_EOL;
|
||||
|
||||
// check if DB exists
|
||||
$command = "echo \"DROP DATABASE IF EXISTS ".$CC_CONFIG['dsn']['database']."\" | su postgres -c psql";
|
||||
|
||||
@exec($command, $output, $dbDeleteFailed);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Delete DB tables
|
||||
// We do this if dropping the database fails above.
|
||||
//------------------------------------------------------------------------
|
||||
if ($dbDeleteFailed) {
|
||||
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
|
||||
AirtimeInstall::DbConnect(false);
|
||||
|
||||
if (!PEAR::isError($CC_DBC)) {
|
||||
$sql = "select * from pg_tables where tableowner = 'airtime'";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
if (PEAR::isError($rows)) {
|
||||
$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);
|
||||
|
||||
$CC_DBC->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) {
|
||||
echo " * User '{$CC_CONFIG['dsn']['username']}' deleted.".PHP_EOL;
|
||||
} else {
|
||||
echo " * Nothing to delete.".PHP_EOL;
|
||||
}
|
||||
|
||||
# Disabled as this should be a manual process
|
||||
#AirtimeInstall::DeleteFilesRecursive(AirtimeInstall::CONF_DIR_STORAGE);
|
||||
|
||||
|
||||
|
||||
#Disabled as this should be a manual process
|
||||
#AirtimeIni::RemoveIniFiles();
|
||||
|
||||
AirtimeInstall::RemoveSymlinks();
|
||||
AirtimeInstall::UninstallBinaries();
|
||||
AirtimeInstall::RemoveLogDirectories();
|
||||
AirtimeIni::RemoveMonitFile();
|
||||
|
||||
unlink('/etc/cron.d/airtime-crons');
|
||||
|
||||
/* FINISHED AIRTIME PHP UNINSTALLER */
|
106
install/include/airtime-upgrade.php
Normal file
106
install/include/airtime-upgrade.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
//Pear classes.
|
||||
set_include_path(__DIR__.'/../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
|
||||
require_once('DB.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
|
||||
if(exec("whoami") != "root"){
|
||||
echo "Must be root user.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo $CC_DBC->getMessage().PHP_EOL;
|
||||
echo $CC_DBC->getUserInfo().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
exit(1);
|
||||
} else {
|
||||
echo "* Connected to database".PHP_EOL;
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$version = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (PEAR::isError($version)) {
|
||||
$version = false;
|
||||
}
|
||||
|
||||
if (!$version){
|
||||
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (!PEAR::isError($result)) {
|
||||
$version = "1.7.0";
|
||||
echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
$version = "1.6";
|
||||
echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
echo "******************************** Update Begin *********************************".PHP_EOL;
|
||||
|
||||
//convert strings like 1.9.0-devel to 1.9.0
|
||||
$version = substr($version, 0, 5);
|
||||
|
||||
if (strcmp($version, "1.7.0") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.7/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.8.0") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.8/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.8.1") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.8.1/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.8.2") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.8.2/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.9.0") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.9/airtime-upgrade.php");
|
||||
}
|
||||
|
||||
|
||||
//set the new version in the database.
|
||||
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$CC_DBC->query($sql);
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '1.9.0-devel')";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
|
||||
echo PHP_EOL."*** Updating Pypo ***".PHP_EOL;
|
||||
passthru("python ".__DIR__."/../../python_apps/pypo/install/pypo-install.py");
|
||||
|
||||
echo PHP_EOL."*** Updating Recorder ***".PHP_EOL;
|
||||
passthru("python ".__DIR__."/../../python_apps/show-recorder/install/recorder-install.py");
|
||||
|
||||
echo PHP_EOL."*** Updating Media Monitor ***".PHP_EOL;
|
||||
passthru("python ".__DIR__."/../../python_apps/media-monitor/install/media-monitor-install.py");
|
||||
|
||||
AirtimeIni::CreateMonitFile();
|
||||
|
||||
|
||||
echo "******************************* Update Complete *******************************".PHP_EOL;
|
Loading…
Add table
Add a link
Reference in a new issue