Skip to content

opensips-cli defaults to MySQL despite PostgreSQL being installed #112

Open

Description

@Vince-H1

Hi Team,
I've noticed that when using the database create command in opensips-cli, it automatically selects MySQL, even though I have PostgreSQL correctly installed on my system. I have double-checked the configurations and ensured PostgreSQL's availability, yet the CLI tool seems to prioritize MySQL.

opensips-cli is installed via get.
#dpkg -l | grep opensips
ii opensips 3.4.1-1 amd64 very fast and configurable SIP server
ii opensips-cli 0.120230512161b5ea-1 all Interactive command-line tool for OpenSIPS 3.0+
ii opensips-postgres-module:amd64 3.4.1-1 amd64 PostgreSQL database connectivity module for OpenSIPS

modules:
ls /usr/share/opensips/
dbtext menuconfig_templates postgres

Can I force opensips-cli to install it only on postgresql?

Regards,
Vincent

Activity

  1. self-assigned this
    on Oct 17, 2023
  2. liviuchircu commented on Oct 17, 2023

    @liviuchircu
    Member

    Hi @Vince-H1!

    If this is still an issue, I believe you have some lingering opensips-cli.cfg configuration which instructs it to default to MySQL. In decreasing order of importance, can you check the following files for any MySQL DB URLs? Moreover, the implicit database_url is mysql://opensips:opensipsrw@localhost, after all, which could be the source of your troubles!

    • ~/.opensips-cli.cfg
    • /etc/opensips-cli.cfg
    • /etc/opensips/opensips-cli.cfg
  3. Vince-H1 commented on Oct 17, 2023

    @Vince-H1
    Author

    Hi @liviuchircu,

    Thanks for the hint.
    I have had no opensips-cli.cfg file, I found in the repository the correct line to add:
    osips06# cat ~/.opensips-cli.cfg
    [default]
    log_level: WARNING
    prompt_name: cli
    prompt_intro: Welcome to CLI!
    prompt_emptyline_repeat_cmd: False
    history_file: ~/.opensips-cli.history
    history_file_size: 1000
    output_type: pretty-print
    communication_type: fifo
    fifo_file: /tmp/opensips_fifo
    domain: opensips.org
    database_admin_url: postgresql://root@localhost
    root@osips06:/usr/local/lib/python3.9/dist-packages# opensips-cli -x database create
    Password for admin PostgreSQL user (root):

    So the default was still to MySQL.

    Thanks for the help! :)
    cheers, Vincent

  4. liviuchircu commented on Oct 18, 2023

    @liviuchircu
    Member

    I see. Glad you could move past the issue.

    Now, whether this is a bug or not... I think it's ultimately best to leave database_url as it is, and not add too much bloat around it:

    • the default URL is MySQL based, documented here
    • adding logic for DB package detection could get cumbersome to maintain, with lots of random logical forks on several levels:
      • is it a dpkg listing? rpm? pacman? etc.
      • is the MySQL package named mysql-server, mariadb-server, percona-server or percona-xtradb-cluster, etc.
    • even if we were to add all this "detection" logic, how would you explain the behavior to CLI users? "The CLI tries to detect your SQL DB and use it, but only if it's a single DB install from a known package on a CLI-known distro?"
  5. Vince-H1 commented on Oct 18, 2023

    @Vince-H1
    Author

    Don't think it is a bug, it is more that I was not able to find that this step was needed.

    I notice I'm a step further but not able to get it fixed as I need it.

    root@osips06:/etc/opensips# cat ~/.opensips-cli.cfg
    [default]
    log_level: WARNING
    prompt_name: cli
    prompt_intro: Welcome to CLI!
    prompt_emptyline_repeat_cmd: False
    history_file: ~/.opensips-cli.history
    history_file_size: 1000
    output_type: pretty-print
    communication_type: fifo
    fifo_file: /tmp/opensips_fifo
    domain: vh-telefonie.nl
    database_admin_url: postgresql://sips:2023@localhost/opensips
    database_name: opensips

    root@osips06:/etc/opensips# opensips-cli -x database create

    Outcome at the moment is:

    sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: FATAL: database "sips" does not exist

    It is taking the username also as the Database name.
    I'm still searching and debugging what to put in here to get it correct

  6. liviuchircu commented on Oct 18, 2023

    @liviuchircu
    Member

    Could you run it in debug mode, using opensips-cli -d, and provide the output of the same database create attempt? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions