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 / build_rstudio_focal.sh
Last active August 27, 2022 15:44
COMPLETELY UNSUPPORTED way to build rstudio from the v1.3-patches branch with QT 5.15 for ubuntu/20.04 focal & R 4.0. Put both files in the same directory. Note a docker install is needed for this to work.
#!/bin/bash -ex
git_branch="v1.3-patch"
git_base="https://github.com/rstudio/rstudio"
QT_VERSION=5.15.0
now=$(date +"%m%d%Y%H%M")
#docker build --pull --no-cache -f Dockerfile.focal-amd64 -t rstudio:focal-amd64 .
# following from https://stackoverflow.com/a/246128
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
@satmandu
satmandu / bounce_ipv6.sh
Created January 17, 2023 23:02
Bounce IPv6 connection if router is up but IPv6 connectivity is down, and check the connection every 30 seconds.
#!/bin/bash
# Put this script into your crontab e.g.
# @reboot ~/bin/bounce_ipv6.sh
# Bounce IPv6 connection if router is up but IPv6 connectivity is down,
# and check the connection every 30 seconds.
router_address="192.168.0.1"
ipvsixaddress="2600::"
while true;
do
if ping -c1 $router_address &>/dev/null; then
@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
@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 / 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 / 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 / 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 / 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 / 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
#!/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