Skip to content

Instantly share code, notes, and snippets.

@agners
agners / prune-corrupted-layer-metadata.sh
Last active November 30, 2023 21:18
Prune corrupted Docker layers in overlayfs2 storage
#!/bin/sh
# (c) 2023 Stefan Agner
# This scripts attempts to clear corrupted Docker overlay2 storage metadata
# which can be left over after a power failure.
# See also: https://github.com/moby/moby/issues/42964
#
# Typically the error message when attempting to pull the image for which
# corrupted layers are in the storage looks like:
# failed to register layer: error creating overlay mount to /mnt/data/docker/overlay2/6ee02298ee75a4f96e77f90551673cb700f29867f9ad1c4e20b8c816bfcf0735/merged: too many levels of symbolic links
@agners
agners / CommissioningStage.h
Created January 11, 2024 13:05
enum CommissioningStage with numeric values
// enum CommissioningStage with numeric values
// from
// https://github.com/project-chip/connectedhomeip/blob/v1.2.0.1/src/controller/CommissioningDelegate.h
enum CommissioningStage : uint8_t
{
kError = 0,
kSecurePairing = 1, ///< Establish a PASE session with the device
kReadCommissioningInfo = 2, ///< Query General Commissioning Attributes, Network Features and Time Synchronization Cluster
kReadCommissioningInfo2 = 3, ///< Query SupportsConcurrentConnection, ICD state, check for matching fabric
@agners
agners / tlv-parser.py
Last active December 24, 2024 15:02
Thread credentials dataset TLV parser
#!/bin/env python3
import binascii
import sys
MESHCOP_TLV_TYPE = {
"CHANNEL": 0,
"PANID": 1,
"EXTPANID": 2,
"NETWORKNAME": 3,
#!/usr/bin/env python3
import argparse
import asyncio
import logging
from typing import Any, Optional, cast
from zeroconf import IPVersion, ServiceInfo, ServiceStateChange, Zeroconf, ServiceListener
from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo, AsyncZeroconf
@agners
agners / securetar-extract.py
Created January 23, 2025 20:06
Extract SecureTar encrypted tar.gz files
#!/usr/bin/env python3
import gzip
import io
import os
import tarfile
from pathlib import Path
import hashlib
from securetar import (
SECURETAR_MAGIC,
SecureTarFile,