CC-2279: Upgrade script for converting stor directory to new format
-make every function a static function and put into a class
This commit is contained in:
parent
aa1039413a
commit
232470c66b
|
@ -321,7 +321,7 @@ class AirtimeInstall{
|
||||||
INSERT INTO cc_country (isocode, name) VALUES ('ZWE', 'Zimbabwe ');";
|
INSERT INTO cc_country (isocode, name) VALUES ('ZWE', 'Zimbabwe ');";
|
||||||
|
|
||||||
echo "* Inserting data into country table".PHP_EOL;
|
echo "* Inserting data into country table".PHP_EOL;
|
||||||
execSqlQuery($sql);
|
Airtime190Upgrade::execSqlQuery($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ class AirtimeIni{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgradeConfigFiles(){
|
public static function upgradeConfigFiles(){
|
||||||
|
|
||||||
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
||||||
AirtimeIni::CONF_FILE_PYPO,
|
AirtimeIni::CONF_FILE_PYPO,
|
||||||
|
@ -443,7 +443,7 @@ class AirtimeIni{
|
||||||
* This function creates the /etc/airtime configuration folder
|
* This function creates the /etc/airtime configuration folder
|
||||||
* and copies the default config files to it.
|
* and copies the default config files to it.
|
||||||
*/
|
*/
|
||||||
function CreateIniFiles()
|
public static function CreateIniFiles()
|
||||||
{
|
{
|
||||||
if (!file_exists("/etc/airtime/")){
|
if (!file_exists("/etc/airtime/")){
|
||||||
if (!mkdir("/etc/airtime/", 0755, true)){
|
if (!mkdir("/etc/airtime/", 0755, true)){
|
||||||
|
@ -474,7 +474,9 @@ class AirtimeIni{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstallAirtimePhpServerCode($phpDir)
|
class Airtime190Upgrade{
|
||||||
|
|
||||||
|
public static function InstallAirtimePhpServerCode($phpDir)
|
||||||
{
|
{
|
||||||
|
|
||||||
$AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc');
|
$AIRTIME_SRC = realpath(__DIR__.'/../../../airtime_mvc');
|
||||||
|
@ -484,7 +486,7 @@ function InstallAirtimePhpServerCode($phpDir)
|
||||||
exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir);
|
exec("cp -R ".$AIRTIME_SRC."/* ".$phpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CopyUtils()
|
public static function CopyUtils()
|
||||||
{
|
{
|
||||||
$utilsSrc = __DIR__."/../../../utils";
|
$utilsSrc = __DIR__."/../../../utils";
|
||||||
|
|
||||||
|
@ -496,25 +498,25 @@ function CopyUtils()
|
||||||
/* Removes pypo, media-monitor, show-recorder and utils from system. These will
|
/* 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.
|
||||||
*/
|
*/
|
||||||
function UninstallBinaries()
|
public static function UninstallBinaries()
|
||||||
{
|
{
|
||||||
echo "* Removing Airtime binaries from ".CONF_DIR_BINARIES.PHP_EOL;
|
echo "* Removing Airtime binaries from ".CONF_DIR_BINARIES.PHP_EOL;
|
||||||
exec('rm -rf "'.CONF_DIR_BINARIES.'"');
|
exec('rm -rf "'.CONF_DIR_BINARIES.'"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function removeOldAirtimeImport(){
|
public static function removeOldAirtimeImport(){
|
||||||
exec('rm -f "/usr/bin/airtime-import"');
|
exec('rm -f "/usr/bin/airtime-import"');
|
||||||
exec('rm -f "/usr/lib/airtime/utils/airtime-import.php"');
|
exec('rm -f "/usr/lib/airtime/utils/airtime-import.php"');
|
||||||
exec('rm -rf "/usr/lib/airtime/utils/airtime-import"');
|
exec('rm -rf "/usr/lib/airtime/utils/airtime-import"');
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAirtimeImportSymLink(){
|
public static function updateAirtimeImportSymLink(){
|
||||||
$dir = "/usr/lib/airtime/utils/airtime-import/airtime-import";
|
$dir = "/usr/lib/airtime/utils/airtime-import/airtime-import";
|
||||||
exec("ln -s $dir /usr/bin/airtime-import");
|
exec("ln -s $dir /usr/bin/airtime-import");
|
||||||
}
|
}
|
||||||
|
|
||||||
function execSqlQuery($sql){
|
public static function execSqlQuery($sql){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
$result = $CC_DBC->query($sql);
|
$result = $CC_DBC->query($sql);
|
||||||
|
@ -526,7 +528,7 @@ function execSqlQuery($sql){
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectToDatabase(){
|
public static function connectToDatabase(){
|
||||||
global $CC_DBC, $CC_CONFIG;
|
global $CC_DBC, $CC_CONFIG;
|
||||||
|
|
||||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||||
|
@ -544,18 +546,18 @@ function connectToDatabase(){
|
||||||
/* Old database had a "fullpath" column that stored the absolute path of each track. We have to
|
/* Old database had a "fullpath" column that stored the absolute path of each track. We have to
|
||||||
* change it so that the "fullpath" column has path relative to the "directory" column.
|
* change it so that the "fullpath" column has path relative to the "directory" column.
|
||||||
*/
|
*/
|
||||||
function installMediaMonitor($values){
|
public static function installMediaMonitor($values){
|
||||||
|
|
||||||
/* Handle Database Changes. */
|
/* Handle Database Changes. */
|
||||||
$stor_dir = realpath($values['general']['base_files_dir']."/stor")."/";
|
$stor_dir = realpath($values['general']['base_files_dir']."/stor")."/";
|
||||||
echo "* Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
|
echo "* Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
|
||||||
$sql = "UPDATE cc_music_dirs SET directory='$stor_dir' WHERE type='stor'";
|
$sql = "UPDATE cc_music_dirs SET directory='$stor_dir' WHERE type='stor'";
|
||||||
echo $sql.PHP_EOL;
|
echo $sql.PHP_EOL;
|
||||||
execSqlQuery($sql);
|
Airtime190Upgrade::execSqlQuery($sql);
|
||||||
|
|
||||||
$sql = "SELECT id FROM cc_music_dirs WHERE type='stor'";
|
$sql = "SELECT id FROM cc_music_dirs WHERE type='stor'";
|
||||||
echo $sql.PHP_EOL;
|
echo $sql.PHP_EOL;
|
||||||
$rows = execSqlQuery($sql);
|
$rows = Airtime190Upgrade::execSqlQuery($sql);
|
||||||
|
|
||||||
echo "Creating media-monitor log file";
|
echo "Creating media-monitor log file";
|
||||||
mkdir("/var/log/airtime/media-monitor/", 755, true);
|
mkdir("/var/log/airtime/media-monitor/", 755, true);
|
||||||
|
@ -580,9 +582,12 @@ function installMediaMonitor($values){
|
||||||
$absPathOld = pg_escape_string($pair[0]);
|
$absPathOld = pg_escape_string($pair[0]);
|
||||||
$sql = "UPDATE cc_files SET filepath = '$relPathNew', directory=1 WHERE filepath = '$absPathOld'";
|
$sql = "UPDATE cc_files SET filepath = '$relPathNew', directory=1 WHERE filepath = '$absPathOld'";
|
||||||
echo $sql.PHP_EOL;
|
echo $sql.PHP_EOL;
|
||||||
execSqlQuery($sql);
|
Airtime190Upgrade::execSqlQuery($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AirtimeInstall::CreateZendPhpLogFile();
|
AirtimeInstall::CreateZendPhpLogFile();
|
||||||
|
@ -624,19 +629,19 @@ foreach ($pathnames as $pn){
|
||||||
/* update Airtime Server PHP files */
|
/* update Airtime Server PHP files */
|
||||||
$values = parse_ini_file(AirtimeIni::CONF_FILE_AIRTIME, true);
|
$values = parse_ini_file(AirtimeIni::CONF_FILE_AIRTIME, true);
|
||||||
$phpDir = $values['general']['airtime_dir'];
|
$phpDir = $values['general']['airtime_dir'];
|
||||||
InstallAirtimePhpServerCode($phpDir);
|
Airtime190Upgrade::InstallAirtimePhpServerCode($phpDir);
|
||||||
|
|
||||||
/* update utils (/usr/lib/airtime) folder */
|
/* update utils (/usr/lib/airtime) folder */
|
||||||
UninstallBinaries();
|
Airtime190Upgrade::UninstallBinaries();
|
||||||
CopyUtils();
|
Airtime190Upgrade::CopyUtils();
|
||||||
|
|
||||||
/* James made a new airtime-import script, lets remove the old airtime-import php script,
|
/* James made a new airtime-import script, lets remove the old airtime-import php script,
|
||||||
*install the new airtime-import.py script and update the /usr/bin/symlink.
|
*install the new airtime-import.py script and update the /usr/bin/symlink.
|
||||||
*/
|
*/
|
||||||
removeOldAirtimeImport();
|
Airtime190Upgrade::removeOldAirtimeImport();
|
||||||
updateAirtimeImportSymLink();
|
Airtime190Upgrade::updateAirtimeImportSymLink();
|
||||||
|
|
||||||
connectToDatabase();
|
Airtime190Upgrade::connectToDatabase();
|
||||||
|
|
||||||
if(AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
|
if(AirtimeInstall::DbTableExists('doctrine_migration_versions') === false) {
|
||||||
$migrations = array('20110312121200', '20110331111708', '20110402164819', '20110406182005');
|
$migrations = array('20110312121200', '20110331111708', '20110402164819', '20110406182005');
|
||||||
|
@ -654,7 +659,7 @@ AirtimeInstall::InsertCountryDataIntoDatabase();
|
||||||
/* create cron file for phone home stat */
|
/* create cron file for phone home stat */
|
||||||
AirtimeInstall::CreateCronFile();
|
AirtimeInstall::CreateCronFile();
|
||||||
|
|
||||||
installMediaMonitor($values);
|
Airtime190Upgrade::installMediaMonitor($values);
|
||||||
|
|
||||||
AirtimeIni::upgradeConfigFiles();
|
AirtimeIni::upgradeConfigFiles();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue