Background: Although I think Fail2Ban is great way of securing subsystems like Apache, it takes a lot of work to get all the info together. So I'm writing a BASH script to do that for me.
I need to put the 'get' options of fail2ban-client in an array ..
So far I isolated these using: f2b_opts_cmd="$(sudo fail2ban-client --help | grep -i 'get <jail>' | grep -vw 'act')"
On the commandline, it looks like:
get <JAIL> logpath gets the list of the monitored
get <JAIL> logencoding gets the encoding of the log files
get <JAIL> journalmatch gets the journal filter match for
get <JAIL> ignoreself gets the current value of the
get <JAIL> ignoreip gets the list of ignored IP
get <JAIL> ignorecommand gets ignorecommand of <JAIL>
get <JAIL> failregex gets the list of regular
get <JAIL> ignoreregex gets the list of regular
get <JAIL> findtime gets the time for which the filter
get <JAIL> bantime gets the time a host is banned for
get <JAIL> datepattern gets the patern used to match
get <JAIL> usedns gets the usedns setting for <JAIL>
get <JAIL> maxretry gets the number of failures
get <JAIL> maxlines gets the number of lines to buffer
get <JAIL> actions gets a list of actions for <JAIL>
However, the variable looks like:
get
<JAIL>
logpath gets the list of the monitored get<JAIL>
logencoding gets the encoding of the log files get<JAIL>
journalmatch gets the journal filter match for get<JAIL>
ignoreself gets the current value of the get<JAIL>
ignoreip gets the list of ignored IP get<JAIL>
ignorecommand gets ignorecommand of<JAIL>
get<JAIL>
failregex gets the list of regular get<JAIL>
ignoreregex gets the list of regular get<JAIL>
findtime gets the time for which the filter get<JAIL>
bantime gets the time a host is banned for get datepattern gets the patern .. etc.etc.
But I need to have something like:
f2b_opts=(logpath logencoding journalmatch ignoreself ignoreip ignorecommand failregex ignoreregex findtime bantime datepattern usedns maxretry maxlines actions)
How do I get the word after the <JAIL>
part?
After days of searching this forum and other sites, still haven't found a solution to this problem. Complicating factors here are the "less" and "greater than" signs and the fact that there are multiple "JAIL" words in the raw string (see example).