I had been scouring the web this morning looking for a way to get the hostname of the server in my e-mails without hard-coding it into my action.d scripts (e.g. mail.conf, mail-whois.conf, etc.). The fail2ban wiki was not much help in this regard. In fact, somebody had posted this exact request on the community page, but it seems as though this request has not gone through. But, alas, I found a solution that’s not ideal, but isn’t the horrible must hard-code my hostname into every action.d script.
Now, again, I mentioned this wasn’t ideal. I still had to touch all of my mail-related action.d scripts. Notice the
The default did not include the
on <host>. So, this gave me the flexibility of defining the hostname this message was coming from. But, how do you do that?
Sadly, it wasn’t as simple as setting a global config variable of
host = _HOSTNAME_. Instead, for every jail rule I had, I have to pass my host parameter to the action.d script. Again, this is not ideal as I’m still having to define my hostname in multiple places, but at least it’s limited to one file:
lf I find a better solution, I’ll post it online. That or I may just submit a patch to the lead developers for a better solution than this.