Skip to content

Instantly share code, notes, and snippets.

View linux4life798's full-sized avatar

Craig Hesling linux4life798

View GitHub Profile
@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 November 19, 2025 18:46
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 in Blue and then run it.
# Usage: msg-run [cmd] [args...]
#
# Example: msg-run confirm
msg-run() {
local f="" redir=""
for f in " <$(readlink /proc/$$/fd/0)" " >$(readlink /proc/$$/fd/1)" " 2>$(readlink /proc/$$/fd/2)"; do
redir+="${f##*/dev/pts/*}"
# 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 July 29, 2025 23:17
Protect USB storage devices, holding alternative operating systems, from overwrite

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

# Craig Jul 29, 2025
#
# Prevent accidentally writing over alt OS boot volumes, like my
# Framework 1TB Expansion card for Windows 11.
#
# sudo udevadm control --reload-rules
@linux4life798
linux4life798 / chroot-enter.bash
Last active April 22, 2025 23:19
Script to setup and enter a chroot
#!/bin/bash
# Craig Hesling <[email protected]>
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
@linux4life798
linux4life798 / unraid_installer.md
Last active December 2, 2024 03:06
Setup an Unraid inestaller on USB driver on Linux
@linux4life798
linux4life798 / portainer.md
Last active July 29, 2024 09:30
Setup Portainer on Debian with Tailscale