Skip to content

Instantly share code, notes, and snippets.

View satmandu's full-sized avatar

Satadru Pramanik, DO, MPH, MEng satmandu

View GitHub Profile
@satmandu
satmandu / chromeos_docker35
Last active April 20, 2024 02:38
Docker buildx based package builder for Chromebrew on x86_64, i686, & armv7l, generating containier scripts at https://gist.github.com/satmandu/d8365cb70b899901a05290d31c04909a
#!/bin/bash
# chromeos_docker.sh
# Usage:
# REPOSITORY=YOUR_DOCKER_HUB_REPOSITORY_NAME chromeos_docker.sh recovery_file_url container_name chromeos_milestone arch
# or if image.bin already exists this works too:
# chromeos_docker.sh dummy name milestone arch
# (Default is not to delete the image after download.)
# e.g.
# Example for x86_64:
# chromeos_docker.sh https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_13816.82.0_nocturne_recovery_stable-channel_mp.bin.zip nocturne 90 x86_64
#!/bin/bash
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
SESSION_TYPE=remote/ssh
elif pstree -p | egrep --quiet --extended-regexp ".*sshd.*\($$\)"; then
SESSION_TYPE=remote/ssh
else
case $(ps -o comm= -p $PPID) in
sshd|*/sshd) SESSION_TYPE=remote/ssh;;
esac
fi
@satmandu
satmandu / usbtrim
Last active March 31, 2024 00:54
Detect and enable trim for usb-connected sata/nvme drives in initramfs/initrd, ideally before zfs modules load.
#!/bin/bash
# This goes in /usr/share/initramfs-tools/hooks/usbtrim
case $1 in
prereqs)
echo "udev"
exit 0
;;
esac
@satmandu
satmandu / bashprompt.sh
Last active March 31, 2024 00:54
bash prompt with color, xterm title setting, and ssh host in title
# Goes in .bashrc
# Heavily cribbed from
# https://stackoverflow.com/a/16715681
# and inspired by
# https://unix.stackexchange.com/a/420090
__prompt_command() {
local EXIT="$?" # This needs to be first
PS1=""
local RCol='\[\e[0m\]'
@satmandu
satmandu / a_enable_wireless.sh
Last active March 31, 2024 00:51 — forked from telenieko/a_enable_wireless.sh
Sample files to enable wireless on Debian initramfs
#!/bin/sh
# this goes into /etc/initramfs-tools/scripts/init-premount/a_enable_wireless
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
@satmandu
satmandu / raspios.sh
Last active December 15, 2023 07:27
Generate Raspberry Pi OS Docker Images
#!/bin/bash
# raspios.sh
# Usage:
# REPOSITORY=YOUR_DOCKER_HUB_REPOSITORY_type raspios image_file_url debian_release type date ARCH
# or if img already exists this works too:
# raspios.sh dummy debian_release type date ARCH
# (Default is not to delete the image after download.)
# e.g.
# Example for arm64:
# ./raspios.sh https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-12-06/2023-12-05-raspios-bookworm-arm64-lite.img.xz bookworm lite 2023-12-06 arm64
@satmandu
satmandu / make_current_arm64_rpi_kernel_debs.sh
Last active October 22, 2023 11:06
Make arm64 deb packages for the offical Raspberry Pi Foundation arm64 kernels, tested with ubuntu 23.04
#!/bin/bash -x
# make_arm64_rpi_kernel_debs.sh
# Builds arm64 debian packages from the CURRENT rpi firmware repository kernel which is installed by:
# sudo rpi-update
# This runs on an arm64 host with arm64 compilation tools...
# or with some sort of cross-compilation setup.
# Debs are put in $workdir/build
#
# This will NOT work in Raspbian unless you have an arm64 compilation
# environment setup. Appears to work on
@satmandu
satmandu / build_arm64_rpi_userland.sh
Last active July 22, 2023 23:37
Generate an arm64 rpi userland for use on ubuntu/arm64.
#!/bin/bash -x
workdir="${HOME}/workdir"
[[ ! -d "$workdir" ]] && ( mkdir -p "$workdir" || exit 1)
[[ ! -d "$workdir"/tmp ]] && ( mkdir -p "$workdir"/tmp || exit 1)
[[ ! -d "$workdir"/output ]] && ( mkdir -p "$workdir"/output || exit 1)
echo "workdir is ${workdir}"
tmpdir=$(mktemp -d deb_XXXX -p "$workdir"/tmp)
deb_temp=${tmpdir}/deb
extract_tmp=${tmpdir}/extract
@satmandu
satmandu / zfs_build
Last active April 21, 2023 17:13
Compiles zfs 2.0.1 for ubuntu & debian systems (tested on x86_64 [groovy] and arm64 [raspi_os]). Not tested with zsys. . In a new folder do this to make zfs debs: curl -OLf https://gist.github.com/satmandu/3aebcd7d26cdc588b40af29f1be6009c/raw/8bd4ce4dc67ba258b9b6f613c1b604fdade9e552/zfs_build && chmod +x zfs_build && ./zfs_build
#!/bin/bash -x
main () {
VER=10
export CC="ccache gcc-${VER}"
export CXX="ccache g++-${VER}"
export SHLIB_CXXLD="g++-${VER}"
#FC="ccache gfortran"
#F77="ccache gfortran"
zfs_work="$(pwd)/$(uname -m)"
mkdir -p "${zfs_work}"
@satmandu
satmandu / gist:3fd42c5a538bc34a1636950740838d3e
Created April 12, 2019 03:56
Waveshare35a config info for raspberry pi
From https://www.spotpear.com/learn/EN/raspberry-pi/Raspberry-Pi-LCD/Raspberry-Pi-_Rotate-the-screen-display.html
Raspberry Pi - Rotate the screen display
Raspberry Pi 2.4/3.2 inch LCD
Rotate display
sudo nano /boot/config.txt