A shell script to make purging remote media files from a Matrix Synapse server easier.
These (or compatible versions) are likely included by default with your chosen GNU/Linux system.
- Tested with GNU bash 5.0.11
- Requires GNU date for date/time conversion
- Requires Perl for domain validation
- Uses the
_synapse/admin/v1/purge_media_cache API endpoint
Go to the Releases page and click the link for
rmk.sh to download the script.
Downloading using git
Navigate to a reasonable directory and download the repo with
git clone https://gitbucket.thisisjoes.site/joe/remote_media_killer.git. This will create a directory named
To ensure you run the latest version of the script, first navigate to the directory with
cd remote_media_killer, then switch to the latest version with
git checkout 1.0.0, replacing "1.0.0" with a more recent version if necessary.
Executing the script
You may execute the script directly using bash with
You may also mark the script as executable with
chmod +x rmk.sh and execute using this shorthand
Making executable from anywhere
If you don't want to have to navigate to the directory containing the script before executing it, you can make it executable from anywhere by first marking it as executable (see above), then copying it to an appropriate directory
cp -p rmk.sh /usr/bin/local/rmk. Finally execute the script with
Remote Media Killer only takes three variables:
- The FQDN (Domain) of your Matrix Synapse server.
- The time/date (Time) of the oldest media you want to keep.
- The account token (Token) of a Matrix account with administrative privileges on your server.
Type each of these variables when prompted and press Enter to continue. The script will return relevant errors if there are any, as well as any output from the Synapse server.
For example, a successful media purge would result in output similar to the following:
If you encounter an error while using the script you may find a solution on the Common Errors page.