Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| tips:fail2ban [2019/04/15 09:03] – [jail] scipio | tips:fail2ban [2019/04/15 09:04] (current) – [telegram action] scipio | ||
|---|---|---|---|
| Line 96: | 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 | ||
| - | |||
| - | </ | ||