Skip to content

Instantly share code, notes, and snippets.

Avatar

Wido den Hollander wido

View GitHub Profile
@wido
wido / ip-family-traffic-counter.py
Last active Oct 22, 2020
Count IPv4 vs IPv6 traffic flowing over a Linux bridge
View ip-family-traffic-counter.py
#!/usr/bin/python3
#
# I have a Linux machine between my ISP's router and my switch. Two interfaces
# are bridged so I can inspect all traffic coming in and going out.
#
#
# bridge name bridge id STP enabled interfaces
# br1 8000.8eb20d8d9b94 no enp0s20f0
# enp0s20f1
#
@wido
wido / ceph-osd-compact.sh
Created Mar 11, 2020
Compact all Ceph OSDs on a host
View ceph-osd-compact.sh
#!/bin/bash
#
# Compact all OSDs on a host while they are stopped/offline
#
# Author: Wido den Hollander <wido@denhollander.io>
#
df|grep "/var/lib/ceph/osd"|awk '{print $6}'|cut -d '-' -f 2|sort -n|xargs -n 1 -P 10 -I OSD ceph-kvstore-tool bluestore-kv /var/lib/ceph/osd/ceph-OSD compact
View powerdns-lua-records.txt
# These are just some LUA records I was testing with for PowerDNS
#
# Author: Wido den Hollander <wido@denhollander.io>
A "ifportup(25, {'185.66.250.201', '185.87.186.222'})"
A "ifportup(25, {'185.66.250.201', '185.87.186.222'}, {selector='all'})"
AAAA "ifportup(25, {'2a00:f10:121:a00:4f8:84ff:fe00:1846', '2a00:f10:400:2:488:56ff:fe00:74f'})"
AAAA "ifportup(25, {'2a00:f10:121:a00:4f8:84ff:fe00:1846', '2a00:f10:400:2:488:56ff:fe00:74f'}, {selector='all'})"
@wido
wido / hue-curl.sh
Created Jan 6, 2020
Philips Hue control with cURL
View hue-curl.sh
#!/bin/bash
#
# Simple script to change lights on Philips Hue using cURL
#
# Source: http://hkionline.net/posts/using-phillips-hue-from-the-command-line
#
# Author: Wido den Hollander <wido@denhollander.io>
#
# YES! Philips Hue also talks IPv6! :-)
@wido
wido / ip6-eui64-address.py
Created Nov 13, 2019
Calculate RFC482 (SLAAC) IPv6 address a host will obtain
View ip6-eui64-address.py
#!/usr/bin/env python3
#
# Calculate the IPv6 address a host will obtain per RFC4862
#
# Usage: ./ip6-eui64-address.py --prefix 2001:db8::/64 52:54:00:59:c2:b3
#
# Author: Wido den Hollander <wido@denhollander.io>
#
import argparse
import ipaddress
@wido
wido / ceph-failed-osd-start.sh
Created Nov 11, 2019
Start all failed Ceph OSDs
View ceph-failed-osd-start.sh
#!/bin/sh
#
# Start all OSDs on a host which didnt start for some reason
#
# Author: Wido den Hollander <wido@denhollander.io>
#
df -h|grep ceph|grep osd|awk '{print $6}'|cut -d '-' -f 2|sort -n|xargs -n 1 -I OSD systemctl reset-failed ceph-osd@OSD
df -h|grep ceph|grep osd|awk '{print $6}'|cut -d '-' -f 2|sort -n|xargs -n 1 -I OSD systemctl start ceph-osd@OSD
@wido
wido / py3-random.sh
Created Oct 22, 2019
Python 3 one-liner generate random string
View py3-random.sh
python3 -c "import random; import string; print(''.join(random.choice(string.ascii_lowercase) for i in range(10)))"
@wido
wido / factory_mode.sh
Created Oct 4, 2019
Tesla MCU factory mode
View factory_mode.sh
#!/bin/bash
#
# Put Tesla MCU1 in factory mode
#
# Call over diagnostics port with seceth enabled
#
# Reboot MCU afterwards
#
VALUE=true
@wido
wido / reverse-ssh.sh
Created Oct 2, 2019
Reverse SSH tunnel
View reverse-ssh.sh
#!/bin/bash
## To use: `ssh -p 33333 <name>@localhost` from server
server="tesla@tesla.myserver.com"
port=$(cut -c 13-17 < /var/etc/vin)
localHost="localhost"
if [ "$server" == "tesla@yourserver.com" ]; then
echo "Script not yet setup, quitting"
@wido
wido / mkteslaemmcimg.sh
Last active Sep 11, 2020
Tesla Model S/X MCU1 eMMC image creator
View mkteslaemmcimg.sh
#!/bin/bash
#
# Create a 8GB eMMC image for Tesla Model S/X MCU1
#
# Example usage: ./mkteslaemmcimg.sh ./vinXXXXX.img ./develop-2019.20.2.1-16-5659e07dfd.img
#
set -e
FIRMWARE=$2
IMAGE=$1
You can’t perform that action at this time.