Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clean-akkoma() {
- DATABASES=(akkoma detroitriotcity)
- echo "Stopping Akkoma"
- systemctl stop akkoma
- for i in "${DATABASES[@]}"; do
- su postgres -s /bin/bash -lc "echo \"SET session_replication_role = replica;\" | psql $i"
- echo "Scanning Fderated Posts to Delete: $i"
- 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"
- echo "Deleting Objects for: $i"
- 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"
- echo "Deleting Activities for: $i"
- 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
- su postgres -s /bin/bash -lc "echo \"SET session_replication_role = DEFAULT;\" | psql $i"
- done
- echo "Starting Akkoma: $i"
- systemctl start akkoma
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement