Skip to content

Instantly share code, notes, and snippets.

View TimJDFletcher's full-sized avatar

Tim Fletcher TimJDFletcher

View GitHub Profile
@TimJDFletcher
TimJDFletcher / launch-qemu-rpi.sh
Created November 3, 2025 09:13
Launch a virtual raspberry Pi on macOS
#!/usr/bin/env bash
# Requirements:
# - macOS
# - qemu - `brew install qemu`
# - A raw 64-bit Raspberry Pi system image to boot (Usually a .img)
# Raspberry Pi 3
DTB=bcm2710-rpi-3-b-plus.dtb
MACHINE=raspi3b
@TimJDFletcher
TimJDFletcher / bullseye-to-bookworm.sh
Created June 24, 2023 16:18
Upgrading Debian again
#!/bin/bash
set -eux -o pipefail
# Remove old pi packages list
sudo rm -f /etc/apt/apt.conf.d/99rpimonitor /etc/apt/sources.list.d/rpi-monitor.list
# Replace version name in all source lists and fix up naming
sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/* /etc/apt/sources.list
sudo sed -i '/debian-security\//b; s/\/debian-security/\/debian-security\//g' /etc/apt/sources.list.d/* /etc/apt/sources.list
sudo sed -i '/security/ s,bookworm/updates,bookworm-security,g' /etc/apt/sources.list.d/* /etc/apt/sources.list
@TimJDFletcher
TimJDFletcher / buster-to-bullseye.sh
Last active April 3, 2023 08:17
Upgrade from Buster to Bullseye
#!/bin/bash
set -eux -o pipefail
# Remove old pi packages list
sudo rm -f /etc/apt/apt.conf.d/99rpimonitor /etc/apt/sources.list.d/rpi-monitor.list
# Replace version name in all source lists and fix up naming
sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/* /etc/apt/sources.list
sudo sed -i '/debian-security\//b; s/\/debian-security/\/debian-security\//g' /etc/apt/sources.list.d/* /etc/apt/sources.list
sudo sed -i '/security/ s,bullseye/updates,bullseye-security,g' /etc/apt/sources.list.d/* /etc/apt/sources.list
@TimJDFletcher
TimJDFletcher / stretch-to-buster.sh
Last active August 22, 2019 21:09
Upgrade from Stretch to Buster
#!/bin/bash
set -eux -o pipefail
# Bug fixes
sudo rm -f /etc/apt/apt.conf.d/99rpimonitor
# Replace stretch with buster in all source lists
sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/* /etc/apt/sources.list
# Run the upgrade
@TimJDFletcher
TimJDFletcher / packer-permissions.json
Last active December 9, 2019 21:23 — forked from ogrodnek/packer-permissions.json
packer IAM permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "NonResourceBasedReadOnlyPermissions",
"Action": [
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSnapshots",
"ec2:DescribeImages",
@TimJDFletcher
TimJDFletcher / GNUPG_agent_forwarding.md
Last active November 6, 2026 10:30 — forked from surhudm/GNUPG_agent_forwarding.md
GnuPG agent forwarding

Forward the GnuPG agent from macOS to Linux

Your private keys stay on the Mac, or on your YubiKey, and gpg on the Linux host uses them over SSH.

Last tested in October 2026 from macOS with GnuPG 2.5.24 and OpenSSH 10.5 to Debian 13 with GnuPG 2.4.7 and OpenSSH 10.0. You need GnuPG 2.1.17 or newer on both ends and OpenSSH 6.7 or newer.

On the Mac

Install GnuPG and a graphical pinentry. Passphrase and PIN prompts appear on the Mac, so a terminal pinentry won't work for a request that comes from the remote host.

@TimJDFletcher
TimJDFletcher / ipv6-check.yml
Created September 3, 2017 20:30
Check IPv6 connections with ansible
---
- hosts: all
gather_facts: false
tasks:
- name: Get information from ds.testmyipv6.com
raw: curl http://ds.testmyipv6.com/
changed_when: false
register: connection_test
- debug:
@TimJDFletcher
TimJDFletcher / multi-gunzip.sh
Last active June 23, 2017 10:28
Simple bash script to loop over a multi layered gzip file
#!/bin/bash
set -e
maxloop=100
loop=0
file="$1"
while file "${file}" | grep -q "gzip compressed data" ; do
temp=$(mktemp)
gzip -dc "${file}" > ${temp}
mv ${temp} "${file}"
loop=$((loop+1))
@TimJDFletcher
TimJDFletcher / ssh-keygen.service
Created May 13, 2017 15:54
Systemd unit to generate missing ssh keys on boot
[Unit]
Description=Generate sshd keys
Before=ssh.server
[Service]
Type=oneshot
ExecStart=/usr/bin/ssh-keygen -A
RemainAfterExit=true
StandardOutput=journal
@TimJDFletcher
TimJDFletcher / appify.sh
Created January 2, 2017 11:45 — forked from oubiwann/appify.sh
appify — create the simplest possible Mac app from a shell script (adds an application icon)
#!/usr/bin/env bash
VERSION=4.0.1
SCRIPT=`basename "$0"`
APPNAME="My App"
APPICONS="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericApplicationIcon.icns"
OSX_VERSION=`sw_vers -productVersion`
PWD=`pwd`
function usage {