Skip to content

Instantly share code, notes, and snippets.

View linux4life798's full-sized avatar

Craig Hesling linux4life798

View GitHub Profile
@linux4life798
linux4life798 / debian-btrfs-on-luks.md
Last active June 24, 2026 01:47
Debian install btrfs directly on LUKS

Install Debian using BTRFS as root directly on LUKS (without LVM)

  1. Use non-grphical expert install mode Advanced options -> Expert install
  2. Enable all relevant crypto, fdisk, parted, and rescue installer modules.
  3. Run setup down to and including detect disks
  4. At the agenda menu select the second to last step that says Execute a shell
  5. Provision the LUKS an BTRFS volumes
    parted -s -a optimal /dev/sda \

mklabel gpt \

@linux4life798
linux4life798 / test-oidc.bash
Created January 13, 2026 22:15
Messy educational example to understand OIDC flow
#!/bin/bash
# Test and learn about OpenID Connect.
ISSUER="https://auth.blah.com"
REDIRECT_URI="http://127.0.0.1:7777/callback"
CLIENT_ID="BLAHHHHHHH"
CLIENT_SECRET="BLAHHHHHHH"
main() {
echo "Getting openid configuration:"
@linux4life798
linux4life798 / docker-btrfs-migrate.bash
Created November 19, 2025 23:54
Migrate a /var/lib/docker from one BTRFS filesystem to another encapsulating BTRFS filesystem and subvolumes.
#!/bin/bash
# Migrate a /var/lib/docker from one BTRFS filesystem to another encapsulating
# BTRFS filesystem and subvolume(s).
#
# This script tries to correctly handle transfering the hierarchy of subvolumes
# and snapshots that Docker creates in the /var/lib/docker/btrfs/subvolumes
# directory, when it was using the btrfs storage driver.
#
# This is situation when you start using Docker on a machine using BTRFS as
# the root filesystem, but forgot to create an encapsulating subvolume for
@linux4life798
linux4life798 / msg-run.bash
Last active June 2, 2026 20:15
My bash msg-run function, but self contained for easy copy/paste. The full version can be found https://github.com/linux4life798/bash-includes/blob/main/bash_include.d/1-msg-print.bash .
# https://github.com/linux4life798/bash-includes/blob/main/bash_include.d/1-msg-print.bash
# Print command before running it.
# Usage: msg-run [cmd] [args...]
#
# Example: msg-run sudo apt install -y vim
msg-run() {
local f="" redir=""
# Use $$ and /proc because we subshell this check, thus we need parent PID and can't use /dev/fd.
for f in " <$(readlink /proc/$$/fd/0)" " >$(readlink /proc/$$/fd/1)" " 2>$(readlink /proc/$$/fd/2)"; do
# Craig added on Sep 17, 2025.
# /etc/apt/apt.conf.d/80snapper-boot
#
# This uses snapper to do pre and post snapshots of the "boot" config/volume.
# This mirrors what 80snapper config does for the "root" config/volume, but
# applies it to the "boot" config.
# See https://salsa.debian.org/debian/snapper/-/blob/debian/sid/debian/80snapper.
#
# When snapper is run without a config "-c root" argument it will default to the
# "root" config, which is how the original 80snapper script functions.
@linux4life798
linux4life798 / dew_point.yaml
Last active August 8, 2025 20:50
Home Assistant dew point blueprint template
blueprint:
name: Dew Point (Template Sensor)
description: >
Create a dew point sensor from temperature and relative humidity using
precise psychrometric formulas. Defaults to Buck (1981, ice/water split);
Magnus–Tetens (Alduchov & Eskridge, 1996) available as an alternative.
domain: template
source_url: https://gist.github.com/linux4life798/417a932a54503c9747d3a3a40219ac46
input:
temperature_entity:
@linux4life798
linux4life798 / udev-protected-usb-storage.md
Last active January 12, 2026 22:26
Protect USB storage devices, holding alternative operating systems, from overwrite

1. Identify device filtering criteria

Use sudo udevadm info /dev/sda to determine serial numbers or other attributes to filter on.

2. Add/edit udev rules

/etc/udev/rules.d/99-protected-usb-storage.rules:

# Craig Jul 29, 2025
@linux4life798
linux4life798 / chroot-enter.bash
Last active April 22, 2025 23:19
Script to setup and enter a chroot
#!/bin/bash
# Craig Hesling <craig@hesling.com>
set -e
root="$1"
if [[ -z "$root" || ! -d "$root" ]]; then
echo "Error: Directory '$root' does not exist"
echo
@linux4life798
linux4life798 / nginx_proxy_default.conf
Last active April 19, 2025 05:50
Change Home Assistant NGINX SSL Proxy Listening Port
# /share/nginx_proxy_default.conf
# Blank.
# apk add cadaver
sudo apt install cadaver

cadaver http://100.100.100.100:8080/<tailnet_name>/<host>/<share>
> ls