mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-07 20:23:51 +00:00
Change. Use require "resources.functions.config" to load config file.
Change. Move `script_dir` definition into config file.
This commit is contained in:
@@ -24,6 +24,22 @@
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
global $IS_WINDOWS;
|
||||
|
||||
if ($IS_WINDOWS == null) {
|
||||
if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; }
|
||||
}
|
||||
|
||||
if (!function_exists('correct_path')) {
|
||||
function correct_path($p) {
|
||||
global $IS_WINDOWS;
|
||||
if ($IS_WINDOWS) {
|
||||
return str_replace('/', '\\', $p);
|
||||
}
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
|
||||
//proccess this only one time
|
||||
if ($domains_processed == 1) {
|
||||
|
||||
@@ -113,28 +129,31 @@ if ($domains_processed == 1) {
|
||||
$tmp = "\n";
|
||||
$tmp .= "--set the variables\n";
|
||||
if (strlen($_SESSION['switch']['sounds']['dir']) > 0) {
|
||||
$tmp .= " sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n";
|
||||
$tmp .= correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n");
|
||||
}
|
||||
if (strlen($_SESSION['switch']['db']['dir']) > 0) {
|
||||
$tmp .= " database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n";
|
||||
$tmp .= correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n");
|
||||
}
|
||||
if (strlen($_SESSION['switch']['recordings']['dir']) > 0) {
|
||||
$tmp .= " recordings_dir = [[".$recordings_dir."]];\n";
|
||||
$tmp .= correct_path(" recordings_dir = [[".$recordings_dir."]];\n");
|
||||
}
|
||||
if (strlen($_SESSION['switch']['storage']['dir']) > 0) {
|
||||
$tmp .= " storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n";
|
||||
$tmp .= correct_path(" storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n");
|
||||
}
|
||||
if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) {
|
||||
$tmp .= " voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n";
|
||||
$tmp .= correct_path(" voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n");
|
||||
}
|
||||
$tmp .= " php_dir = [[".PHP_BINDIR."]];\n";
|
||||
if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
|
||||
$tmp .= correct_path(" scripts_dir = [[".$_SESSION['switch']['scripts']['dir']."]];\n");
|
||||
}
|
||||
$tmp .= correct_path(" php_dir = [[".PHP_BINDIR."]];\n");
|
||||
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
|
||||
$tmp .= " php_bin = \"php.exe\";\n";
|
||||
}
|
||||
else {
|
||||
$tmp .= " php_bin = \"php\";\n";
|
||||
}
|
||||
$tmp .= " document_root = [[".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."]];\n";
|
||||
$tmp .= correct_path(" document_root = [[".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."]];\n");
|
||||
$tmp .= "\n";
|
||||
|
||||
if ((strlen($db_type) > 0) || (strlen($dsn_name) > 0)) {
|
||||
@@ -142,7 +161,7 @@ if ($domains_processed == 1) {
|
||||
$tmp .= " database = {}\n";
|
||||
$tmp .= " database[\"type\"] = \"".$db_type."\";\n";
|
||||
$tmp .= " database[\"name\"] = \"".$db_name."\";\n";
|
||||
$tmp .= " database[\"path\"] = \"".$db_path."\";\n";
|
||||
$tmp .= correct_path(" database[\"path\"] = [[".$db_path."]];\n");
|
||||
|
||||
if (strlen($dsn_name) > 0) {
|
||||
$tmp .= " database[\"system\"] = \"odbc://".$dsn_name.":".$dsn_username.":".$dsn_password."\";\n";
|
||||
@@ -166,19 +185,19 @@ if ($domains_processed == 1) {
|
||||
|
||||
$tmp .= "--additional info\n";
|
||||
$tmp .= " domain_count = ".count($_SESSION["domains"]).";\n";
|
||||
$tmp .= " temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n";
|
||||
$tmp .= correct_path(" temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n");
|
||||
if (isset($_SESSION['domain']['dial_string']['text'])) {
|
||||
$tmp .= " dial_string = \"".$_SESSION['domain']['dial_string']['text']."\";\n";
|
||||
}
|
||||
$tmp .= "\n";
|
||||
$tmp .= "--include local.lua\n";
|
||||
$tmp .= " dofile(scripts_dir..\"/resources/functions/file_exists.lua\");\n";
|
||||
$tmp .= " require(\"resources.functions.file_exists\");\n";
|
||||
$tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n";
|
||||
$tmp .= " dofile(\"/etc/fusionpbx/local.lua\");\n";
|
||||
$tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n";
|
||||
$tmp .= " dofile(\"/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 .= " require(\"resources.local\");\n";
|
||||
$tmp .= " end\n";
|
||||
fwrite($fout, $tmp);
|
||||
unset($tmp);
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--get the argv values
|
||||
script_name = argv[0];
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
--get the scripts directory and include the config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--additional includes
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
|
||||
@@ -26,9 +26,7 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -44,11 +44,6 @@
|
||||
tries = 0;
|
||||
profile = "internal";
|
||||
|
||||
--include config.lua
|
||||
--scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
--dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
--dofile(config());
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
dbh = database_handle('system');
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
require "resources.functions.config";
|
||||
|
||||
--set variables
|
||||
max_tries = "3";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--include the lua script
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--define general settings
|
||||
sleep = 300;
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
digit_timeout = "5000";
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--general functions
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
|
||||
@@ -51,9 +51,7 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--check if the session is ready
|
||||
if (session:ready()) then
|
||||
|
||||
@@ -79,9 +79,7 @@
|
||||
end;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--check if the session is ready
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -34,9 +34,7 @@
|
||||
db_extension_uuid = "";
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -34,14 +34,7 @@
|
||||
search_count = 0;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
debug["sql"] = true;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -31,9 +31,7 @@ digit_timeout = "5000";
|
||||
debug["sql"] = true;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -51,9 +51,7 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--check if the session is ready
|
||||
if ( session:ready() ) then
|
||||
|
||||
@@ -28,9 +28,7 @@ digit_timeout = "5000";
|
||||
extension = argv[1];
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--add the file_exists function
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
-- Riccardo Granchi <riccardo.granchi@nems.it>
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -51,9 +51,7 @@
|
||||
api = freeswitch.API();
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--check if the session is ready
|
||||
if ( session:ready() ) then
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
if (file_exists(database_dir.."/core.db")) then
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
debug["sql"] = false;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--add the function
|
||||
dofile(scripts_dir.."/resources/functions/explode.lua");
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
debug["tries"] = false;
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
--action lua park.lua
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
--then send presence terminate, and delete from the database
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
--dbh = freeswitch.Dbh("core:core"); -- when using sqlite
|
||||
|
||||
@@ -34,9 +34,7 @@
|
||||
recording_prefix = "";
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -1,12 +1,26 @@
|
||||
|
||||
-- add file_exists function
|
||||
require "resources.functions.file_exists";
|
||||
|
||||
--find and return path to the config.lua
|
||||
function config()
|
||||
dofile(scripts_dir.."/resources/functions/file_exists.lua");
|
||||
if (file_exists("/etc/fusionpbx/config.lua")) then
|
||||
return "/etc/fusionpbx/config.lua";
|
||||
elseif (file_exists("/usr/local/etc/fusionpbx/config.lua")) then
|
||||
return "/usr/local/etc/fusionpbx/config.lua";
|
||||
else
|
||||
return scripts_dir.."/resources/config.lua";
|
||||
return "resources.config";
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- load config
|
||||
function load_config()
|
||||
local cfg = config()
|
||||
if cfg:sub(1,1) == '//' then
|
||||
dofile(cfg)
|
||||
else
|
||||
require(cfg)
|
||||
end
|
||||
end
|
||||
|
||||
load_config()
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
file_name = argv[1];
|
||||
|
||||
--include config.lua
|
||||
scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1));
|
||||
dofile(scripts_dir.."/resources/functions/config.lua");
|
||||
dofile(config());
|
||||
require "resources.functions.config";
|
||||
|
||||
--connect to the database
|
||||
dofile(scripts_dir.."/resources/functions/database_handle.lua");
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
These entries will be pre-pended to the LUA_PATH environment variable
|
||||
-->
|
||||
<!-- <param name="script-directory" value="/usr/local/lua/?.lua"/> -->
|
||||
<!-- <param name="script-directory" value="$${base_dir}/scripts/?.lua"/> -->
|
||||
|
||||
<param name="script-directory" value="$${base_dir}/scripts/?.lua"/>
|
||||
<param name="xml-handler-script" value="app.lua xml_handler"/>
|
||||
<param name="xml-handler-bindings" value="configuration,dialplan,directory"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user