Skip to content

Commit

Permalink
Database: Add auto-detection for /usr/local/share/opensips
Browse files Browse the repository at this point in the history
This should improve CLI's behavior in scenarios where OpenSIPS is
installed from sources (make && make install).

Related to #126
  • Loading branch information
liviuchircu committed May 27, 2024
1 parent d0add90 commit 66e21d2
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions opensipscli/modules/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from collections import OrderedDict

DEFAULT_DB_TEMPLATE = "template1"
OPENSIPS_SCHEMA_SRC_PATH = "/usr/local/share/opensips"

STANDARD_DB_MODULES = [
"acc",
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 66e21d2

Please sign in to comment.