synapse/media_purge.sh
author Peter Gervai <grin@grin.hu>
Fri, 21 Jan 2022 10:10:19 +0100
changeset 2 c3f49b58aff6
parent 1 ba8922061637
permissions -rwxr-xr-x
Add synapse/cmd.sh: query db for various user statistics - last registrations - user events - user event contents - active daily users
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     1
#!/bin/sh
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     2
# purge (foreign) media cache
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     3
# (cc) Peter 'grin' Gervai, 2020
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     4
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     5
# import $T access token (macaroon)
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     6
. /root/matrix-synapse/clean_auto/_config.sh
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     7
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     8
U="https://matrix.grin.hu:8448/"
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
     9
TM=`date +%s`
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    10
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    11
# T - 1week
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    12
###TM=$(( TM - 60*60*24*7 ))
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    13
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    14
# T - 1 hour
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    15
TM=$(( TM - 60*60 ))
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    16
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    17
printf "Purging up to %s\n", "`date --date="@${TM}"`"
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    18
TM="${TM}000"
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    19
STAMP=$TM
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    20
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    21
MODE="POST"
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    22
#CMD="_matrix/client/r0/admin/purge_media_cache?before_ts=$STAMP"
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    23
CMD="_synapse/admin/v1/purge_media_cache?before_ts=$STAMP"
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    24
4216bf35912e Init repo; my matrix stuff
Peter Gervai <grin@grin.hu>
parents:
diff changeset
    25
time curl -s -d '{}' -X${MODE} "${U}${CMD}&access_token=$T" | jq