Skip to content

Instantly share code, notes, and snippets.

View lgrn's full-sized avatar

Linus lgrn

View GitHub Profile
#!/bin/bash
while getopts u: flag
do
case "${flag}" in
u) user=${OPTARG};;
*) echo "Bailing out."; exit 1
esac
done
@lgrn
lgrn / disable_inactive_mastodon_users.sh
Created February 24, 2024 13:58
disable any mastodon users not active for the past 7890000 seconds (91.3 days)
#!/bin/bash
DB_HOST=1.2.3.4
DB_PORT=5432
DB_NAME=mastodon_production
DB_USER=mastodon
PGPASSWORD=yourpassword psql -h ${DB_HOST} -p ${DB_PORT} -d ${DB_NAME} -U ${DB_USER} -w -1 -t -A -F" " -c "SELECT accounts.username, TRUNC(EXTRACT(EPOCH FROM (NOW() - current_sign_in_at))) AS diff FROM users JOIN accounts ON users.account_id = accounts.id WHERE (approved = TRUE AND disabled = FALSE)" | while read -r user time;
do
if [[ -v user && time -ge 7890000 ]]; then

Keybase proof

I hereby claim:

  • I am lgrn on github.
  • I am lgrn (https://keybase.io/lgrn) on keybase.
  • I have a public key ASBUtjdSyPanXbQk39VwuQWyMmPOHdoJZT2Lc1PqTTttyAo

To claim this, I am signing this object: