CC-2562 : Allow users to convert linked files into watched directories
This commit is contained in:
parent
d3776f4ea9
commit
b89338e808
|
@ -17,22 +17,22 @@ class Version20110711161043 extends AbstractMigration
|
|||
{
|
||||
/* 1) update cc_files table to include to "directory" column */
|
||||
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('stor', '/srv/airtime/stor');");
|
||||
|
||||
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('upgrade', '');");
|
||||
|
||||
$this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('link', '');");
|
||||
|
||||
$cc_music_dirs = $schema->getTable('cc_music_dirs');
|
||||
|
||||
|
||||
/* 2) create a foreign key relationship from cc_files to cc_music_dirs */
|
||||
$cc_files = $schema->getTable('cc_files');
|
||||
$cc_files->addColumn('directory', 'integer', array('default'=> 2));
|
||||
|
||||
$cc_files->addNamedForeignKeyConstraint('cc_music_dirs_folder_fkey', $cc_music_dirs, array('directory'), array('id'), array('onDelete' => 'CASCADE'));
|
||||
|
||||
|
||||
/* 3) create a foreign key relationship from cc_schedule to cc_files */
|
||||
$cc_schedule = $schema->getTable('cc_schedule');
|
||||
$cc_schedule->addNamedForeignKeyConstraint('cc_files_folder_fkey', $cc_files, array('file_id'), array('id'), array('onDelete' => 'CASCADE'));
|
||||
}
|
||||
|
||||
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ set_include_path(__DIR__.'/../../../airtime_mvc/library/pear' . PATH_SEPARATOR .
|
|||
require_once 'conf.php';
|
||||
require_once 'DB.php';
|
||||
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(__DIR__."../../../airtime_mvc/application/configs/airtime-conf.php");
|
||||
|
||||
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
||||
|
||||
class AirtimeInstall{
|
||||
|
@ -33,7 +36,7 @@ class AirtimeInstall{
|
|||
chown($file, $CC_CONFIG['webServerUser']);
|
||||
chgrp($file, $CC_CONFIG['webServerUser']);
|
||||
}
|
||||
|
||||
|
||||
public static function CreateSymlinksToUtils()
|
||||
{
|
||||
echo "* Creating /usr/bin symlinks".PHP_EOL;
|
||||
|
@ -51,14 +54,14 @@ class AirtimeInstall{
|
|||
$dir = CONF_DIR_BINARIES."/utils/airtime-check-system";
|
||||
exec("ln -s $dir /usr/bin/airtime-check-system");
|
||||
}
|
||||
|
||||
|
||||
public static function RemoveSymlinks()
|
||||
{
|
||||
exec("rm -f /usr/bin/airtime-import");
|
||||
exec("rm -f /usr/bin/airtime-update-db-settings");
|
||||
exec("rm -f /usr/bin/airtime-check-system");
|
||||
}
|
||||
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
@ -69,7 +72,7 @@ class AirtimeInstall{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function BypassMigrations($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
|
@ -89,22 +92,22 @@ class AirtimeInstall{
|
|||
"--no-interaction migrations:migrate $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
|
||||
public static function CreateCronFile(){
|
||||
// Create CRON task to run every day. Time of day is initialized to a random time.
|
||||
$hour = rand(0,23);
|
||||
$minute = rand(0,59);
|
||||
|
||||
|
||||
$fp = fopen('/etc/cron.d/airtime-crons','w');
|
||||
fwrite($fp, "$minute $hour * * * root /usr/lib/airtime/utils/phone_home_stat\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
|
||||
public static function GetAirtimeSrcDir()
|
||||
{
|
||||
return __DIR__."/../../../airtime_mvc";
|
||||
}
|
||||
|
||||
|
||||
public static function InsertCountryDataIntoDatabase(){
|
||||
$sql = "INSERT INTO cc_country (isocode, name) VALUES ('AFG', 'Afghanistan ');
|
||||
INSERT INTO cc_country (isocode, name) VALUES ('ALA', 'Åland Islands');
|
||||
|
@ -346,7 +349,7 @@ class AirtimeInstall{
|
|||
INSERT INTO cc_country (isocode, name) VALUES ('ZWE', 'Zimbabwe ');";
|
||||
|
||||
echo "* Inserting data into country table".PHP_EOL;
|
||||
Airtime190Upgrade::execSqlQuery($sql);
|
||||
Airtime190Upgrade::execSqlQuery($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,7 +362,7 @@ class AirtimeIni{
|
|||
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
|
||||
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
|
||||
const CONF_FILE_MONIT = "/etc/monit/conf.d/airtime-monit.cfg";
|
||||
|
||||
|
||||
/**
|
||||
* This function updates an INI style config file.
|
||||
*
|
||||
|
@ -395,7 +398,7 @@ class AirtimeIni{
|
|||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
|
||||
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.";
|
||||
|
@ -453,7 +456,7 @@ class AirtimeIni{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function upgradeConfigFiles(){
|
||||
|
||||
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
||||
|
@ -462,7 +465,7 @@ class AirtimeIni{
|
|||
AirtimeIni::CONF_FILE_LIQUIDSOAP);
|
||||
|
||||
// Backup the config files
|
||||
$suffix = date("Ymdhis")."-1.8.1";
|
||||
$suffix = date("Ymdhis")."-1.9.0";
|
||||
foreach ($configFiles as $conf) {
|
||||
if (file_exists($conf)) {
|
||||
echo "Backing up $conf to $conf$suffix.bak".PHP_EOL;
|
||||
|
@ -485,7 +488,7 @@ class AirtimeIni{
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc');
|
||||
$AIRTIME_PYTHON_APPS = realpath(__DIR__.'/../../../python_apps');
|
||||
|
||||
|
@ -530,7 +533,7 @@ class Airtime190Upgrade{
|
|||
}
|
||||
|
||||
/* Removes pypo, media-monitor, show-recorder and utils from system. These will
|
||||
* be reinstalled by the main airtime-upgrade script.
|
||||
* be reinstalled by the main airtime-upgrade script.
|
||||
*/
|
||||
public static function UninstallBinaries()
|
||||
{
|
||||
|
@ -558,7 +561,7 @@ class Airtime190Upgrade{
|
|||
echo "* Failed sql query: $sql".PHP_EOL;
|
||||
echo "* Message {$result->getMessage()}".PHP_EOL;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -604,11 +607,11 @@ class Airtime190Upgrade{
|
|||
if (!copy(__DIR__."/../../../python_apps/api_clients/api_client.cfg", AirtimeIni::CONF_FILE_API_CLIENT)){
|
||||
echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
|
||||
}
|
||||
|
||||
|
||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_API_CLIENT, "api_key", $values["general"]["api_key"]);
|
||||
|
||||
|
||||
echo "Reorganizing files in stor directory".PHP_EOL;
|
||||
|
||||
|
||||
$cwd = __DIR__;
|
||||
$mediaMonitorUpgradePath = __DIR__."/media-monitor-upgrade.py";
|
||||
$command = "cd $cwd && su -c \"python $mediaMonitorUpgradePath\"";
|
||||
|
@ -624,6 +627,20 @@ class Airtime190Upgrade{
|
|||
echo $sql.PHP_EOL;
|
||||
Airtime190Upgrade::execSqlQuery($sql);
|
||||
}
|
||||
|
||||
echo "Upgrading Linked Files".PHP_EOL;
|
||||
|
||||
//HANDLE LINKED FILES HERE.
|
||||
|
||||
$files = CcFilesQuery::create()
|
||||
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
|
||||
->filterByDbDirectory(NULL)
|
||||
->find();
|
||||
|
||||
// You won't get a Fatal error for not enough memory with the following code
|
||||
foreach($db_files as $db_file) {
|
||||
echo $db_file->DbTrackTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue