mirror of
https://git.envs.net/envs/matrix-conf.git
synced 2025-05-13 04:22:11 -04:00
update scripts
This commit is contained in:
parent
babb552a1f
commit
00a6c905e4
2 changed files with 7 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
# this script removed all room's without local members.
|
||||||
# you dont need to stop synapse.
|
# you dont need to stop synapse.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -30,15 +30,14 @@ done
|
||||||
if [ -z "$DOMAIN" ] || [ "$DOMAIN" == '-t' ]; then print_usage; fi
|
if [ -z "$DOMAIN" ] || [ "$DOMAIN" == '-t' ]; then print_usage; fi
|
||||||
if [ -z "$TOKEN" ] || [ "$TOKEN" == '-d' ]; then print_usage; fi
|
if [ -z "$TOKEN" ] || [ "$TOKEN" == '-d' ]; then print_usage; fi
|
||||||
|
|
||||||
curl -s -X GET -H "Authorization: Bearer $TOKEN" "https://$DOMAIN/_synapse/admin/v1/rooms?limit=10000" | \
|
curl -s -X GET -H "Authorization: Bearer $TOKEN" "https://$DOMAIN/_synapse/admin/v1/rooms?limit=1000000" | \
|
||||||
jq -M '.rooms[] | select(.joined_local_members == 0) | .room_id' > $tmp_file
|
jq -Mr '.rooms[] | select(.joined_local_members == 0) | .room_id' > $tmp_file
|
||||||
sed -i 's/"//g' $tmp_file
|
|
||||||
|
|
||||||
while IFS= read -r room_id
|
while IFS= read -r room_id
|
||||||
do
|
do
|
||||||
printf 'remove room %s ' "$room_id"
|
printf 'remove room %s ' "$room_id"
|
||||||
curl -s -X POST -H "Authorization: Bearer $TOKEN" "https://$DOMAIN/_synapse/admin/v1/purge_room" \
|
curl -s -X DELETE -H "Authorization: Bearer $TOKEN" "https://$DOMAIN/_synapse/admin/v1/rooms/$room_id" \
|
||||||
-H "Content-Type: application/json" -d "{ \"room_id\": \"$room_id\" }"
|
-H "Content-Type: application/json" -d "{}"
|
||||||
printf ' done.\n'
|
printf ' done.\n'
|
||||||
done < $tmp_file
|
done < $tmp_file
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
## start task via:
|
## start task via:
|
||||||
# $ sudo systemd-run --nice=4 -pCPUSchedulingPolicy=batch \
|
# $ sudo systemd-run --nice=4 -pCPUSchedulingPolicy=batch \
|
||||||
# -pIOSchedulingClass=idle --uid=matrix-synapse --collect \
|
# -pIOSchedulingClass=idle --uid=matrix-synapse --collect \
|
||||||
# --unit=synapse-clear-state ~/bin/synapse-clear-state
|
# --unit=synapse-clear-state ~/bin/synapse_clear_state
|
||||||
#
|
#
|
||||||
## watch task-log via:
|
## watch task-log via:
|
||||||
# $ journalctl -Stoday -u synapse-clear-state -f
|
# $ journalctl -Stoday -u synapse-clear-state -f
|
||||||
|
@ -20,7 +20,6 @@ set -e -u
|
||||||
|
|
||||||
username='matrix'
|
username='matrix'
|
||||||
db='matrix'
|
db='matrix'
|
||||||
|
|
||||||
conn_str="host=localhost user=$username dbname=$db application_name=state_compress"
|
conn_str="host=localhost user=$username dbname=$db application_name=state_compress"
|
||||||
|
|
||||||
###
|
###
|
||||||
|
@ -56,7 +55,7 @@ do
|
||||||
sql_file=state-compress-$((no += 1)).sql
|
sql_file=state-compress-$((no += 1)).sql
|
||||||
echo "Writing SQL commands to $sql_file"
|
echo "Writing SQL commands to $sql_file"
|
||||||
|
|
||||||
$time synapse-compress-state -t -p "$conn_str" -o "$sql_file" -r "$room" -m 1000
|
$time synapse_compress_state -t -p "$conn_str" -o "$sql_file" -r "$room" -m 1000
|
||||||
if test -s "$sql_file"
|
if test -s "$sql_file"
|
||||||
then
|
then
|
||||||
$time psql -X -q -b -U "$username" -c '\set ON_ERROR_STOP on' -f "$sql_file" $db
|
$time psql -X -q -b -U "$username" -c '\set ON_ERROR_STOP on' -f "$sql_file" $db
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue