Skip to content

Instantly share code, notes, and snippets.

View qrkourier's full-sized avatar

Kenneth Bingham qrkourier

View GitHub Profile
@qrkourier
qrkourier / matrix_video_fetch.py
Last active November 16, 2024 07:53
download all videos from a Matrix room
#!/usr/bin/env python3
import os
import sys
import argparse
import requests
from urllib.parse import urljoin, quote
import base64
import hashlib
@qrkourier
qrkourier / ziti-open-files.bash
Created October 7, 2024 17:39
Count open files for commands: ziti-edge-tunnel run, ziti controller run, and ziti router run
printf 'Open\tSock\tUnix\tFile\tCommand\n'
for CMD in 'ziti router run' 'ziti controller run' 'ziti-edge-tunnel run'
do
for PID in $(pgrep -f "$CMD")
do
# Capture lsof output for the process
lsof_output=$(sudo lsof -Pnp "$PID" 2>/dev/null)
# Total open files
total_open=$(echo "$lsof_output" | wc -l)
@qrkourier
qrkourier / compose.tproxy.bash
Last active September 25, 2024 19:05
Use a Ziti Router as a Client TPROXY Sidecar and as a Server host
#!/usr/bin/env bash
# this one-shot script demonstrates how to use a ziti router as a transparent proxy sidecar
set -o errexit -o nounset -o pipefail #-o xtrace
function cleanup() {
if ! (( I_AM_ROBOT ))
then
echo "WARNING: destroying docker volumes in 30s; set I_AM_ROBOT=1 to suppress this message" >&2
@qrkourier
qrkourier / zrok.sh
Created August 2, 2024 19:18
wrapper function for zrok --profile
zrok(){
if [[ "$1" =~ ^(-p|--profile)$ ]]
then
shift
local profile="$1"
shift
else
/usr/bin/zrok ${@}
return $?
fi
@qrkourier
qrkourier / ziti-debug.Dockerfile
Created August 2, 2024 18:33
Debug container image with ziti CLI
FROM openziti/ziti-cli AS ziti-cli
FROM ubuntu
COPY --from=ziti-cli /usr/local/bin/ziti /usr/local/bin/ziti
RUN apt-get update && apt-get install --yes \
nano \
vim \
iputils-ping \
@qrkourier
qrkourier / k3s-loop-ula.bash
Last active July 9, 2024 01:40
install single-node, single-stack IPv6 k3s with a random, private IPv6 address on the loopback interface for host-local communication
#!/usr/bin/env bash
_gen_ula(){
# Generate a 40-bit random global ID
local random_id
random_id=$(od -An -N5 -tx1 /dev/urandom | xxd -p | tr -d '\n')
# Construct the ULA address prefix with the generated global ID
local ula_prefix="fd${random_id:0:2}:${random_id:2:4}:${random_id:6:4}"
echo "${ula_prefix}::1"
}
@qrkourier
qrkourier / ziti-downstreams.bash
Last active June 25, 2024 00:53
Build Ziti downstreams (Linux pax, Docker images)
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
exec 3>/dev/null # suppress debug on 3
exec 4>&1; exec 1>/dev/null # stash stdout on 4
declare -a ARTIFACTS=(openziti{-{controller,router},})
@qrkourier
qrkourier / getzet.bash
Last active June 12, 2024 22:22
install a specific version of the ziti-edge-tunnel Linux binary from GitHub
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
get(){
local target=$1
local arch=$2
@qrkourier
qrkourier / docker-hub-tag-multi-platform-latest.bash
Last active May 22, 2024 15:46
Tag the last known good semver as latest
(set -euxopipefail
GOOD_VERSION=1.0.0
for REPO in ziti-{cli,controller,router}; do
docker buildx imagetools create --tag openziti/${REPO}:latest openziti/${REPO}:${GOOD_VERSION}
done
)
@qrkourier
qrkourier / artifactory-unpublish.zsh
Last active May 22, 2024 15:49
Delete a bad version from DEB/RPM Artifactory repos
(
set -euxopipefail
ARTIFACTORY_REPO='zitipax-openziti-(rpm|deb)-stable'
DELETE="--dry-run"
: DELETE="--quiet"
BAD_VERSION=1.1.8
declare -a ARTIFACTS=(openziti{,-controller,-router})