Skip to content

Instantly share code, notes, and snippets.

@smoser
smoser / README.md
Last active February 21, 2023 18:08
[fosdem 2023 talk] oci images in squashfs format with dm-verity

Fosdem 2023 Talk on use of squashfs in oci images

@smoser
smoser / README.md
Last active January 18, 2023 14:53
raspberry pi in qemu / Romi emulation

Raspberry pi / Romi in qemu

When working with photonvision and without a romi in front of me, I decided to give qemu a try.

It works, but it is very slow.

See the 'boot' script provided for booting.

Getting Romi 2023 image going.

Romi notes

  • system reboots twice before staying up
@smoser
smoser / inscreen
Last active December 18, 2022 15:29
run a command in screen
#!/bin/sh
#
# upstream: git://gist.github.com/1019125.git
VERBOSITY=0
LOCK=""
CR="
"
error() { echo "$@" 1>&2; }
@smoser
smoser / README.md
Created June 28, 2022 18:07
subprocess python wrapper named 'subp'.

subp - a python subprocess wrapper

This is just a wrapper around python subprocess that I like to use. It originated during cloud-init development.

Some things that I like about it:

  • SubpResult prints well.
  • times how long subpocesses take, that is available in the SubpResult.
  • takes a timeout and a signal to send to the subprocess. The python standard library will only ever send SIGKILL which does not give the process time to cleanup.
@smoser
smoser / distro_info_dict
Created October 1, 2013 19:54
extract data from distro_info to a dict. Quite possibly this should just read from /usr/share/distro-info/ubuntu.csv instead of using distro_info library. However, this seems functional for what I needed.
#!/usr/bin/python
import distro_info
def get_ubuntu_info(date=None):
# this returns a sorted list of dicts
# each dict has information about an ubuntu release.
# Notably absent is any date information (release or eol)
# its harder than you'd like to get at data via the distro_info library
@smoser
smoser / inotify-hack
Created April 27, 2016 18:21
inotifywait example
#!/bin/bash
# just an example using inotifywait. the 'process' function basically reads from
# the output of inotifywait and then when it is found what it is after it will kill the
# inotifywait process.
#
# used this to hack a dpkg postinst script that wasnt yet installed and enable some debugging
# in it before it was run.
LAUNCH_PID=""
LOG="/run/${0##*/}.log"
set -f
@smoser
smoser / README.md
Last active August 31, 2022 15:44
A deb upload client for artifactory

deb-artifactory - publish a deb to artifactory

This is an example client to upload debs to artifactory.

Example usage is pretty simple:

$ export ARTIFACTORY_CREDS=AKCp.........BuV
$ ./deb-artifactory https://smoser0.jfrog.io/artifactory/test1 my.deb

Things this does:

@smoser
smoser / README.md
Last active August 2, 2022 18:30
test kernel and initrd boot with cirros

Minimal initramfs

If you are playing around with qemu, sometimes it is useful to have a kernel and initrd easily available to play with. Cirros provides kernel and initramfs that can be used for this purpose.

This init script here provides a initramfs /init that will do nothing but write the kernel command line and then power the system off. You can adjust it to your needs.

The get-krd script will:

@smoser
smoser / README.md
Last active July 11, 2022 20:29
backdoor-image

backdoor-image

Description

backdoor-image can be used to easily add user with passwordless sudo access to a image or a root filesystem.

Operating on an image requires the 'mount-image-callback' tool from cloud-utils. That can be installed on ubuntu via apt-get install -qy cloud-image-utils.

@smoser
smoser / README.md
Created June 27, 2022 18:42
Simple test of using ginkgo test suite with go

Example ginkgo test

Setup

Setup for this was like:

$ mkdir superdude
$ cd superdude
$ go mod init example.com/superdude
$ go get -u github.com/onsi/ginkgo/v2

$ go get -u "github.com/onsi/gomega"