Skip to content

Instantly share code, notes, and snippets.

View Roadmaster's full-sized avatar

Roadmaster Roadmaster

  • Montreal, QC, Canada
  • 15:17 (UTC -04:00)
View GitHub Profile
@Roadmaster
Roadmaster / gist:c00f8aa205ccbe003f6fd24549effe02
Created October 5, 2017 18:52
snap building scripts and yamls
namespace=${1:-tomechangosubanana}
name=${2:-1}
rev=${3:-2}
cat > snapcraft.yaml <<EOF
name: hello-$namespace-$name
version: $rev
summary: say hello
confinement: strict
grade: stable
@Roadmaster
Roadmaster / aptcaching.sh
Last active February 4, 2024 00:20
Create an lxc profile enabling use of an apt cache
#!/bin/bash
# Create lxc profile with apt caching
# Requires installing apt-cacher-ng to 10.0.4.1 (your host)
# Could be improved by making the actual apt cache host tunable
# Then use like:
# lxc launch -p default -p aptcache ubuntu:16.04 my-cached-container
NAME=aptcache
CACHE_IP=$(ip addr list lxdbr0 | grep -Po 'inet \K[\d.]+')
if ! ping -c 1 "$CACHE_IP" -w 1 >/dev/null 2>&1; then
@Roadmaster
Roadmaster / google-chrome-lxc.sh
Created October 18, 2017 21:16
Set up an lxc container with google chrome so it runs confined but displays on localhost.
#!/bin/bash
# Set up an lxc container with google chrome so it runs confined but displayed on the
# localhost.
# Adapted from https://blog.simos.info/how-to-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/
# Assume setguid/setid for root is properly setup
# root:1000:1
# Assume aptcache profile exists, see https://gist.github.com/Roadmaster/754110f3f49fef19ec89ae29f29edd11
LXC_NAME=chrome-container
env PROMETHEUS=/usr/bin/prometheus
env CONFIG=/etc/prometheus/prometheus.yml
env USER=prometheus
env GROUP=prometheus
env DEFAULTS=/etc/default/prometheus
env RUNDIR=/var/run/prometheus
env PID_FILE=/var/run/prometheus/prometheus.pid
pre-start script
[ -e $DEFAULTS ] && . $DEFAULTS
@Roadmaster
Roadmaster / snap-lxc.sh
Created October 27, 2017 21:21
snap-lxc.sh
#!/bin/bash
# Create lxc profile that allows using snaps in the container
NAME=snap
lxc profile create $NAME &> /dev/null || true
cat << EOF | lxc profile edit $NAME
name: $NAME
description: Set up snaposity
config:
security.nesting: "true"
user.vendor-data: |
@Roadmaster
Roadmaster / gist:6a4814ee253d055475e4b2cc64e688e1
Created January 31, 2018 23:32
Fix for kuard's build.sh script because npm/node/etc is suck a brainfuckery
diff --git a/build/build.sh b/build/build.sh
index 485c6ca..df82658 100755
--- a/build/build.sh
+++ b/build/build.sh
@@ -45,6 +45,8 @@ export GOARCH="${ARCH}"
(
cd client
npm install --loglevel=error
+ chmod 755 ./node_modules/webpack/bin/webpack.js
+
https://discuss.linuxcontainers.org/t/lxd-netplan-static-ips-in-same-subnet-how-to/1074/7
$ lxc profile show lan
config: {}
description: ""
devices:
br0:
nictype: bridged
parent: br0
type: nic
@Roadmaster
Roadmaster / gist:08c44bf715feb80017720317bbdfd42f
Created October 5, 2018 20:05
how to ssh into local lxd containers
# snippet for .ssh/config
Host *.lxd
#User ubuntu
#StrictHostKeyChecking no
#UserKnownHostsFile /dev/null
ProxyCommand nc $(lxc list --format csv -c s4 $(echo %h | sed "s/\.lxd//g") %h | python3 -c "import csv,sys; print([ip for ip in [e.split('\n') for s,e in list(csv.reader(sys.stdin)) if s == 'RUNNING'][0] if
'eth' in ip][0].split(' ')[0])") %p
@Roadmaster
Roadmaster / s
Last active June 12, 2020 13:39
ssh sig check
The sender needs to do this:
Create a file /tmp/attest with something like "blah", then sign it with:
openssl dgst -sha512 -sign ~/.ssh/id_rsa /tmp/attest > /tmp/attest.sig
then base64-encode the sig and the attest file:
base64 /tmp/attest >/tmp/attest.b64
base64 /tmp/attest.sig >/tmp/attest.sig.b64
@Roadmaster
Roadmaster / samechars.py
Created April 4, 2019 15:36
detect many characters in a row - 3 approaches
#!/usr/bin/python3
import re
import timeit
def toomanyinarow1(term, maxreps):
cnt = 1
prev = None
for char in term:
if char == prev: