Skip to content

Instantly share code, notes, and snippets.

View klutchell's full-sized avatar
🏠
Working from home

Kyle Harding klutchell

🏠
Working from home
View GitHub Profile
#!/bin/bash
for file in .github/repos/*.yml; do
# delete custom merge settings
yq e 'del(.repository)' -i "$file"
# delete required approving review count as we use policy-bot instead
yq e 'del(.branches[].protection.required_pull_request_reviews.required_approving_review_count)' -i "$file"
if [ "$(yq e '.branches[].protection.required_pull_request_reviews' "$file")" = "{}" ]; then
@klutchell
klutchell / run.sh
Last active September 19, 2023 18:18
balena-os bulk edit gitmodules
#!/bin/bash
set -euo pipefail
GH_TOKEN="$(<"${HOME}/.github_pat")"
github_org="balena-os"
repo_yaml_match="yocto-based OS image"
clone_root_path="src" # Set the root repository clone path here
# known_branches=("pyro" "rocko" "sumo" "thud" "warrior" "zeus" "dunfell" "honister" "kirkstone" "master" "main") # Add your list of known branches here
# Pull alpine image for the correct platform (avoid pulling the wrong platform on Pi Zero)
balena pull alpine --platform linux/arm/v6
# Run inotifywatch to gather filesystem access statistics for 5m
balena run --rm -it -v /mnt/data:/mnt/data:ro alpine sh -c \
'apk add --no-cache inotify-tools && /usr/bin/inotifywatch -v -t 300 -r /mnt/data'
# Run iostat with 5 min intervals
balena run --rm --privileged alpine iostat -z -k -t -d 300
#!/usr/bin/env bash
set -eux
cleanup() {
sudo umount /mnt/flasher
sudo losetup -d "${loopback_device:-}"
}
trap cleanup EXIT
@klutchell
klutchell / bump-submodule.sh
Last active February 14, 2022 18:34
Bump a submodule to the provided tag using commits in versionist syntax
#!/usr/bin/env bash
module_path="${1}"
tag="${2}"
tag() {
if [[ $1 == v* ]]
then
echo "${1/v/}"
else
@klutchell
klutchell / registry.sh
Last active November 1, 2021 13:17
Given a DockerHub repo and tag, return a list of identical manifest tags
#!/usr/bin/env bash
# only supports hub.docker.com for now
registry="${1:-"https://registry.hub.docker.com"}"
# limited to 100 for hub.docker.com
page_size="${2:-100}"
# avoid reading all pages if at least one match is found
quick=1
@klutchell
klutchell / Dockerfile
Last active April 6, 2021 12:29
buildroot dashboard
ARG BR_VERSION=2020.11
# hadolint ignore=DL3029
FROM --platform=$BUILDPLATFORM klutchell/buildroot-rootfs-amd64:$BR_VERSION as rootfs-amd64
# hadolint ignore=DL3029
FROM --platform=$BUILDPLATFORM klutchell/buildroot-rootfs-arm64:$BR_VERSION as rootfs-arm64
# hadolint ignore=DL3029
FROM --platform=$BUILDPLATFORM klutchell/buildroot-rootfs-arm32v7:$BR_VERSION as rootfs-armv7
@klutchell
klutchell / Dockerfile
Last active April 1, 2021 14:14
python3-slim (buildroot)
#syntax=docker/dockerfile:1.2
FROM klutchell/buildroot-base:2020.11 as build
# copy common config
COPY common.cfg ./.config
# hadolint ignore=SC2215
RUN --mount=type=cache,target=/cache,uid=1000,gid=1000,sharing=private \
make olddefconfig && make source && make
--- poky/meta/recipes-kernel/linux/kernel-devsrc.bb 2020-12-01 11:02:39.510292328 -0500
+++ meta-balena-warrior/recipes-kernel/linux/kernel-devsrc.bb 2020-12-16 14:11:36.146363392 -0500
@@ -104,7 +104,9 @@
fi
if [ "${ARCH}" = "arm64" ]; then
- cp -a --parents arch/arm64/kernel/vdso/vdso.lds $kerneldir/build/
+ if [ -f "arch/arm64/kernel/vdso/vdso.lds" ]; then
+ cp -a --parents arch/arm64/kernel/vdso/vdso.lds $kerneldir/build/
+ fi