Skip to content

Instantly share code, notes, and snippets.

View anonymouse64's full-sized avatar
🍎
Think Different

Ian Johnson anonymouse64

🍎
Think Different
View GitHub Profile
@anonymouse64
anonymouse64 / snap-decls.sh
Last active November 4, 2021 19:41
snap debug base-declaration jq slot allow-installation examples
#!/bin/bash
# NOTE: the following commands are rather simplistic and ignore the logic around deny-installation, which should also hypothetically affect these lists, but really taking that into account requires more logic than I'm willing to put into a jq command
echo ">>> GADGET SNAP SLOT INTERFACES <<<"
echo
# Get all slots that can be used on a gadget snap specifically
snap debug base-declaration | \
head -n -1 | \
@anonymouse64
anonymouse64 / stream-gcloud-serial-console-for-snapd.sh
Last active September 2, 2021 06:31
stream gce serial console output continuously
#!/bin/bash -e
INSTANCE="$1"
if [ -z "$INSTANCE" ]; then
echo "first argument must be the GCE instance"
exit 1
fi
next=0
@anonymouse64
anonymouse64 / snap-debug-info.sh
Last active March 23, 2022 13:00
[DEPRECATED] Basic debugging information for snap devices
#!/bin/bash
##############################################################################
##############################################################################
#
# THIS IS DEPRECATED - PLEASE USE THE NEW HOME FOR THIS SCRIPT:
# https://github.com/snapcore/snapd/blob/master/debug-tools/snap-debug-info.sh
#
##############################################################################
##############################################################################
@anonymouse64
anonymouse64 / do-release.sh
Created August 28, 2021 02:16
Release snapd prototype automated script
#!/bin/bash -e
# TODO: programatically figure these out
PREV_VERSION=2.51.6
NEW_VERSION=2.51.7
MAJOR_VERSION=2.51
IS_MINOR=1
RELEASE_BRANCH=release/$MAJOR_VERSION
@anonymouse64
anonymouse64 / busctl-example-systemd.sh
Created April 15, 2021 23:03
Get systemd unit property's from busctl
# Get the object path for a service with the "easy name"
sudo busctl --verbose --system call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager GetUnit s snap.docker.dockerd.service
# get the ActiveState d-bus property of the Unit object
sudo busctl --verbose --system get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/snap_2edocker_2edockerd_2eservice org.freedesktop.systemd1.Unit ActiveState
# get the OOMScoreAdjust d-bus property of the Service object
sudo busctl --verbose --system get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/snap_2edocker_2edockerd_2eservice org.freedesktop.systemd1.Service OOMScoreAdjust
@anonymouse64
anonymouse64 / leaf-account-key-testkeys-assertion.go
Last active February 12, 2021 14:59
Generate a leaf, non-self-signed account-key assertion with associated private key for use with snapd
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2021 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
@anonymouse64
anonymouse64 / self-signed-root-account-key-assertion.go
Created February 11, 2021 14:42
Generate a self signed root account-key assertion for snapd
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2021 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
@anonymouse64
anonymouse64 / kernel_cmdline.go
Created November 18, 2020 02:30
pointless overly complicated and overly engineered kernel cmdline parsing utilities using SplitFunc supporting quotes (but not nested quotes!) in Go
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2020 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
@anonymouse64
anonymouse64 / sign-system-user-assertion.sh
Created September 25, 2020 10:28
simplistic shell script for creating system-user assertions for use with snapd/ubuntu core
#!/bin/bash
set -e
# first argument is the name of the key to sign the assertion with
if [ "$#" != 1 ]; then
echo "usage: ./sign-system-user-assertion <key-name>"
exit 1
fi
@anonymouse64
anonymouse64 / hashmap.go
Created July 31, 2020 14:26
Hash a map and a bool in Go deterministically
func hashMapAndBool(b bool, m map[string]string) string {
h := sha256.New()
// hashing maps is not deterministic because it is not sorted, so we have
// to manually hash each key value into another hash after sorting
// first we hash the string representation of the bool
h.Write([]byte(fmt.Sprintf("%v", b)))
keys := make([]string, len(m))
i := 0