34 lines
1.4 KiB
Bash
34 lines
1.4 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
if [ -z $1 ]; then
|
||
|
echo "Missing IP argument";
|
||
|
echo "Usage : ./$0 IP"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
|
||
|
IP=$1
|
||
|
|
||
|
echo "Selecting accounts from IP $IP..."
|
||
|
psql -A -t -P pager=off mastodon-production -c "select account_id from users where host(last_sign_in_ip) like '$IP%';" > account_id_from_ip.txt
|
||
|
|
||
|
echo "Filtering accounts that are suspended..."
|
||
|
for id in `cat account_id_from_ip.txt`; do psql -A -t -P pager=off mastodon-production -c "select id from accounts where id='$id' and suspended_at is NULL;"; done > filtered_account_id_from_ip.txt
|
||
|
|
||
|
echo "Generating URL list..."
|
||
|
for id in `cat filtered_account_id_from_ip.txt`; do echo "https://pouet.chapril.org/admin/accounts/$id"; done > account_url_from_ip.txt
|
||
|
|
||
|
echo "Generating username list..."
|
||
|
for id in `cat filtered_account_id_from_ip.txt`; do psql -A -t -P pager=off mastodon-production -c "select username from accounts where id='$id';"; done > account_username_from_ip.txt
|
||
|
|
||
|
echo "Generating username string...";
|
||
|
for username in `cat account_username_from_ip.txt`; do echo -n "$username, "; done > account_username_from_ip_list.txt
|
||
|
|
||
|
|
||
|
echo -e "All done\n\n#################\n"
|
||
|
echo "accounts id in account_id_from_ip.txt"
|
||
|
echo "filtered accounts id in filtered_account_id_from_ip.txt"
|
||
|
echo "accounts url in account_url_from_ip.txt"
|
||
|
echo "username list in account_username_from_ip.txt"
|
||
|
echo "username string in account_username_from_ip_list.txt"
|