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 #!/bin/bash
MYS_DATA="/mystic/data" # Recommended crontab entry
MYS_LOGS="/mystic/logs" # 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' IFS=$'\n'
for I in $(curl https://www.erb.pw/blacklist 2>/dev/null); do for URL in ${URLS[@]}; do
CHECK=$(grep -c $I $MYS_DATA/blacklist.txt) for I in $(curl -s $URL); do
if [[ $CHECK -lt 1 ]]; then CHECK=$(grep -c $I $FILE)
echo $I >> $MYS_DATA/blacklist.txt if [[ $CHECK -lt 1 ]]; then
echo "[+] $I" echo $I >> $FILE
echo "$(date) [+] $I" >> $MYS_LOGS/twitupd.log echo "[+] $I"
else echo "$(date) [+] $I" >> $MYS_LOGS/twitupd.log
echo "[✔] $I" else
echo "$(date) [✔] $I" >> $MYS_LOGS/twitupd.log echo "[✔] $I"
fi echo "$(date) [✔] $I" >> $MYS_LOGS/twitupd.log
fi
done
done done