Advertisement
Guest User

Untitled

a guest
Apr 26th, 2024
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.49 KB | None | 0 0
  1. clean-akkoma() {
  2.         DATABASES=(akkoma detroitriotcity)
  3.         echo "Stopping Akkoma"
  4.         systemctl stop akkoma
  5.         for i in "${DATABASES[@]}"; do
  6.                 su postgres -s /bin/bash -lc "echo \"SET session_replication_role = replica;\" | psql $i"
  7.                 echo "Scanning Fderated Posts to Delete: $i"
  8.                 su postgres -s /bin/bash -lc "echo \"SELECT COUNT(*) FROM \"objects\" AS o0 WHERE (o0.\"data\"->'to' ? 'https://www.w3.org/ns/activitystreams#Public' OR o0.\"data\"->'cc' ? 'https://www.w3.org/ns/activitystreams#Public') AND (o0.\"inserted_at\" < now() - interval '15 days' ) AND (split_part(o0.\"data\"->>'actor', '/', 3) != '$i')\" | psql $i"
  9.                 echo "Deleting Objects for: $i"
  10.                 su postgres -s /bin/bash -lc "echo \"DELETE FROM \"objects\" AS o0 WHERE (o0.\"data\"->'to' ? 'https://www.w3.org/ns/activitystreams#Public' OR o0.\"data\"->'cc' ? 'https://www.w3.org/ns/activitystreams#Public') AND (o0.\"inserted_at\" < now() - interval '15 days' ) AND (split_part(o0.\"data\"->>'actor', '/', 3) != '$i')\" | psql $i"
  11.                 echo "Deleting Activities for: $i"
  12.                 su postgres -s /bin/bash -lc "echo \"DELETE FROM \"activities\" where data->>'type' = 'Create' and local = 'f' and inserted_at < now() - interval '10 days'"\" | psql $i
  13.                 su postgres -s /bin/bash -lc "echo \"SET session_replication_role = DEFAULT;\" | psql $i"
  14.         done
  15.         echo "Starting Akkoma: $i"
  16.         systemctl start akkoma
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement