A shell script to make purging remote media files from a Matrix Synapse server easier.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.4 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. Remote Media Killer
  2. ===============
  3. A shell script to make purging remote media files from a Matrix *Synapse* server
  4. easier.
  5. ## Dependencies
  6. These (or compatible versions) are likely included by default with your chosen
  7. GNU/Linux system.
  8. - Tested with *GNU bash* 5.0.11
  9. - Requires *GNU date* for date/time conversion
  10. - Requires *Perl* for domain validation
  11. - Uses the `_synapse/admin/v1/purge_media_cache` API endpoint
  12. ## Installation
  13. ### Downloading directly
  14. Go to the [Releases](https://gitbucket.thisisjoes.site/joe/remote_media_killer/releases)
  15. page and click the link for `rmk.sh` to download the script.
  16. ### Downloading using *git*
  17. Navigate to a reasonable directory and download the repo with `git clone
  18. https://gitbucket.thisisjoes.site/git/joe/remote_media_killer.git`. This will
  19. create a directory named `remote_media_killer` automatically.
  20. To ensure you run the latest version of the script, first navigate to the
  21. directory with `cd remote_media_killer`, then switch to the latest version with
  22. `git checkout 1.0.0`, replacing "1.0.0" with a more recent version if necessary.
  23. ## Usage
  24. ### Executing the script
  25. You may execute the script directly using *bash* with `bash rmk.sh`.
  26. You may also **mark the script as executable** with `chmod +x rmk.sh` and
  27. execute using this shorthand `./rmk.sh`.
  28. #### Making executable from anywhere
  29. If you don't want to have to navigate to the directory containing the script
  30. before executing it, you can make it executable from anywhere by first marking
  31. it as executable (see above), then copying it to an appropriate directory
  32. `cp -p rmk.sh /usr/bin/local/rmk`. Finally execute the script with `rmk`.
  33. ### Inputting Information
  34. *Remote Media Killer* only takes three variables:
  35. 1. The FQDN (Domain) of your Matrix Synapse server.
  36. 2. The time/date (Time) of the oldest media you want to keep.
  37. 3. The account token (Token) of a Matrix account with administrative privileges
  38. on your server.
  39. Type each of these variables when prompted and press ***Enter*** to continue.
  40. The script will return relevant errors if there are any, as well as any output
  41. from the *Synapse* server.
  42. For example, a successful media purge would result in output similar to the
  43. following:
  44. ```json
  45. {
  46. "deleted": 1337
  47. }
  48. ```
  49. ### Common Errors
  50. If you encounter an error while using the script you may find a solution on the [Common Errors](https://gitbucket.thisisjoes.site/joe/remote_media_killer/wiki/Common Errors) page.