ugoviti / izpbx

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

Create DB if it doesn't exist #17

Closed hyavari closed 3 years ago

hyavari commented 3 years ago

I think it would be good to add a checking script in entrypoint-hooks.sh and checks if "asterisk" DB doesn't exist, create it before installation. It removes the dependency/ limitation of one DB creation in DB docker.

Something like this:

mysql -h ${MYSQL_SERVER} -P ${APP_PORT_MYSQL} -u root --password=${MYSQL_ROOT_PASSWORD} -B -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE}"

ugoviti commented 3 years ago

Hi,

thank you for your feedback.

Can you give me more details?

When starting izPBX for the first time, is FreePBX install script that create the missing 'asterisk' and 'asteriskcdrdb' database, what is the problem that you are experiencing?

Thank you

hyavari commented 3 years ago

I am not sure about 'asterisk' DB. I checked again entrypoint* scripts but didn't find that point. Please let me know where you are creating 'asterisk'. As I know, we have to run a separate container for DB and create 'asterisk'.

But for running the second FPBX instance, you have to do it manually like 'asterisk2'. So, I think it would be good to handle it and create 'asterisk2' if it doesn't exist.

ugoviti commented 3 years ago

Hi,

the database will be created only if new installation is tirggered:

function cfgService_freepbx_install if [ ! -e ${APP_DATA}/.initialized ]

the database is created by ./install -n --skip-install --no-ansi --dbhost=${MYSQL_SERVER} --dbuser=${MYSQL_USER} --dbpass=${MYSQL_PASSWORD} ${FPBX_OPTS} command.

anyway I just pushed into dev branch the commit d324daad7727c87db6ab584e9439fe4390756ff0 to allow the use of custom asteriskcdrdb and the manual creation of db, before running ./install script

can you test and make me report before promoting to stable release?

CI is building right now, when pushed into docker hub, you can test with:

docker pull izdock/izpbx-asterisk:dev-18

Kind regards

ugoviti commented 3 years ago

closed by https://github.com/ugoviti/izdock-izpbx/commit/d324daad7727c87db6ab584e9439fe4390756ff0 and release 18.15.6

danielkucera commented 2 years ago

Hi, I'd like to avoid giving db root password. Can we do this only when MYSQL_ROOT_PASSWORD env var is defined?

danielkucera commented 2 years ago

Ah, it seems to be not an issue because after several retires it continues anyway:

ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[2/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[3/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[4/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[5/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[6/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[7/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[8/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[9/10]
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
--> WARNING: cannot connect to MySQL database 's.danman.eu'... waiting database to become ready... retrying in 10 seconds... try:[10/10]
--> installing FreePBX in '/data/var/www/html'
---> START install FreePBX @ Fri Jan 21 11:50:21 UTC 2022
++ mysql -h s.danman.eu -P 3306 -u root --password= -B -e 'CREATE USER IF NOT EXISTS '\''izpbx'\''@'\''%'\'' IDENTIFIED BY '\''.......'\'';'
ERROR 1045 (28000): Access denied for user 'root'@'10.88.0.133' (using password: NO)
++ mysql -h s.danman.eu -P 3306 -u root --password= -B -e 'CREATE DATABASE IF NOT EXISTS asterisk'
ugoviti commented 2 years ago

Hi, nice suggestion... yes I can manage that... Let's me working on.

Kind Regards

ugoviti commented 2 years ago

Hi,

relased https://github.com/ugoviti/izpbx/releases/tag/18.16.3

can you test if working as expected and report here problems?

Thank you.

Kind Regards

danielkucera commented 2 years ago

I haven't tried reinstall but deployed a new version and It works fine. Thank you.