Skip to content

Instantly share code, notes, and snippets.

Avatar

Satadru Pramanik satmandu

View GitHub Profile
@satmandu
satmandu / bashprompt.sh
Last active Jun 12, 2020
bash prompt with color, xterm title setting, and ssh host in title
View bashprompt.sh
# 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 / make_current_arm64_rpi_kernel_debs.sh
Last active Oct 15, 2021
Make arm64 deb packages for the offical Raspberry Pi Foundation arm64 kernels + NOW INSTALLS headers package too.
View make_current_arm64_rpi_kernel_debs.sh
#!/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_rstudio_focal.sh
Last active May 12, 2020
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.
View build_rstudio_focal.sh
#!/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 / 70-gapps.sh
Created Apr 10, 2020
not working 70-gapps.sh
View 70-gapps.sh
#!/sbin/sh
#
# ADDOND_VERSION=2
#
# /system/addon.d/70-gapps.sh
#
. /tmp/backuptool.functions
if [ -z $backuptool_ab ]; then
SYS=$S
@satmandu
satmandu / k5.6.3.patch
Last active Feb 27, 2020
Patch for zfs-dkms_0.8.3-1ubuntu5 to fix compatibility with kernel 5.6rc3 as per zfs PR #9961 & PR #1064
View k5.6.3.patch
diff -Npaur a/config/kernel-inode-times.m4 b/config/kernel-inode-times.m4
--- a/config/kernel-inode-times.m4 2020-01-22 16:49:01.000000000 -0500
+++ b/config/kernel-inode-times.m4 2020-02-27 12:40:52.273139053 -0500
@@ -1,8 +1,22 @@
-dnl #
-dnl # 4.18 API change
-dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
-dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
+
@satmandu
satmandu / build_arm64_rpi_userland.sh
Last active Mar 21, 2021
Generate an arm64 rpi userland for use on ubuntu/arm64.
View build_arm64_rpi_userland.sh
#!/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 / nighttime.py
Last active Feb 21, 2020
Sets volumes for all Google home device on the local network programmatically.
View nighttime.py
#!/usr/bin/python3
# Sets volumes for all Google home device on the local network programmatically.
# Adapted from script at https://pastebin.com/ke3Z65pm
# from this discussion by reddit user Mjjjjjjjjjjjjjjjj
# https://www.reddit.com/r/googlehome/comments/8b0b4o/python_script_to_manage_the_volume_of_multiple/
#
from __future__ import print_function
import time
import sys
View use_rpi_bootloader_on_ubuntu_rpi.sh
#!/bin/bash
echo "* Disabling any non-vmlinuz kernel lines"
echo " in /boot/firmware/config.txt ."
sed -i -E '/(^kernel=vmlinuz)/!s/^kernel=/#kernel=/g' /boot/firmware/config.txt
echo "* Adding line to use the rpi bootloader to load the kernel"
echo " in /boot/firmware/config.txt ."
if ! grep -qs '^kernel=vmlinuz' /boot/firmware/config.txt
then echo "kernel=vmlinuz" >> /boot/firmware/config.txt
fi
echo "* Adding line to use the rpi bootloader to load the initrd"
@satmandu
satmandu / overlayon.sh
Created Jan 9, 2020
set overlay on so that everything mounts at boot
View overlayon.sh
#!/bin/bash
for f in `sudo zfs list -H| awk '{print $1}'`; do sudo zfs set overlay=on "$f" ; done
@satmandu
satmandu / mount_zfs.sh
Last active Nov 20, 2019
Alternative non-bpool/rpool zpool mount service for ubuntu 19.10
View mount_zfs.sh
#!/bin/bash -e
#export PS4='+(${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
# Place in /usr/local/sbin/mount_zfs.sh
USAGE="Usage: $0 zpool1 zpool2 zpool3 ... zpoolN"
MOUNTATTEMPTS=50
COUNTER=1
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 0