-cleaned up install scripts / renamed camp* functions to airtime*
This commit is contained in:
parent
2a8e8715d2
commit
740a157627
|
@ -70,8 +70,7 @@ function directorySetup($CC_CONFIG){
|
|||
//------------------------------------------------------------------------
|
||||
echo " *** Directory Setup ***\n";
|
||||
foreach (array('baseFilesDir', 'storageDir') as $d) {
|
||||
$test = file_exists($CC_CONFIG[$d]);
|
||||
if ( $test === FALSE ) {
|
||||
if ( !file_exists($CC_CONFIG[$d]) ) {
|
||||
@mkdir($CC_CONFIG[$d], 02775, true);
|
||||
if (file_exists($CC_CONFIG[$d])) {
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
|
@ -86,26 +85,21 @@ echo " *** Directory Setup ***\n";
|
|||
} else {
|
||||
$rp = realpath($CC_CONFIG[$d]);
|
||||
echo " * WARNING: Directory already exists, but is not writable: $rp\n";
|
||||
//exit(1);
|
||||
}
|
||||
$CC_CONFIG[$d] = $rp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
checkIfRoot();
|
||||
updateINIKeyValues('../build/build.properties', 'project.home', realpath(__dir__.'/../'));
|
||||
|
||||
echo "******************************** Install Begin *********************************\n";
|
||||
|
||||
echo " *** Database Installation ***\n";
|
||||
|
||||
|
||||
// Create the database user
|
||||
$command = "sudo -u postgres psql postgres --command \"CREATE USER {$CC_CONFIG['dsn']['username']} "
|
||||
." ENCRYPTED PASSWORD '{$CC_CONFIG['dsn']['password']}' LOGIN CREATEDB NOCREATEUSER;\" 2>/dev/null";
|
||||
//echo $command."\n";
|
||||
|
||||
@exec($command, $output, $results);
|
||||
if ($results == 0) {
|
||||
echo " * User {$CC_CONFIG['dsn']['username']} created.\n";
|
||||
|
@ -114,7 +108,6 @@ if ($results == 0) {
|
|||
}
|
||||
|
||||
$command = "sudo -u postgres createdb {$CC_CONFIG['dsn']['database']} --owner {$CC_CONFIG['dsn']['username']} 2> /dev/null";
|
||||
//echo $command."\n";
|
||||
@exec($command, $output, $results);
|
||||
if ($results == 0) {
|
||||
echo " * Database '{$CC_CONFIG['dsn']['database']}' created.\n";
|
||||
|
@ -123,14 +116,14 @@ if ($results == 0) {
|
|||
}
|
||||
|
||||
// Connect to DB
|
||||
campcaster_db_connect(true);
|
||||
airtime_db_connect(true);
|
||||
|
||||
// Install postgres scripting language
|
||||
$langIsInstalled = $CC_DBC->GetOne('SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'');
|
||||
if ($langIsInstalled == '0') {
|
||||
echo " * Installing Postgres scripting language\n";
|
||||
$sql = "CREATE LANGUAGE 'plpgsql'";
|
||||
camp_install_query($sql, false);
|
||||
airtime_install_query($sql, false);
|
||||
} else {
|
||||
echo " * Postgres scripting language already installed\n";
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ function airtime_uninstall_delete_files($p_path)
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
// Delete the database
|
||||
// Note: Do not put a call to campcaster_db_connect()
|
||||
// Note: Do not put a call to airtime_db_connect()
|
||||
// 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.
|
||||
//------------------------------------------------------------------------
|
||||
|
@ -48,12 +48,12 @@ $command = "sudo -u postgres dropdb {$CC_CONFIG['dsn']['database']} 2> /dev/null
|
|||
//------------------------------------------------------------------------
|
||||
if ($dbDeleteFailed) {
|
||||
echo " * Couldn't delete the database, so deleting all the DB tables...\n";
|
||||
campcaster_db_connect(true);
|
||||
airtime_db_connect(true);
|
||||
if (!PEAR::isError($CC_DBC)) {
|
||||
if (camp_db_table_exists($CC_CONFIG['prefTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['prefTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['prefTable'];
|
||||
camp_install_query($sql, false);
|
||||
airtime_install_query($sql, false);
|
||||
|
||||
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id");
|
||||
echo "done.\n";
|
||||
|
@ -62,10 +62,10 @@ if ($dbDeleteFailed) {
|
|||
}
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['transTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['transTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['transTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['transTable'];
|
||||
camp_install_query($sql, false);
|
||||
airtime_install_query($sql, false);
|
||||
|
||||
$CC_DBC->dropSequence($CC_CONFIG['transTable']."_id");
|
||||
echo "done.\n";
|
||||
|
@ -73,53 +73,48 @@ if ($dbDeleteFailed) {
|
|||
echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['filesTable']." CASCADE";
|
||||
camp_install_query($sql);
|
||||
airtime_install_query($sql);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['filesTable']."_id");
|
||||
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['playListTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['playListTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['playListTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['playListTable']." CASCADE";
|
||||
camp_install_query($sql);
|
||||
airtime_install_query($sql);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['playListTable']."_id");
|
||||
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['playListTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['playListContentsTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['playListContentsTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['playListContentsTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['playListContentsTable'];
|
||||
camp_install_query($sql);
|
||||
airtime_install_query($sql);
|
||||
$CC_DBC->dropSequence($CC_CONFIG['playListContentsTable']."_id");
|
||||
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['playListContentsTable']."\n";
|
||||
}
|
||||
|
||||
//if (camp_db_sequence_exists($CC_CONFIG['filesSequence'])) {
|
||||
// $sql = "DROP SEQUENCE ".$CC_CONFIG['filesSequence'];
|
||||
// camp_install_query($sql);
|
||||
//}
|
||||
//
|
||||
if (camp_db_table_exists($CC_CONFIG['accessTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['accessTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['accessTable'];
|
||||
camp_install_query($sql);
|
||||
airtime_install_query($sql);
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['accessTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['permTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['permTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['permTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['permTable'];
|
||||
camp_install_query($sql, false);
|
||||
airtime_install_query($sql, false);
|
||||
|
||||
$CC_DBC->dropSequence($CC_CONFIG['permTable']."_id");
|
||||
echo "done.\n";
|
||||
|
@ -127,30 +122,30 @@ if ($dbDeleteFailed) {
|
|||
echo " * Skipping: database table ".$CC_CONFIG['permTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['sessTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['sessTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['sessTable'];
|
||||
camp_install_query($sql);
|
||||
airtime_install_query($sql);
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['sessTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['subjTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['subjTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
|
||||
$CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id");
|
||||
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['subjTable']." CASCADE";
|
||||
camp_install_query($sql, false);
|
||||
airtime_install_query($sql, false);
|
||||
|
||||
echo "done.\n";
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['subjTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['smembTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['smembTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
|
||||
$sql = "DROP TABLE ".$CC_CONFIG['smembTable'];
|
||||
camp_install_query($sql, false);
|
||||
airtime_install_query($sql, false);
|
||||
|
||||
$CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id");
|
||||
echo "done.\n";
|
||||
|
@ -158,16 +153,16 @@ if ($dbDeleteFailed) {
|
|||
echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['scheduleTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['scheduleTable']."...";
|
||||
camp_install_query("DROP TABLE ".$CC_CONFIG['scheduleTable']);
|
||||
airtime_install_query("DROP TABLE ".$CC_CONFIG['scheduleTable']);
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['scheduleTable']."\n";
|
||||
}
|
||||
|
||||
if (camp_db_table_exists($CC_CONFIG['backupTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['backupTable'])) {
|
||||
echo " * Removing database table ".$CC_CONFIG['backupTable']."...";
|
||||
camp_install_query("DROP TABLE ".$CC_CONFIG['backupTable']);
|
||||
airtime_install_query("DROP TABLE ".$CC_CONFIG['backupTable']);
|
||||
} else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['backupTable']."\n";
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ if (!function_exists('pg_connect')) {
|
|||
|
||||
require_once(dirname(__FILE__).'/../library/pear/DB.php');
|
||||
|
||||
function camp_db_table_exists($p_name)
|
||||
function airtime_db_table_exists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
|
@ -17,18 +17,7 @@ function camp_db_table_exists($p_name)
|
|||
return true;
|
||||
}
|
||||
|
||||
function camp_db_sequence_exists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT 1 FROM pg_class where relname = '$p_name'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (!PEAR::isError($result) && $result == "1") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function camp_install_query($sql, $verbose = true)
|
||||
function airtime_install_query($sql, $verbose = true)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$result = $CC_DBC->query($sql);
|
||||
|
@ -43,7 +32,7 @@ function camp_install_query($sql, $verbose = true)
|
|||
}
|
||||
}
|
||||
|
||||
function campcaster_db_connect($p_exitOnError = true) {
|
||||
function airtime_db_connect($p_exitOnError = true) {
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
|
|
|
@ -29,7 +29,7 @@ function printUsage() {
|
|||
echo "Storage server: ". $CC_CONFIG["storageDir"] ."\n\n\n";
|
||||
}
|
||||
|
||||
function camp_clean_files($p_path) {
|
||||
function airtime_clean_files($p_path) {
|
||||
if (!empty($p_path) && (strlen($p_path) > 4)) {
|
||||
list($dirList,$fileList) = File_Find::maptree($p_path);
|
||||
|
||||
|
@ -62,7 +62,7 @@ function camp_clean_files($p_path) {
|
|||
}
|
||||
}
|
||||
|
||||
function camp_remove_files($p_path) {
|
||||
function airtime_remove_files($p_path) {
|
||||
|
||||
if (!empty($p_path) && (strlen($p_path) > 4)) {
|
||||
list($dirList,$fileList) = File_Find::maptree($p_path);
|
||||
|
@ -80,14 +80,14 @@ function camp_remove_files($p_path) {
|
|||
}
|
||||
}
|
||||
|
||||
function camp_empty_db($db) {
|
||||
function airtime_empty_db($db) {
|
||||
global $CC_CONFIG;
|
||||
|
||||
if (!PEAR::isError($db)) {
|
||||
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
if (airtime_db_table_exists($CC_CONFIG['filesTable'])) {
|
||||
echo " * Deleting from database table ".$CC_CONFIG['filesTable']."\n";
|
||||
$sql = "DELETE FROM ".$CC_CONFIG['filesTable'];
|
||||
camp_install_query($sql, false);
|
||||
airtime_install_query($sql, false);
|
||||
}
|
||||
else {
|
||||
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
|
||||
|
@ -110,12 +110,12 @@ switch($argv[1]){
|
|||
|
||||
case '-e':
|
||||
case '--empty':
|
||||
camp_empty_db($CC_DBC);
|
||||
camp_remove_files($CC_CONFIG['storageDir']);
|
||||
airtime_empty_db($CC_DBC);
|
||||
airtime_remove_files($CC_CONFIG['storageDir']);
|
||||
break;
|
||||
case '-c':
|
||||
case '--clean':
|
||||
camp_clean_files($CC_CONFIG['storageDir']);
|
||||
airtime_clean_files($CC_CONFIG['storageDir']);
|
||||
break;
|
||||
default:
|
||||
printUsage();
|
||||
|
|
Loading…
Reference in New Issue