diff --git a/core/databases/app_defaults.php b/core/databases/app_defaults.php index a47eb106d0..7dafbcdf31 100644 --- a/core/databases/app_defaults.php +++ b/core/databases/app_defaults.php @@ -98,76 +98,78 @@ if ($domains_processed == 1) { } //config.lua - if (is_dir("/etc/fusionpbx")){ - $config = "/etc/fusionpbx/config.lua"; - } elseif (is_dir("/usr/local/etc/fusionpbx")){ - $config = "/usr/local/etc/fusionpbx/config.lua"; - } - else { - $config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua"; - } - $fout = fopen($config,"w"); - $tmp = "\n"; - $tmp .= "--switch directories\n"; - if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { - $tmp .= " sounds_dir = \"".$_SESSION['switch']['sounds']['dir']."\";\n"; - } - if (strlen($_SESSION['switch']['db']['dir']) > 0) { - $tmp .= " database_dir = \"".$_SESSION['switch']['db']['dir']."\";\n"; - } - if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { - $tmp .= " recordings_dir = \"".$recordings_dir."\";\n"; - } - if (strlen($_SESSION['switch']['storage']['dir']) > 0) { - $tmp .= " storage_dir = \"".$_SESSION['switch']['storage']['dir']."\";\n"; - } - if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) { - $tmp .= " voicemail_dir = \"".$_SESSION['switch']['voicemail']['dir']."\";\n"; - } - $tmp .= "\n"; - $tmp .= "--database information\n"; - $tmp .= " database = {}\n"; - $tmp .= " database[\"type\"] = \"".$db_type."\";\n"; - $tmp .= " database[\"name\"] = \"".$db_name."\";\n"; - $tmp .= " database[\"path\"] = \"".$db_path."\";\n"; - - if ($db_type == "pgsql") { - if ($db_host == "localhost") { $db_host = "127.0.0.1"; } - $tmp .= " database[\"system\"] = \"pgsql://hostaddr=".$db_host." port=".$db_port." dbname=".$db_name." user=".$db_username." password=".$db_password." options='-c client_min_messages=NOTICE' application_name='".$db_name."'\";\n"; - $tmp .= " database[\"switch\"] = \"pgsql://hostaddr=".$db_host." port=".$db_port." dbname=freeswitch user=".$db_username." password=".$db_password." options='-c client_min_messages=NOTICE' application_name='freeswitch'\";\n"; - } - elseif ($db_type == "sqlite") { - $tmp .= " database[\"system\"] = \"sqlite://".$db_path."/".$db_name."\";\n"; - $tmp .= " database[\"switch\"] = \"sqlite://".$_SESSION['switch']['db']['dir']."\";\n"; - } - elseif ($db_type == "mysql") { - if (strlen($dsn_name) > 0) { - $tmp .= " database[\"system\"] = \"odbc://".$dsn_name.":".$dsn_username.":".$dsn_password."\";\n"; - $tmp .= " database[\"switch\"] = \"odbc://freeswitch:".$dsn_username.":".$dsn_password."\";\n"; + if (strlen($db_type) > 0) { + if (is_dir("/etc/fusionpbx")){ + $config = "/etc/fusionpbx/config.lua"; + } elseif (is_dir("/usr/local/etc/fusionpbx")){ + $config = "/usr/local/etc/fusionpbx/config.lua"; } else { - $tmp .= " database[\"system\"] = \"\";\n"; - $tmp .= " database[\"switch\"] = \"\";\n"; + $config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua"; } - } + $fout = fopen($config,"w"); + $tmp = "\n"; + $tmp .= "--switch directories\n"; + if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { + $tmp .= " sounds_dir = \"".$_SESSION['switch']['sounds']['dir']."\";\n"; + } + if (strlen($_SESSION['switch']['db']['dir']) > 0) { + $tmp .= " database_dir = \"".$_SESSION['switch']['db']['dir']."\";\n"; + } + if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { + $tmp .= " recordings_dir = \"".$recordings_dir."\";\n"; + } + if (strlen($_SESSION['switch']['storage']['dir']) > 0) { + $tmp .= " storage_dir = \"".$_SESSION['switch']['storage']['dir']."\";\n"; + } + if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) { + $tmp .= " voicemail_dir = \"".$_SESSION['switch']['voicemail']['dir']."\";\n"; + } + $tmp .= "\n"; + $tmp .= "--database information\n"; + $tmp .= " database = {}\n"; + $tmp .= " database[\"type\"] = \"".$db_type."\";\n"; + $tmp .= " database[\"name\"] = \"".$db_name."\";\n"; + $tmp .= " database[\"path\"] = \"".$db_path."\";\n"; - $tmp .= "\n"; - $tmp .= "--additional info\n"; - $tmp .= " domain_count = ".count($_SESSION["domains"]).";\n"; - $tmp .= " temp_dir = \"".$_SESSION['server']['temp']['dir']."\";\n"; - $tmp .= "\n"; - $tmp .= "--include local.lua\n"; - $tmp .= " dofile(scripts_dir..\"/resources/functions/file_exists.lua\");\n"; - $tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n"; - $tmp .= " dofile(scripts_dir..\"/etc/fusionpbx/local.lua\");\n"; - $tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n"; - $tmp .= " dofile(scripts_dir..\"/usr/local/etc/fusionpbx/local.lua\");\n"; - $tmp .= " elseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n"; - $tmp .= " dofile(scripts_dir..\"/resources/local.lua\");\n"; - $tmp .= " end\n"; - fwrite($fout, $tmp); - unset($tmp); - fclose($fout); + if ($db_type == "pgsql") { + if ($db_host == "localhost") { $db_host = "127.0.0.1"; } + $tmp .= " database[\"system\"] = \"pgsql://hostaddr=".$db_host." port=".$db_port." dbname=".$db_name." user=".$db_username." password=".$db_password." options='-c client_min_messages=NOTICE' application_name='".$db_name."'\";\n"; + $tmp .= " database[\"switch\"] = \"pgsql://hostaddr=".$db_host." port=".$db_port." dbname=freeswitch user=".$db_username." password=".$db_password." options='-c client_min_messages=NOTICE' application_name='freeswitch'\";\n"; + } + elseif ($db_type == "sqlite") { + $tmp .= " database[\"system\"] = \"sqlite://".$db_path."/".$db_name."\";\n"; + $tmp .= " database[\"switch\"] = \"sqlite://".$_SESSION['switch']['db']['dir']."\";\n"; + } + elseif ($db_type == "mysql") { + if (strlen($dsn_name) > 0) { + $tmp .= " database[\"system\"] = \"odbc://".$dsn_name.":".$dsn_username.":".$dsn_password."\";\n"; + $tmp .= " database[\"switch\"] = \"odbc://freeswitch:".$dsn_username.":".$dsn_password."\";\n"; + } + else { + $tmp .= " database[\"system\"] = \"\";\n"; + $tmp .= " database[\"switch\"] = \"\";\n"; + } + } + + $tmp .= "\n"; + $tmp .= "--additional info\n"; + $tmp .= " domain_count = ".count($_SESSION["domains"]).";\n"; + $tmp .= " temp_dir = \"".$_SESSION['server']['temp']['dir']."\";\n"; + $tmp .= "\n"; + $tmp .= "--include local.lua\n"; + $tmp .= " dofile(scripts_dir..\"/resources/functions/file_exists.lua\");\n"; + $tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n"; + $tmp .= " dofile(scripts_dir..\"/etc/fusionpbx/local.lua\");\n"; + $tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n"; + $tmp .= " dofile(scripts_dir..\"/usr/local/etc/fusionpbx/local.lua\");\n"; + $tmp .= " elseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n"; + $tmp .= " dofile(scripts_dir..\"/resources/local.lua\");\n"; + $tmp .= " end\n"; + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + } } } ?> \ No newline at end of file