E-F-A / eFa5

eFa version 5.x
Other
10 stars 3 forks source link

add support for external database server #23

Open bilias opened 1 month ago

bilias commented 1 month ago

I've been running eFa for years on external database. Actually on galera cluster but let's just stick to external for now as this is the first step. This helps me having a redundant active-active setup of 2 eFa servers using the same DB for mailwatch.

Although most of scripts use /etc/eFa/* files to read the SQL password, localhost is hardcoded everywhere.

It's quite easy to update many of the scripts to accept host (as well as db and user) from /etc/eFa/ config files. This comes helpfull when updating software to not override back to localhost.

Examples: /var/www/html/sgwi/includes/config.inc.php /usr/share/MailScanner/perl/custom/MailWatchConf.pm /etc/cron.daily/trim-txrep /etc/cron.daily/mailwatch /usr/sbin/eFa-Daily-DMARC

There might be others for eFa5 (I've done this for efa3 and efa4)

Are you interested in providing pull requests for getting MySQL connections from config files the same way passwords are fetched?

There are also other files which are not scriptable like /etc/sqlgrey/sqlgrey.conf /var/www/html/mailscanner/conf.php /etc/mail/spamassassin/mailscanner.cf

These could be updated with a sed script, or maybe the /etc/eFa/* config file should also point to each file that needs change.

I use mysql-server in /etc/hosts to point to the server and hardcoded mysql-server everywhere and maybe this could also be extended per db as an alternative or extension to my proposal.

What do you think about this?

Seeing back I found this one: https://github.com/E-F-A/v4/pull/355

shawniverson commented 1 month ago

I think this is a good thing to implement. The earlier pull request has some issues and merge conflicts so it never was merged. If this is done I would like to extend eFa to prompt for local/remote database information during initial setup.

bilias commented 1 month ago

ok, I will start pushing updates.

How do you want to handle the update for the config file?

For instance for /etc/eFa/MailWatch-Config I'm planning to add something like MAILWATCHSQLHOST:localhost for the default setup.

How do you suggest this line be added there? Maybe %post of MailWatch.spec ?

shawniverson commented 1 month ago

That would work or in the eFa package update script itself, like this:

if [[-z $(grep MAILWATCHSQLHOST /etc/eFa/MailWatch-Config ) ]]; then 
   echo "MAILWATCHSQLHOST:localhost" >> /etc/eFa/MailWatch-Config
fi