diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index ae6f9ce2c..cc22213f2 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -300,7 +300,7 @@ class AirtimeInstall { global $CC_DBC; - $defaultTimezone = date_default_timezone_get(); + $defaultTimezone = exec("cat /etc/timezone"); $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')"; $result = $CC_DBC->query($sql); diff --git a/install_minimal/include/airtime-uninstall.php b/install_minimal/include/airtime-uninstall.php index 4f9e4b661..44a7d4126 100644 --- a/install_minimal/include/airtime-uninstall.php +++ b/install_minimal/include/airtime-uninstall.php @@ -28,10 +28,16 @@ echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL; // 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"; +//close connection for any process id using airtime database since we are about to drop the database. +$sql = "SELECT pg_cancel_backend(procpid) FROM pg_stat_activity WHERE datname = 'airtime';"; +$command = "echo \"$sql\" | su postgres -c psql"; +@exec($command, $output); + +echo " * Dropping the database '".$CC_CONFIG["dsn"]["database"]."'...".PHP_EOL; + +//dropdb returns 1 if other sessions are using the database, otherwise returns 0 +$command = "su postgres -c \"dropdb ".$CC_CONFIG["dsn"]["database"]."\""; @exec($command, $output, $dbDeleteFailed);