Set up fail2ban for nginx, move IPFS gateway to proxy role
This commit is contained in:
26
cookbooks/fail2ban/templates/slack_notify.sh.erb
Normal file
26
cookbooks/fail2ban/templates/slack_notify.sh.erb
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# message first command argument
|
||||
MESSAGE=$1
|
||||
HOOK_URL=<%= @slack_webhook %>
|
||||
HOST=$(hostname)
|
||||
|
||||
CHANNEL="#<%= @slack_channel %>"
|
||||
USERNAME="fail2ban"
|
||||
ICON=":cop:"
|
||||
|
||||
# ip second command argument
|
||||
IP=$2
|
||||
# lets find out from what country we have our hacker
|
||||
COUNTRY=$(curl ipinfo.io/${IP}/country)
|
||||
# converting country to lover case. I love you bash script =\
|
||||
COUNTRY=$(echo "$COUNTRY" | tr -s '[:upper:]' '[:lower:]')
|
||||
# slack emoji
|
||||
COUNTRY=":flag-$COUNTRY:"
|
||||
|
||||
# replace _country_ template to the country emoji
|
||||
MESSAGE="${MESSAGE/_country_/$COUNTRY}"
|
||||
|
||||
curl -X POST --data-urlencode "payload={\"channel\": \"${CHANNEL}\", \"username\": \"${USERNAME}\", \"text\": \"[${HOST}] ${MESSAGE}\", \"icon_emoji\": \"${ICON}\"}" ${HOOK_URL}
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user