OpenSIPS / opensips-cli

OpenSIPS CLI tool - an interactive command line tool that can be used to control and monitor OpenSIPS servers.
GNU General Public License v3.0
84 stars 46 forks source link

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

Open Vince-H1 opened 10 months ago

Vince-H1 commented 10 months ago

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.1~20230512~161b5ea-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

liviuchircu commented 9 months ago

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!

Vince-H1 commented 9 months ago

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

liviuchircu commented 9 months ago

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:

Vince-H1 commented 9 months ago

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

liviuchircu commented 9 months ago

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