diff --git a/twitupd.sh b/twitupd.sh old mode 100644 new mode 100755 index c995780..896ab23 --- a/twitupd.sh +++ b/twitupd.sh @@ -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