Skip to content

Instantly share code, notes, and snippets.

@grifferz
grifferz / exim.conf
Created Jul 11, 2022
Saving a copy of all bounce messages with Exim4
View exim.conf
# /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 Jun 24, 2022
bash script to dump mailman3's mysql tables excluding hyperkitty archives
View mailman3-mysqldump.bash
#!/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 Jan 28, 2022
Hack to get BitFolk's static IP setup on a Debian Live image
View fix-9990-networking.sh.patch
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"
-
@grifferz
grifferz / sync-esps.sh
Last active May 31, 2021
Sync EFI System Partition to redundant copy if necessary
View sync-esps.sh
#!/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 / shaper.sh
Created Dec 26, 2020
Hacky script to use an ifb interface to shape traffic both ways on another interface
View shaper.sh
#!/bin/sh
# shaper.sh eth1 clear # removes traffic shaping
# shaper.sh eth1 1000 # shapes eth1 to 1Mbit/s in both directions
# Andy Smith <andy@bitfolk.com>
intf="$1"
bw="$2"
ifb="ifb0"
@grifferz
grifferz / fix_tags.pl
Created Jan 8, 2020
Given YAML file from gather_tags.pl, stuff tags back into current copy of photos
View fix_tags.pl
#!usr/bin/env perl
# This uses the YAML generated by gather_tags.pl
#
# See: https://gist.github.com/grifferz/5b116b87d93ee9586a053a4021ef86fc
use strict;
use warnings;
use utf8;
@grifferz
grifferz / gather_tags.pl
Created Jan 8, 2020
Get all the "Keywords", "Subject" and "TagsList" tags from my photos and save them out as a YAML file
View gather_tags.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode qw(decode_utf8);
@ARGV = map { decode_utf8($_, 1) } @ARGV;
@grifferz
grifferz / blkleaderboard.sh
Last active Apr 29, 2021
Block device leaderboard
View blkleaderboard.sh
#!/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 / attackers.sh
Created Jun 23, 2019
Dumb script to resolve a list of IPs to their reverse DNS and AS details
View attackers.sh
#!/bin/bash
#
# Dumb script to resolve a list of IPs to their reverse DNS and AS details.
#
# This directly calls whois against whois.cymru.com for each line of input
# so if you're going to run it with hundreds of lines of input, maybe don't
# do that and use their DNS zone instead.
#
# Usage
# Pipe a list of counts and IP addresses through me like:
@grifferz
grifferz / git_svn_bash_prompt.sh
Created Feb 12, 2019
Would generally recommend powerline of bashline or oh-my-zsh or something but this makes a fancy bash prompt from scratch
View git_svn_bash_prompt.sh
#!/bin/bash
# Started off being just the git/svn stuff from authors below but then got
# hacked on by me to add other silly things.
#
# Needs:
# - A 256-colour terminal
# - A terminal that supports colour emoji (else you'll need to substitute boring monochrome unicode glyphs and maybe colour them with terminal escapes)
# - Powerline font ("fonts-powerline" on Debian/Ubuntu) for the separator chevrons
# - Add this to your ~/.bashrc like: