diff --git a/README.md b/README.md new file mode 100644 index 0000000..b90b0fc --- /dev/null +++ b/README.md @@ -0,0 +1,145 @@ +# mastodon-styles + +Some styles for a mastodon server. + +Should work on the root path of your mastodon instance. (/home/mastodon/live). + +## My instance + +I had a single-user instance running for about 4 months and I shut it down on +March 25 2023 because of different reasons. + +I've been testing and playing around with that mastodon software but I only used +version 4.0.2 (I think) up to 4.1.1. Upgrades went very well, just read the release +docs. + +I moved servers two times, first time only geographically but second time I went +to use a server with a smaller configuration setup (ram, harddisk size). This is +not something you do in your webinterface, you gonna move the files and database +by hand (an upgrade of harddisk size and RAM would be much easier on VPS systems). + +Finally, I'd like to show you some stats and maybe some useful information. + +### Some statistics + +for a single user instance with 4 relais (1 of them was only ham radio related, so +the traffic on that one was very low). The other three relais made sidekiq to work +~8x more than before the relais. + +```console +$ bin/tootctl media usage +Attachments: 16.1 GB (1.94 MB local) +Custom emoji: 87.2 MB (450 KB local) +Preview cards: 1.02 GB +Avatars: 2.3 GB (48.5 KB local) +Headers: 5.33 GB (429 KB local) +Backups: 0 Bytes +Imports: 0 Bytes +Settings: 0 Bytes +``` + +![admin dashboard showing usage](admin.png) + +### (Hopefully) helpful snippets + +#### clear media files + + + +```bash +#!/bin/bash +export PATH="$HOME/.rbenv/bin:$PATH" +eval "$(rbenv init -)" +export RAILS_ENV=production + +exec > /home/mastodon/live/log/prune.log 2>&1 + +/home/mastodon/live/bin/tootctl statuses remove +/home/mastodon/live/bin/tootctl media remove --days=5 +/home/mastodon/live/bin/tootctl media remove --prune-profiles --days=60 +/home/mastodon/live/bin/tootctl preview_cards remove --days=15 +/home/mastodon/live/bin/tootctl media remove-orphans +/home/mastodon/live/bin/tootctl cache clear +/home/mastodon/live/bin/tootctl media usage +date +``` + +#### profile pics + + + +```bash +#!/usr/bin/env bash +# Kept only the accounts compression and jpeg optimization + +cd /home/mastodon/live/public/system/cache +find -name '*.jpg' -print0 | xargs -0 jpegoptim --verbose --preserve --threshold=1 --max=45 +find -name '*.jpeg' -print0 | xargs -0 jpegoptim --verbose --preserve --threshold=1 --max=45 + +cd /home/mastodon/live/public/system/cache/accounts +find -name '*.png' -print0 | xargs -0 pngquant --verbose --ext=.png --force --speed 10 --quality 45-50 --skip-if-larger +``` + +#### managing media in rails console + + + +There are several scripts executable with `RAILS_ENV=production bundle exec rails c`, +for convenience laid out here with minor corrections. **Do not execute these +without understanding what they do!**: + +Deleting all cached media attachments from external servers to allow web app +to refetch them when they are queried. At least on my instance this is reaaally +slow, takes tens of seconds per attachment (is this the same as tootctl media +remove?): + +```ruby +MediaAttachment.cached.where.not(remote_url: '').each do |attachment| + attachment.file.destroy + attachment.thumbnail.destroy + attachment.save +end +``` + +Deleting and redownloading all cached remote emojis. This apparently has a +problem that the local URLs for the cached emojis change, and the URLs aren't +updated to the fetched profile headers. I suppose this should be done before +the next steps, assuming the cached local emoji URLs are set up correctly to +the profile headers and names at the time of fetching. This doesn't seem to +work though, maybe tootctl emoji purge --remote-only would be better: + +```ruby +CustomEmoji.remote.where.not(image_file_name: nil).where.not(image_remote_url: '').each do |emoji| + emoji.image.destroy + emoji.image.save + emoji.download_image! +end +``` + +Deleting all remote profile avatars, and refetching them. Are these two the +same as tootctl accounts refresh --all?: + +```ruby +Account.remote.where.not(avatar_file_name: nil).where.not(avatar_remote_url: '').each do |a| + a.avatar.destroy + a.save + a.download_avatar! +end +``` + +Deleting all remote profile headers, and refetching them. Hopefully this +uses/updates the newly fetched local cached emoji URLs, and also includes the +profile name as they often contain emojis: + +```ruby +Account.remote.where.not(header_file_name: nil).where.not(header_remote_url: '').each do |a| + a.header.destroy + a.save + a.download_header! +end +``` + +It would be awesome to get tooling for these to tootctl. That said, I'm not +entirely sure if destroying the entities is necessary before downloading them +again, and perhaps we could use remove_entity_cache instead. I'm not very well +acquainted with the codebase. diff --git a/admin.png b/admin.png new file mode 100644 index 0000000..02834a2 Binary files /dev/null and b/admin.png differ