Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tips:fail2ban [2019/04/15 08:56] – [telegram action] scipio | tips:fail2ban [2019/04/15 09:04] (current) – [telegram action] scipio | ||
---|---|---|---|
Line 22: | Line 22: | ||
fail2ban-regex / | fail2ban-regex / | ||
</ | </ | ||
+ | |||
+ | ===== action ===== | ||
+ | |||
+ | <file ini action.d/ | ||
+ | [Definition] | ||
+ | actionstart = / | ||
+ | actionstop = / | ||
+ | actioncheck = | ||
+ | actionban = / | ||
+ | actionunban = | ||
+ | |||
+ | [Init] | ||
+ | init = ' | ||
+ | </ | ||
===== jail ===== | ===== jail ===== | ||
Line 34: | Line 48: | ||
bantime = 6000 | bantime = 6000 | ||
maxretry = 3 | maxretry = 3 | ||
+ | action = %(action_)s | ||
+ | | ||
</ | </ | ||
Line 80: | Line 96: | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | <file bash / | ||
- | # | ||
- | | ||
- | # Sends text messages using Telegram | ||
- | # to alert webmaster of banning. | ||
- | | ||
- | # Require one argument, one of the following | ||
- | # start | ||
- | # stop | ||
- | # ban | ||
- | # unban | ||
- | # Optional second argument: Ip for ban/ | ||
- | | ||
- | | ||
- | # Display usage information | ||
- | function show_usage { | ||
- | echo " | ||
- | echo "Where action start, stop, ban, unban" | ||
- | echo "and IP is optional passed to ban, unban" | ||
- | exit | ||
- | } | ||
- | |||
- | |||
- | # Send notification | ||
- | function send_msg { | ||
- | apiToken= | ||
- | chatId= | ||
- | url=" | ||
- | |||
- | curl -s -X POST $url -d chat_id=$chatId -d text=" | ||
- | exit | ||
- | } | ||
- | |||
- | # Check for script arguments | ||
- | if [ $# -lt 1 ] | ||
- | then | ||
- | show_usage | ||
- | fi | ||
- | |||
- | |||
- | # Take action depending on argument | ||
- | if [ " | ||
- | then | ||
- | msg=' | ||
- | send_msg $msg | ||
- | elif [ " | ||
- | then | ||
- | msg=' | ||
- | send_msg $msg | ||
- | elif [ " | ||
- | then | ||
- | msg=$([ " | ||
- | send_msg $msg | ||
- | elif [ " | ||
- | then | ||
- | msg=$([ " | ||
- | send_msg $msg | ||
- | else | ||
- | show_usage | ||
- | fi | ||
- | |||
- | </ | ||