byezlax/byezlax

137 lines
3.1 KiB
Plaintext
Raw Normal View History

2021-01-13 19:54:19 +00:00
#!/bin/bash
########################
# Script configuration #
########################
2021-01-13 19:54:19 +00:00
if [ ! -f "$PWD/config" ]; then
declare DB_NAME="hubzilla"
declare DB_HOST="localhost"
declare DB_PORT="3306"
declare DB_USER="user"
declare DB_PASS="pass"
declare SPAMLIST_URL="https://git.c-r-t.tk/DiasporaDefenseLeague/spamlist/raw/branch/master/spammers"
else
source $PWD/config > /dev/null
fi
#################################
# Download new list of spammers #
#################################
2021-01-28 15:01:30 +00:00
wget $SPAMLIST_URL -q -N
#########################
# Read List of spammers #
#########################
mapfile -t SPAMMERS < $PWD/spammers
2021-01-13 19:54:19 +00:00
####################################
# Extermination of Zlaxes' actions #
####################################
QUERIES=$(mktemp)
2021-01-13 19:54:19 +00:00
for SPAM in "${SPAMMERS[@]}"
do
echo "Preparing to remove items from handle $SPAM ..."
echo "UPDATE item SET item_pending_remove = '1' WHERE author_xchan LIKE '$SPAM';" >> $QUERIES
2021-01-13 19:54:19 +00:00
done
mysql --user=$DB_USER \
--password=$DB_PASS \
--database=$DB_NAME \
--host=$DB_HOST \
--port=$DB_PORT \
--silent \
--compress \
-e "$(cat $QUERIES)"
rm $QUERIES
2021-01-13 19:54:19 +00:00
#################################################
# Finally remove all marked items from database #
#################################################
QUERIES=$(mktemp)
2021-01-13 19:54:19 +00:00
echo "All items have been marked for deletion and won't be visible anymore. If you wish to delete them permamently, type YES."
read REMOVAL
if [ "$REMOVAL" = "YES" ]; then
echo "DELETE from item WHERE item_pending_remove = '1';" >> $QUERIES
2021-01-13 19:54:19 +00:00
fi
mysql --user=$DB_USER \
--password=$DB_PASS \
--database=$DB_NAME \
--host=$DB_HOST \
--port=$DB_PORT \
--silent \
-e "$(cat $QUERIES)"
rm $QUERIES
2021-01-13 19:54:19 +00:00
########################
# Remove notifications #
########################
QUERIES=$(mktemp)
2021-01-13 19:54:19 +00:00
for SPAM in "${SPAMMERS[@]}"
do
POD=$(echo -e "$SPAM" | cut -f2 -d"@")
USR=$(echo -e "$SPAM" | cut -f1 -d"@")
URL="htt%://$POD/u/$USR"
echo "Preparing to remove notifications from handle $SPAM ..."
echo "DELETE FROM notify WHERE url LIKE '$URL';" >> $QUERIES
done
mysql --user=$DB_USER \
--password=$DB_PASS \
--database=$DB_NAME \
--host=$DB_HOST \
--port=$DB_PORT \
--silent \
-e "$(cat $QUERIES)"
rm $QUERIES
#####################################
# Set hubloc entry to "deactivated" #
#####################################
QUERIES=$(mktemp)
2021-01-13 19:54:19 +00:00
for SPAM in "${SPAMMERS[@]}"
do
echo "Deactivating account $SPAM on this hub ..."
echo "UPDATE hubloc SET hubloc_deleted = '1' WHERE hubloc_addr LIKE '$SPAM';" >> $QUERIES
2021-01-13 19:54:19 +00:00
done
mysql --user=$DB_USER \
--password=$DB_PASS \
--database=$DB_NAME \
--host=$DB_HOST \
--port=$DB_PORT \
--silent \
-e "$(cat $QUERIES)"
rm $QUERIES
2021-01-13 19:54:19 +00:00
##############################################
# TBD #
##############################################
# Blocking further communication from Zlaxes #
##############################################
#
#HZ_BANLIST=$(mysql --user=$DB_USER \
# --password=$DB_PASS \
# --database=$DB_NAME \
# --host=$DB_HOST \
# --port=$DB_PORT \
# --silent \
# -e "SELECT v FROM config WHERE cat='system' AND k='blacklisted_channels';")