media_purge.sh
changeset 0 4216bf35912e
equal deleted inserted replaced
-1:000000000000 0:4216bf35912e
       
     1 #!/bin/sh
       
     2 # purge (foreign) media cache
       
     3 # (cc) Peter 'grin' Gervai, 2020
       
     4 
       
     5 # import $T access token (macaroon)
       
     6 . /root/matrix-synapse/clean_auto/_config.sh
       
     7 
       
     8 U="https://matrix.grin.hu:8448/"
       
     9 TM=`date +%s`
       
    10 
       
    11 # T - 1week
       
    12 ###TM=$(( TM - 60*60*24*7 ))
       
    13 
       
    14 # T - 1 hour
       
    15 TM=$(( TM - 60*60 ))
       
    16 
       
    17 printf "Purging up to %s\n", "`date --date="@${TM}"`"
       
    18 TM="${TM}000"
       
    19 STAMP=$TM
       
    20 
       
    21 MODE="POST"
       
    22 #CMD="_matrix/client/r0/admin/purge_media_cache?before_ts=$STAMP"
       
    23 CMD="_synapse/admin/v1/purge_media_cache?before_ts=$STAMP"
       
    24 
       
    25 time curl -s -d '{}' -X${MODE} "${U}${CMD}&access_token=$T" | jq