ugoviti / izpbx

izPBX is a Turnkey Cloud Native Telephony System powered by Asterisk Engine and FreePBX Management GUI
GNU General Public License v3.0
179 stars 74 forks source link

Different port for mysql doesn't work #40

Closed danialb007 closed 1 year ago

danialb007 commented 1 year ago

Greetings. Great project. I found a bug which makes it impossible to initialize MySQL db on non-default port (3306) So let's say we want to load it up on port 3307, we just have to change the #APP_PORT_MYSQL var in .env file but the thing is that in this file izpbx-asterisk/rootfs/entrypoint-hooks.sh line 1078 we are changing mysql server address if the port is not 3306 and we are appending the port to the address itself which is wrong and creates a problem. This is the error log that gets printed to the console: ERROR 2005 (HY000): Unknown MySQL server host '127.0.0.1:3307' (-2).

Also notice line 1011 :

mysqlQuery() {
    mysql -h ${MYSQL_SERVER} -P ${APP_PORT_MYSQL} -u ${MYSQL_ROOT_USER} --password=${MYSQL_ROOT_PASSWORD} -N -B -e "$@"
  }

The fix would be to remove or comment this: izpbx-asterisk/rootfs/entrypoint-hooks.sh:1078

ugoviti commented 1 year ago

Hi danialb,

Thank you for the bug report...

I tried to make a new install from scratch changing and I seen the problem.

anyway, the freepbx ./install script seems broken, because it doesn't works using these options:

(izPBX)[root@jlt.local: /usr/src/freepbx]# cd /usr/src/freepbx ; ./install -n --skip-install --no-ansi --dbhost=127.0.0.1 --dbport=3307 --dbuser=asterisk --dbpass=CHANGEM3 --dbname=asterisk --cdrdbname=asteriskcdrdb --webroot=/data/var/www/html --as
tetcdir=/data/etc/asterisk --astmoddir= --astvarlibdir=/data/var/lib/asterisk --astagidir=/data/var/lib/asterisk/agi-bin --astspooldir=/data/var/spool/asterisk --astrundir=/var/run/asterisk --astlogdir=/data/var/log/asterisk --ampbin=/data/var/lib/asterisk/bin --ampsbin=/data/var/lib/asterisk/sbin --ampcgibin=/data/var/www/cgi-bin --ampplayback=/data/var/lib/asterisk/playback -vvv
Checking if SELinux is enabled...Its not (good)!
Reading /etc/asterisk/asterisk.conf...Done
Checking if Asterisk is running and we can talk to it as the 'asterisk' user...Yes. Determined Asterisk version to be: 20.0.0
Checking if NodeJS is installed and we can get a version from it...Yes. Determined NodeJS version to be: 10.24.0
Preliminary checks done. Starting FreePBX Installation
Checking if this is a new install...Yes (No /etc/freepbx.conf file detected)
Database installation checking credentials and permissions..Error!
Invalid Database Permissions. The error was: **SQLSTATE[HY000] [2002] Connection refused**

But, as you can see, the port and the connection is correct:

(izPBX)[root@jlt.local: /usr/src/freepbx]# mysql -h 127.0.0.1 -P3307 -u asterisk -pCHANGEM3 -e 'show databases;'
+--------------------+
| Database           |
+--------------------+
| asterisk           |
| asteriskcdrdb      |
| information_schema |
+--------------------+

I think this is a bug on FreePBX install script that doesn't support custom ports other than 3306.

using APP_PORT_MYSQL=3306 the command works:

./install -n --skip-install --no-ansi --dbhost=127.0.0.1 --dbport=3306 --dbuser=asterisk --dbpass=CHANGEM3 --dbname=asterisk --cdrdbname=asteriskcdrdb --webroot=/data/var/www/html --astetcdir=/data/etc/asterisk --astmoddir= --astvarlibdir=/data/var/lib/asterisk --astagidir=/data/var/lib/asterisk/agi-bin --astspooldir=/data/var/spool/asterisk --astrundir=/var/run/asterisk --astlogdir=/data/var/log/asterisk --ampbin=/data/var/lib/asterisk/bin --ampsbin=/data/var/lib/asterisk/sbin --ampcgibin=/data/var/www/cgi-bin --ampplayback=/data/var/lib/asterisk/playback

Can you open a ticket into FreePBX issue traking?

Thank you

danialb007 commented 1 year ago

Ah so the problem is related to freepbx itself. Thank you for you time and i would open a ticket to freebox issue tracking

ugoviti commented 1 year ago

Please report here the FreePBX issue number, so I can add a comment.

Thank you!

thardie commented 1 year ago

Looks like this issue is back. I just tried with izpbx version 20.16.9 and get the original error again. I can see the install script is passing the --dbport, but it fails in the same way. I see a new bug logged against FreePBX: https://issues.freepbx.org/browse/FREEPBX-24066