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 / 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
#!/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 / 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 / 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
@satmandu
satmandu / google-chrome.desktop
Last active March 3, 2022 16:44
The google-chrome.desktop I use on Ubuntu 22.04 on my MBP11,3. Put in /usr/share/applications/ . Also, I use a patched mesa as per https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5139#note_1279423
[Desktop Entry]
Version=1.0
Name=Google Chrome
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Web Browser
GenericName[ar]=متصفح الشبكة
GenericName[bg]=Уеб браузър
GenericName[ca]=Navegador web
GenericName[cs]=WWW prohlížeč
@satmandu
satmandu / gist:37ce878ba5c3e002b7cb6c3a47aa598a
Last active February 23, 2022 22:11
Extract macos dmg with pkg inside from Linux (ubuntu 22.04)
# Install build prereqs:
sudo apt-get install build-essential libxml2-dev libssl-dev zlib1g-dev
# You can extract a dmg using 7z thus: 7z x File.dmg
# This installs tools like lsbom to see what is inside bom files
git clone https://github.com/hogliux/bomutils && cd bomutils && make && sudo make install
# Now install xar so you can extract the pkg file
curl -OLf https://opensource.apple.com/tarballs/xar/xar-425.2.tar.gz
tar fxv xar-425.2.tar.gz
cd xar-425.2/xar/
curl -OLf https://raw.githubusercontent.com/macports/macports-ports/master/archivers/xar/files/xar-1.8-openssl-1.1.patch
@satmandu
satmandu / ubuntu-mainline-kernel.sh
Created December 18, 2021 22:19
Ubuntu Mainline Kernel update script , modified from forks of https://github.com/pimlie/ubuntu-mainline-kernel.sh
#!/usr/bin/env bash
# shellcheck disable=SC1117
# Ubuntu Kernel PPA info
ppa_host="kernel.ubuntu.com"
ppa_index="/~kernel-ppa/mainline/"
ppa_key="17C622B0"
# If quiet=1 then no log messages are printed (except errors)
@satmandu
satmandu / chromeos_docker.sh
Last active August 5, 2021 18:07
Updated ChromeOS docker container script
#!/bin/bash
# chromeos_docker.sh
# Usage:
# chromeos_docker.sh recoveryfileurl name 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
@satmandu
satmandu / gcc10.rb
Created April 14, 2021 12:38
gcc 10.3.0 chromebrew package WIP
require 'package'
class Gcc10 < Package
description 'The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, and Go.'
homepage 'https://www.gnu.org/software/gcc/'
version '10.3.0'
@isl_ver = '0.23'
compatibility 'all'
license 'GPL-3'
source_url 'https://gcc.gnu.org/pub/gcc/releases/gcc-10.3.0/gcc-10.3.0.tar.xz'
@satmandu
satmandu / getdeps
Last active March 25, 2021 18:11
Chromebrew get actual runtime dependencies for a package
#!/bin/env bash
# set -x
pkg="${1}"
CREW_LIB_PREFIX=$(crew const | grep CREW_LIB_PREFIX | awk -F = '{print $2}')
# Which packages have a needed library in CREW_LIB_PREFIX
# This is a subset of what crew whatprovides gives
whatprovidesfxn() {
pkgdepslcl="${1}"
filelcl=$(grep "$pkgdepslcl" /usr/local/etc/crew/meta/*.filelist | grep $CREW_LIB_PREFIX)