Skip to content

Instantly share code, notes, and snippets.

View wido's full-sized avatar

Wido den Hollander wido

View GitHub Profile
@wido
wido / dnskey_to_dsrecord.py
Created July 18, 2016 11:58
Calculate DS record from DNSKEY with Python 3
"""
Generate a DNSSEC DS record based on the incoming DNSKEY record
The DNSKEY can be found using for example 'dig':
$ dig DNSKEY secure.widodh.nl
The output can then be parsed with the following code to generate a DS record
for in the parent DNS zone
@wido
wido / modifyvxlan.sh
Created June 7, 2021 13:31
BGP+EVPN+VXLAN with Apache CloudStack
#!/usr/bin/env bash
#
# Use BGP+EVPN for VXLAN with CloudStack instead of Multicast
#
# Place this file on all KVM hypervisors at /usr/share/modifyvxlan.sh
#
# More information about BGP and EVPN with FRR: https://vincent.bernat.ch/en/blog/2017-vxlan-bgp-evpn
#
DSTPORT=4789
@wido
wido / mkteslaemmcimg.sh
Last active November 2, 2023 03:23
Tesla Model S/X MCU1 eMMC image creator
#!/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
@wido
wido / factory_mode.sh
Created October 4, 2019 09:28
Tesla MCU factory mode
#!/bin/bash
#
# Put Tesla MCU1 in factory mode
#
# Call over diagnostics port with seceth enabled
#
# Reboot MCU afterwards
#
VALUE=true
@wido
wido / nginx-radosgw.conf
Created August 26, 2015 09:42
Nginx proxy for Ceph RADOS Gateway with Civetweb
server {
listen 80;
listen [::]:80;
server_name localhost;
client_max_body_size 0;
proxy_buffering off;
proxy_set_header Host $host;
@wido
wido / iptables-proxy.sh
Created November 6, 2018 17:50
iptables TCP and UDP proxy
#!/bin/bash
#
# Author: Wido den Hollander <wido@widodh.nl>
#
# Proxy all TCP and UDP IPv4 traffic from 192.168.100.230 to 10.0.100.50
#
# This can be used as a (temporary) proxy when you want to renumber a machine and want
# to make sure it's still available on it's old address
#
@wido
wido / ceph-bluestore-db-size.sh
Created January 30, 2018 09:12
Ceph OSD BlueStore database size
#!/bin/bash
# For each running OSD query the BlueStore DB size and entries and calculate avg size per entry
#
# Author: Wido den Hollander <wido@widodh.nl>
#
for OSD_ID in $(find /var/run/ceph -name 'ceph-osd.*.asok' -type s -printf "%f\n"|cut -d '.' -f 2); do
DB_USED_BYTES=$(ceph daemon osd.$OSD_ID perf dump|jq '.bluefs.db_used_bytes')
BLUESTORE_ONODES=$(ceph daemon osd.$OSD_ID perf dump|jq '.bluestore.bluestore_onodes')
echo "osd.$OSD_ID: db_used_bytes=$DB_USED_BYTES bluestore_onodes=$BLUESTORE_ONODES db_entry_size=$(($DB_USED_BYTES / BLUESTORE_ONODES))"
@wido
wido / ceph-udev-disk-scheduler.rules
Last active July 13, 2023 14:17
ceph-udev-disk-scheduler.rules
# udev rule to set disk schedulers for Ceph
# For spinning disks we want the CFQ scheduler so that we can set
# priorities on client and recovery I/O threads
#
# Author: Wido den Hollander <wido@42on.com>
# Date: July 2015
# Use deadline for SSDs
ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"
@wido
wido / hue-curl.sh
Created January 6, 2020 20:11
Philips Hue control with cURL
#!/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 / random-ipv6-addr.py
Last active May 31, 2023 18:43
Generate a random IPv6 address
#!/usr/bin/env python3
"""
Generate a random IPv6 address for a specified subnet
"""
from random import seed, getrandbits
from ipaddress import IPv6Network, IPv6Address
subnet = '2001:db8:100::/64'