mirror of
https://github.com/jakejarvis/mastodon-utils.git
synced 2025-04-26 07:55:22 -04:00
renamed repo
This commit is contained in:
parent
046c63d220
commit
2b1b586d88
63
README.md
63
README.md
@ -1,58 +1,69 @@
|
|||||||
# 🦣 Mastodon randomness
|
# 🦣 Mastodon utilities
|
||||||
|
|
||||||
Random opinionated helper scripts & front-end customizations for my [personal Mastodon instance](https://fediverse.jarv.is/about) (running on [`glitch-soc`](https://github.com/glitch-soc/mastodon)). You definitely don't want to use any of this as-is — check out my more general purpose [mastodon-installer](https://github.com/jakejarvis/mastodon-installer) scripts instead.
|
Random opinionated helper scripts & front-end customizations for my [personal Mastodon instance](https://fediverse.jarv.is/about) (running on [`glitch-soc`](https://github.com/glitch-soc/mastodon)). You definitely don't want to use any of this as-is — check out my more general purpose [mastodon-installer](https://github.com/jakejarvis/mastodon-installer) scripts instead.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
The [wiki of this repo](https://github.com/jakejarvis/mastodon-scripts/wiki) and the [`/etc` folder](etc/) are simply my way of not forgetting how I did something, which I do quite a bit. Refer there for random notes on PgBouncer, Grafana, etc. but **DO NOT BLINDLY COPY & PASTE** anything there without doing your own research!
|
The [wiki of this repo](https://github.com/jakejarvis/mastodon-utils/wiki) and the [`/etc` folder](etc/) are simply my way of not forgetting how I did something, which I do quite a bit. Refer there for random notes on PgBouncer, Grafana, etc. but **DO NOT BLINDLY COPY & PASTE** anything there without doing your own research!
|
||||||
|
|
||||||
- [Grafana & Prometheus](https://github.com/jakejarvis/mastodon-scripts/wiki/Prometheus-&-Grafana)
|
- [Grafana & Prometheus](https://github.com/jakejarvis/mastodon-utils/wiki/Prometheus-&-Grafana)
|
||||||
- [ElasticSearch](https://github.com/jakejarvis/mastodon-scripts/wiki/ElasticSearch)
|
- [ElasticSearch](https://github.com/jakejarvis/mastodon-utils/wiki/ElasticSearch)
|
||||||
- [PgBouncer](https://github.com/jakejarvis/mastodon-scripts/wiki/Postgres-&-PgBouncer)
|
- [PgBouncer](https://github.com/jakejarvis/mastodon-utils/wiki/Postgres-&-PgBouncer)
|
||||||
- [Brotli compression](https://github.com/jakejarvis/mastodon-scripts/wiki/Brotli-compression-for-nginx)
|
- [Brotli compression](https://github.com/jakejarvis/mastodon-utils/wiki/Brotli-compression-for-nginx)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
***AGAIN, DEFINITELY DO NOT JUST RUN THIS IF YOU'RE NOT ME!!! 😊***
|
***AGAIN, DEFINITELY DO NOT JUST RUN THIS IF YOU'RE NOT ME!!! 😊***
|
||||||
|
|
||||||
|
This sets up the bare minimum customizations **after** Mastodon is installed:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/jakejarvis/mastodon-scripts.git /home/mastodon/scripts
|
git clone https://github.com/jakejarvis/mastodon-utils.git /home/mastodon/utils && cd /home/mastodon/utils
|
||||||
|
|
||||||
# apply vanilla patches:
|
# setup nginx using conf files from this repo:
|
||||||
cd /home/mastodon/live
|
./scripts/setup_nginx.sh
|
||||||
git apply --allow-binary-replacement /home/mastodon/scripts/patches/*.patch
|
|
||||||
|
|
||||||
# apply glitch-only patches:
|
# apply vanilla (and glitch-soc) patches from this repo:
|
||||||
if [ -d /home/mastodon/live/app/javascript/flavours/glitch ]; then
|
./scripts/apply_patches.sh
|
||||||
git apply --allow-binary-replacement /home/mastodon/scripts/patches/glitch/*.patch
|
|
||||||
fi
|
|
||||||
|
|
||||||
# compile new assets:
|
# cherry-pick everything else below...
|
||||||
RAILS_ENV=production bundle exec rails assets:precompile
|
|
||||||
chown -R mastodon:mastodon /home/mastodon/{scripts,live}
|
|
||||||
|
|
||||||
# restart Mastodon:
|
|
||||||
systemctl restart mastodon-*
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Patches
|
## Patches
|
||||||
|
|
||||||
|
#### Vanilla and `glitch-soc`:
|
||||||
|
|
||||||
- [`favicons.patch`](patches/favicons.patch): Use custom icon images instead of Mastodon logo
|
- [`favicons.patch`](patches/favicons.patch): Use custom icon images instead of Mastodon logo
|
||||||
- [`robots.patch`](patches/robots.patch): Disallow search engines for all of Mastodon
|
- [`robots.patch`](patches/robots.patch): Disallow search engines for all of Mastodon
|
||||||
- [`increase-sidekiq-http-timeout.patch`](patches/increase-sidekiq-http-timeout.patch): Minor increase in time before Sidekiq decides a remove instance isn't available. **Use this one carefully!**
|
- [`increase-sidekiq-timeout.patch`](patches/increase-sidekiq-timeout.patch): Small bump in Sidekiq's timeout before it decides a remote instance isn't available. **Use this one very carefully!**
|
||||||
- [`system-font.patch`](patches/system-font.patch): Use the system's default sans-serif font stack instead of Roboto
|
- [`system-font.patch`](patches/system-font.patch): Use the system's default sans-serif font stack instead of Roboto
|
||||||
- [Additional `glitch-soc` patch](patches/glitch/system-font.patch)
|
- [`glitch/system-font.patch`](patches/glitch/system-font.patch)
|
||||||
- [`hide-contact-email.patch`](patches/hide-contact-email.patch): Hides the `mailto:` link on the About page
|
- [`hide-contact-email.patch`](patches/hide-contact-email.patch): Hides the `mailto:` link on the About page
|
||||||
- [Additional `glitch-soc` patch](patches/glitch/hide-contact-email.patch)
|
- [`glitch/hide-contact-email.patch`](patches/glitch/hide-contact-email.patch)
|
||||||
- [`hide-rules.patch`](patches/hide-rules.patch): Applies just to homepage, meant only for single-user instances
|
- [`hide-rules.patch`](patches/hide-rules.patch): Applies just to homepage, meant only for single-user instances
|
||||||
- [Additional `glitch-soc` patch](patches/glitch/hide-rules.patch)
|
- [`glitch/hide-rules.patch`](patches/glitch/hide-rules.patch)
|
||||||
- [`hide-signup.patch`](patches/hide-signup.patch): Hide the "create account" button (for aesthetics, **not security!**)
|
- [`hide-signup.patch`](patches/hide-signup.patch): Hide the "create account" button (for aesthetics, **not security!**)
|
||||||
- [Additional `glitch-soc` patch](patches/glitch/hide-signup.patch)
|
- [`glitch/hide-signup.patch`](patches/glitch/hide-signup.patch)
|
||||||
- `glitch-soc` only:
|
|
||||||
|
#### `glitch-soc` only:
|
||||||
- [`custom-glitch-defaults.patch`](patches/glitch/custom-glitch-defaults.patch): Sets default Glitch appearance settings for logged-out users
|
- [`custom-glitch-defaults.patch`](patches/glitch/custom-glitch-defaults.patch): Sets default Glitch appearance settings for logged-out users
|
||||||
- [`remove-glitch-cruft.patch`](patches/glitch/remove-glitch-cruft.patch): Removes a bunch of junk no longer used by `glitch-soc`
|
- [`remove-glitch-cruft.patch`](patches/glitch/remove-glitch-cruft.patch): Removes a bunch of junk no longer used by `glitch-soc`
|
||||||
- [`sidebar-logo.patch`](patches/glitch/sidebar-logo.patch): Restore Mastodon logo in logged-out sidebar
|
- [`sidebar-logo.patch`](patches/glitch/sidebar-logo.patch): Restore Mastodon logo in logged-out sidebar
|
||||||
|
|
||||||
|
## Scripts
|
||||||
|
|
||||||
|
- [`apply_patches.sh`](scripts/apply_patches.sh): Dangerously applies ***every patch*** listed above, and automatically detects if `glitch-soc` patches should also be applied
|
||||||
|
- [`backup.sh`](scripts/backup.sh): Backs up Postgres, Redis, and `.env.production` secrets to a `.tar.gz` file in `/home/mastodon/backups` — useful for a periodic cronjob
|
||||||
|
- [`setup_nginx.sh`](scripts/setup_nginx.sh): Sets up symlinks from `/etc/nginx` to nginx confs in this repo
|
||||||
|
- [`tootctl_shim.sh`](scripts/tootctl_shim.sh): Small shell shim to run `tootctl` in `/home/mastodon/live` as the `mastodon` user by anyone & from anywhere
|
||||||
|
- Add this line to the `.bash_profile` of the user you normally login as:
|
||||||
|
- `. /home/mastodon/utils/scripts/tootctl_shim.sh`
|
||||||
|
- [`upgrade.sh`](scripts/upgrade.sh): Upgrades Mastodon server (latest version if vanilla Mastodon, latest commit if `glitch-soc`) and re-applies patches listed above
|
||||||
|
- [`version.sh`](scripts/version.sh): Tests `tootctl_shim.sh` by printing Mastodon version (`tootctl version`)
|
||||||
|
- [`weekly_cleanup.sh`](scripts/weekly_cleanup.sh): Runs Mastodon's built-in [cleanup commands](https://docs.joinmastodon.org/admin/setup/#cleanup), designed for a [weekly cronjob](https://github.com/jakejarvis/mastodon-utils/wiki/Cleanup-tasks)
|
||||||
|
- Keeps 7 days of media (in object storage)
|
||||||
|
- Keeps 90 days of generated preview cards
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
@ -3,7 +3,7 @@ worker_processes auto;
|
|||||||
pid /run/nginx.pid;
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
# compiled brotli modules from https://github.com/google/ngx_brotli
|
# compiled brotli modules from https://github.com/google/ngx_brotli
|
||||||
# see: https://github.com/jakejarvis/mastodon-scripts/wiki/Brotli-compression-for-nginx
|
# see: https://github.com/jakejarvis/mastodon-utils/wiki/Brotli-compression-for-nginx
|
||||||
load_module modules/ngx_http_brotli_filter_module.so;
|
load_module modules/ngx_http_brotli_filter_module.so;
|
||||||
load_module modules/ngx_http_brotli_static_module.so;
|
load_module modules/ngx_http_brotli_static_module.so;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ server {
|
|||||||
gzip_min_length 256;
|
gzip_min_length 256;
|
||||||
|
|
||||||
# https://github.com/google/ngx_brotli#sample-configuration
|
# https://github.com/google/ngx_brotli#sample-configuration
|
||||||
# https://github.com/jakejarvis/mastodon-scripts/wiki/Brotli-compression-for-nginx
|
# https://github.com/jakejarvis/mastodon-utils/wiki/Brotli-compression-for-nginx
|
||||||
brotli on;
|
brotli on;
|
||||||
brotli_comp_level 4;
|
brotli_comp_level 4;
|
||||||
brotli_static on;
|
brotli_static on;
|
||||||
|
@ -6,26 +6,26 @@ set -euo pipefail
|
|||||||
# default paths
|
# default paths
|
||||||
MASTODON_ROOT=/home/mastodon
|
MASTODON_ROOT=/home/mastodon
|
||||||
APP_ROOT="$MASTODON_ROOT/live"
|
APP_ROOT="$MASTODON_ROOT/live"
|
||||||
SCRIPTS_ROOT="$MASTODON_ROOT/scripts"
|
UTILS_ROOT="$MASTODON_ROOT/utils"
|
||||||
RBENV_ROOT="$MASTODON_ROOT/.rbenv"
|
RBENV_ROOT="$MASTODON_ROOT/.rbenv"
|
||||||
|
|
||||||
# clone this repo if it doesn't exist in the proper location
|
# clone this repo if it doesn't exist in the proper location
|
||||||
if [ ! -d "$SCRIPTS_ROOT" ]
|
if [ ! -d "$UTILS_ROOT" ]
|
||||||
then
|
then
|
||||||
sudo -u mastodon git clone https://github.com/jakejarvis/mastodon-scripts.git "$SCRIPTS_ROOT"
|
sudo -u mastodon git clone https://github.com/jakejarvis/mastodon-utils.git "$UTILS_ROOT"
|
||||||
|
|
||||||
# fix permissions
|
# fix permissions
|
||||||
sudo chown -R mastodon:mastodon "$SCRIPTS_ROOT"
|
sudo chown -R mastodon:mastodon "$UTILS_ROOT"
|
||||||
sudo git config --global --add safe.directory "$SCRIPTS_ROOT"
|
sudo git config --global --add safe.directory "$UTILS_ROOT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# apply custom patches
|
# apply custom patches
|
||||||
cd "$APP_ROOT"
|
cd "$APP_ROOT"
|
||||||
sudo -u mastodon git apply --reject --allow-binary-replacement "$SCRIPTS_ROOT"/patches/*.patch
|
sudo -u mastodon git apply --reject --allow-binary-replacement "$UTILS_ROOT"/patches/*.patch
|
||||||
if [ -d "$APP_ROOT/app/javascript/flavours/glitch" ];
|
if [ -d "$APP_ROOT/app/javascript/flavours/glitch" ];
|
||||||
then
|
then
|
||||||
# apply additional glitch-only patches:
|
# apply additional glitch-only patches:
|
||||||
sudo -u mastodon git apply --reject --allow-binary-replacement "$SCRIPTS_ROOT"/patches/glitch/*.patch
|
sudo -u mastodon git apply --reject --allow-binary-replacement "$UTILS_ROOT"/patches/glitch/*.patch
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update dependencies
|
# update dependencies
|
||||||
|
32
scripts/setup_nginx.sh
Executable file
32
scripts/setup_nginx.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# symlinks files from this repo to their proper location
|
||||||
|
|
||||||
|
# exit when any step fails
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# default paths
|
||||||
|
MASTODON_ROOT=/home/mastodon
|
||||||
|
APP_ROOT="$MASTODON_ROOT/live"
|
||||||
|
UTILS_ROOT="$MASTODON_ROOT/utils"
|
||||||
|
|
||||||
|
# clone this repo if it doesn't exist in the proper location
|
||||||
|
if [ ! -d "$UTILS_ROOT" ]
|
||||||
|
then
|
||||||
|
sudo -u mastodon git clone https://github.com/jakejarvis/mastodon-utils.git "$UTILS_ROOT"
|
||||||
|
|
||||||
|
# fix permissions
|
||||||
|
sudo chown -R mastodon:mastodon "$UTILS_ROOT"
|
||||||
|
sudo git config --global --add safe.directory "$UTILS_ROOT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# setup nginx config
|
||||||
|
sudo rm -rf /etc/nginx/sites-available
|
||||||
|
sudo rm -rf /etc/nginx/sites-enabled/*
|
||||||
|
sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
|
||||||
|
sudo ln -sf "$UTILS_ROOT/etc/nginx/nginx.conf" /etc/nginx/nginx.conf
|
||||||
|
sudo ln -sf "$UTILS_ROOT/etc/nginx/modules" /usr/lib/nginx/modules
|
||||||
|
sudo ln -sf "$UTILS_ROOT/etc/nginx/sites-available" /etc/nginx/sites-available
|
||||||
|
sudo ln -sf /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf
|
||||||
|
sudo ln -sf /etc/nginx/sites-available/mastodon.conf /etc/nginx/sites-enabled/mastodon.conf
|
||||||
|
sudo nginx -t
|
||||||
|
sudo nginx -s reload
|
@ -1,7 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
MASTODON_ROOT=/home/mastodon
|
MASTODON_ROOT=/home/mastodon
|
||||||
APP_ROOT="$MASTODON_ROOT/live"
|
APP_ROOT="$MASTODON_ROOT/live"
|
||||||
RBENV_ROOT="$MASTODON_ROOT/.rbenv"
|
RBENV_ROOT="$MASTODON_ROOT/.rbenv"
|
||||||
|
@ -6,7 +6,7 @@ set -euo pipefail
|
|||||||
# default paths
|
# default paths
|
||||||
MASTODON_ROOT=/home/mastodon
|
MASTODON_ROOT=/home/mastodon
|
||||||
APP_ROOT="$MASTODON_ROOT/live"
|
APP_ROOT="$MASTODON_ROOT/live"
|
||||||
SCRIPTS_ROOT="$MASTODON_ROOT/scripts"
|
UTILS_ROOT="$MASTODON_ROOT/utils"
|
||||||
RBENV_ROOT="$MASTODON_ROOT/.rbenv"
|
RBENV_ROOT="$MASTODON_ROOT/.rbenv"
|
||||||
|
|
||||||
# check for existing installation
|
# check for existing installation
|
||||||
@ -30,7 +30,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# pull & apply latest patches
|
# pull & apply latest patches
|
||||||
. "$SCRIPTS_ROOT/scripts/apply_patches.sh"
|
. "$UTILS_ROOT/scripts/apply_patches.sh"
|
||||||
|
|
||||||
# create blank custom.css (this overrides any CSS set in the admin panel, but if that's not being used, then
|
# create blank custom.css (this overrides any CSS set in the admin panel, but if that's not being used, then
|
||||||
# this quickly saves a request to the backend)
|
# this quickly saves a request to the backend)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# cronjob ran once per week at 3 AM on Sunday; see https://crontab.guru/#0_3_*_*_0
|
# cronjob ran once per week at 3 AM on Sunday; see https://crontab.guru/#0_3_*_*_0
|
||||||
# syntax for crontab -e:
|
# syntax for crontab -e:
|
||||||
# 0 3 * * 0 root /home/mastodon/scripts/weekly_cleanup.sh >> /home/mastodon/logs/cron.log 2>&1
|
# 0 3 * * 0 root /home/mastodon/utils/weekly_cleanup.sh >> /home/mastodon/logs/cron.log 2>&1
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user