Skip to content

Instantly share code, notes, and snippets.

@rgpublic
Last active August 7, 2022 00:20
Show Gist options
  • Save rgpublic/afdb4fc42804b15c644cef3bd172717a to your computer and use it in GitHub Desktop.
Save rgpublic/afdb4fc42804b15c644cef3bd172717a to your computer and use it in GitHub Desktop.
#!/bin/bash
SERVER="matrix.mycompany.com"
echo -e "\e[97mEnter user you'd like to deactivate\e[0m";
read user
if [ "$user" == "" ]; then
echo "User required.";
exit;
fi
account="@$user:$SERVER";
su postgres -c "psql synapse -c 'DELETE FROM users WHERE name='\''$account'\'';'"
su postgres -c "psql synapse -c 'DELETE FROM user_directory WHERE user_id='\''$account'\'';'"
su postgres -c "psql synapse -c 'DELETE FROM account_data WHERE user_id='\''$account'\'';'"
su postgres -c "psql synapse -c 'DELETE FROM profiles WHERE user_id='\''$user'\'';'"
su postgres -c "psql synapse -c 'DELETE FROM user_external_ids WHERE user_id='\''$account'\'';'"
@disconn3ct
Copy link

It is user_id, which afaik is always @USER:SYNAPSE

@rgpublic
Copy link
Author

Thanks again, @disconn3ct . I've changed the script again accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment