update twitupd.sh

This commit is contained in:
MeaTLoTioN 2022-12-09 09:11:16 +00:00
parent 6017422529
commit 768811fc40

40
twitupd.sh Normal file → Executable file
View File

@ -1,17 +1,33 @@
#!/bin/bash
MYS_DATA="/mystic/data"
MYS_LOGS="/mystic/logs"
# Recommended crontab entry
# 0 0 * * * /mystic/scripts/twitupd.sh /path/to/mystic && logger -t "mystic_badips" "[crontab] blacklist.txt/denylist.txt updated"
[[ -z "$1" ]] && MYS_HOME="/mystic" || MYS_HOME="$1"
MYS_DATA="$MYS_HOME/data"
MYS_LOGS="$MYS_HOME/logs"
# URLs containing raw IP's to use for Mystic's blacklist/denylist
URLS=(
"https://erb.pw/blacklist"
"https://ibbs.archaicbinary.net/ibbs-bots"
)
# Check if using Mystic's blacklist.txt or denylist.txt
[[ -f $MYS_DATA/denylist.txt ]] && FILE="$MYS_DATA/denylist.txt" || FILE="$MYS_DATA/blacklist.txt"
IFS=$'\n'
for I in $(curl https://www.erb.pw/blacklist 2>/dev/null); do
CHECK=$(grep -c $I $MYS_DATA/blacklist.txt)
if [[ $CHECK -lt 1 ]]; then
echo $I >> $MYS_DATA/blacklist.txt
echo "[+] $I"
echo "$(date) [+] $I" >> $MYS_LOGS/twitupd.log
else
echo "[✔] $I"
echo "$(date) [✔] $I" >> $MYS_LOGS/twitupd.log
fi
for URL in ${URLS[@]}; do
for I in $(curl -s $URL); do
CHECK=$(grep -c $I $FILE)
if [[ $CHECK -lt 1 ]]; then
echo $I >> $FILE
echo "[+] $I"
echo "$(date) [+] $I" >> $MYS_LOGS/twitupd.log
else
echo "[✔] $I"
echo "$(date) [✔] $I" >> $MYS_LOGS/twitupd.log
fi
done
done