diff --git a/install/airtime-db-install.php b/install/airtime-db-install.php new file mode 100644 index 000000000..18db57f3b --- /dev/null +++ b/install/airtime-db-install.php @@ -0,0 +1,23 @@ + 'Displays usage information.', 'overwrite|o' => 'Overwrite any existing config files.', - 'preserve|p' => 'Keep any existing config files.' + 'preserve|p' => 'Keep any existing config files.', + 'no-db|n' => 'Turn off database install.' ) ); $opts->parse(); @@ -34,6 +35,10 @@ if (isset($opts->h)) { echo $opts->getUsageMessage(); exit; } +$db_install = true; +if (isset($opts->n)){ + $db_install = false; +} $overwrite = false; if (isset($opts->o)) { @@ -72,17 +77,21 @@ require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php') echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL; +if ($db_install) { + //echo PHP_EOL."*** Database Installation ***".PHP_EOL; -AirtimeInstall::CreateDatabaseUser(); +/* AirtimeInstall::CreateDatabaseUser(); -AirtimeInstall::CreateDatabase(); + AirtimeInstall::CreateDatabase(); -AirtimeInstall::DbConnect(true); + AirtimeInstall::DbConnect(true); -AirtimeInstall::InstallPostgresScriptingLanguage(); + AirtimeInstall::InstallPostgresScriptingLanguage(); -AirtimeInstall::CreateDatabaseTables(); + AirtimeInstall::CreateDatabaseTables();*/ + require( 'airtime-db-install.php' ); +} AirtimeInstall::InstallStorageDirectory(); diff --git a/install/airtime-uninstall.php b/install/airtime-uninstall.php index 7513c874a..065ff6f68 100644 --- a/install/airtime-uninstall.php +++ b/install/airtime-uninstall.php @@ -29,7 +29,10 @@ AirtimeInstall::UninstallPhpCode(); // 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; -$command = "su postgres -c \"dropdb {$CC_CONFIG['dsn']['database']}\""; + +// check if DB exists +$command = "echo \"DROP DATABASE IF EXISTS ".$CC_CONFIG['dsn']['database']."\" | sudo -u postgres psql"; + @exec($command, $output, $dbDeleteFailed); //------------------------------------------------------------------------ @@ -66,7 +69,7 @@ if ($dbDeleteFailed) { // Delete the user //------------------------------------------------------------------------ echo " * Deleting database user '{$CC_CONFIG['dsn']['username']}'...".PHP_EOL; -$command = "echo \"DROP USER {$CC_CONFIG['dsn']['username']}\" | su postgres -c psql"; +$command = "echo \"DROP USER IF EXISTS {$CC_CONFIG['dsn']['username']}\" | su postgres -c psql"; @exec($command, $output, $results); if ($results == 0) { echo " * User '{$CC_CONFIG['dsn']['username']}' deleted.".PHP_EOL;