Skip to content

Instantly share code, notes, and snippets.

@grifferz
grifferz / blkleaderboard.sh
Last active April 22, 2024 02:43
Block device leaderboard
#!/bin/bash
# Paste at shell prompt (or download and execute) and get:
#
# sdc 9936 hours ( 1.13 years) 3.49TiB SAMSUNG MZ7KH3T8
# nvme0n1 9936 hours ( 1.13 years) 3.49TiB SAMSUNG MZQLB3T8HALS-00007
# sde 9932 hours ( 1.13 years) 4.55TiB ST5000LM000-2AN1
# sdd 9931 hours ( 1.13 years) 4.55TiB ST5000LM000-2AN1
# sdb 9617 hours ( 1.09 years) 0.01TiB SuperMicro SSD
# sda 9616 hours ( 1.09 years) 0.01TiB SuperMicro SSD
@grifferz
grifferz / mastodon_well_known.conf
Last active September 27, 2023 08:47
Apache config snippet to redirect Mastodon webfinger
RewriteEngine On
RewriteCond %{QUERY_STRING} ^resource=acct:andy@ [NC]
RewriteRule /.well-known/webfinger https://social.bitfolk.com/.well-known/webfinger?resource=acct:grifferz@social.bitfolk.com [NC,L,R=301]
RewriteCond %{QUERY_STRING} ^resource=acct:grifferz@ [NC]
RewriteRule /.well-known/webfinger https://social.bitfolk.com/.well-known/webfinger?resource=acct:grifferz@social.bitfolk.com [NC,L,R=301]
@grifferz
grifferz / sync-esps.sh
Last active April 10, 2023 15:01
Sync EFI System Partition to redundant copy if necessary
#!/bin/sh
# Keep two different EFI System Partitions (ESP) in sync, because it's 2021 and
# EFI still doesn't support software RAID properly. The idea being to add boot
# entries for both:
#
# $esp1/grubx64.efi
#
# …and:
#
@grifferz
grifferz / cache_age_percentiles.sh
Created November 26, 2022 22:00
Mastodon media cache ages by percentile
#!/bin/sh
# Shows various percentiles for the age of your media attachments, i.e. the
# stuff under mastodon/web/system/cache/media_attachments/
# Usage:
# - Have psql installed so you can connect to your database.
# - Make sure to set PGUSER, PGHOST and PGDATABASE environment variables.
# - Also set PGPASSWORD otherwise it will ask you.
# ./cache_age_percentiles.sh
@grifferz
grifferz / cache_by_ext_bytes.sh
Last active November 26, 2022 16:17
Mastodon cache files by byte count and extension
#!/bin/sh
# Probably needs GNU AWK. Come to think of it, some OSes
# won't have a `find` with -printf like GNU does.
# Usage:
# ./cache_by_ext_bytes.sh /path/to/mastodon/system/cache
cache_dir=${1-/opt/mastodon/web/system/cache}
# This will handle spaces in filenames, but not newlines in filenames…
@grifferz
grifferz / cache_by_ext.sh
Last active November 26, 2022 16:11
Mastodon cache contents by file extension
#!/bin/sh
# Probably needs GNU AWK. Come to think of it, some OSes
# won't have a `find` with -printf like GNU does.
# Usage:
# ./cache_by_ext.sh /path/to/mastodon/system/cache
cache_dir=${1-/opt/mastodon/web/system/cache}
find "$cache_dir" -type f -printf "%p\n" \
MIME-Version: 1.0
From: BitFolk test Email <andy-test@bitfolk.com>
To: andy@strugglers.net
Subject: BitFolk test email (Without multipart/mixed container)
X-Mailer: BitFolk Test Script
Organization: BITFOLK LIMITED, Registered in England (No. 6032951, VAT no.
990 4159 02); 21 Trevithick Close, Feltham, Greater London, TW14 9XJ,
United Kingdom; https://bitfolk.com/contact.html
Content-Type: multipart/mixed; boundary="----------=_1665404967-3424-0"
@grifferz
grifferz / exim.conf
Created July 11, 2022 02:11
Saving a copy of all bounce messages with Exim4
# /etc/exim4/conf.d/router/050_traffic_tap
# This should be the first defined router.
traffic_tap:
unseen
no_expn
no_verify
transport = local_copy_outgoing
driver = accept
# "mm_domains" is a list of domain names for mailman, e.g.
# "lists.example.com"; it's set as part of the usual Mailman install on
@grifferz
grifferz / mailman3-mysqldump.bash
Created June 24, 2022 20:17
bash script to dump mailman3's mysql tables excluding hyperkitty archives
#!/bin/bash
# Needs bash because uses bash arrays.
# Use mysqldump to dump out the mailman3 and mailman3web databases
# through a pipe to gzip, then move it on top of the last backup. It
# is assumed your general backup system takes care of backing up those
# files elsewhere, keeping historical copies.
#
# All tables from the mailman3 database are dumped out, but only the
@grifferz
grifferz / fix-9990-networking.sh.patch
Created January 28, 2022 21:22
Hack to get BitFolk's static IP setup on a Debian Live image
diff -Naur a/usr/lib/live/boot/9990-networking.sh b/usr/lib/live/boot/9990-networking.sh
--- a/usr/lib/live/boot/9990-networking.sh 2022-01-28 21:16:07.880622551 +0000
+++ b/usr/lib/live/boot/9990-networking.sh 2022-01-28 21:15:40.504719118 +0000
@@ -104,16 +104,25 @@
fi
done
else
- for interface in ${DEVICE}; do
- ipconfig -t "$ETHDEV_TIMEOUT" "${interface}" | tee "/netboot-${interface}.config"
-