synapse/media_purge.sh
author Peter Gervai <grin@grin.hu>
Fri, 04 Mar 2022 16:11:51 +0100
changeset 10 aaa61e5b4526
parent 1 ba8922061637
permissions -rwxr-xr-x
cmd.sh: set ordering on some longer outputs.
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