From 66e21d23dd5db9741e14e308711c472d6c5fd58b Mon Sep 17 00:00:00 2001 From: Liviu Chircu Date: Mon, 27 May 2024 16:47:25 +0300 Subject: [PATCH] Database: Add auto-detection for /usr/local/share/opensips This should improve CLI's behavior in scenarios where OpenSIPS is installed from sources (make && make install). Related to #126 --- opensipscli/modules/database.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/opensipscli/modules/database.py b/opensipscli/modules/database.py index a3e89cd..40a58e4 100644 --- a/opensipscli/modules/database.py +++ b/opensipscli/modules/database.py @@ -32,6 +32,7 @@ from collections import OrderedDict DEFAULT_DB_TEMPLATE = "template1" +OPENSIPS_SCHEMA_SRC_PATH = "/usr/local/share/opensips" STANDARD_DB_MODULES = [ "acc", @@ -927,9 +928,15 @@ def get_schema_path(self, backend="mysql"): db_path = os.path.dirname(db_path) if not os.path.exists(db_path): - logger.error("path '{}' to OpenSIPS DB scripts does not exist!". - format(db_path)) - return None + if not os.path.exists(OPENSIPS_SCHEMA_SRC_PATH): + logger.error("path '{}' to OpenSIPS DB scripts does not exist!". + format(db_path)) + return None + + logger.info("schema path '{}' not found, using '{}' instead (detected on system)". + format(db_path, OPENSIPS_SCHEMA_SRC_PATH)) + db_path = OPENSIPS_SCHEMA_SRC_PATH + if not os.path.isdir(db_path): logger.error("path '{}' to OpenSIPS DB scripts is not a directory!". format(db_path))