Skip to content

Instantly share code, notes, and snippets.

View wido's full-sized avatar

Wido den Hollander wido

View GitHub Profile
@wido
wido / mac2eui64.py
Created December 21, 2016 11:56
Python 3 48-bit MAC to EUI-64 IPv6
#!/usr/bin/env python3
import ipaddress
import re
def mac2eui64(mac, prefix=None):
'''
Convert a MAC address to a EUI64 address
or, with prefix provided, a full IPv6 address
'''
@wido
wido / remove-old-bucket-indexes.sh
Created November 13, 2018 10:43
Remove old RADOS Gateway Bucket Indexes from Ceph
#!/bin/bash
for bucket in $(radosgw-admin bucket list | jq -r .[]); do
bucket_id=$(radosgw-admin metadata get bucket:${bucket} | jq -r .data.bucket.bucket_id)
marker=$(radosgw-admin metadata get bucket:${bucket} | jq -r .data.bucket.marker)
for instance in $(radosgw-admin metadata list bucket.instance | jq -r .[] | grep "^${bucket}:" | grep -v ${bucket_id} | grep -v ${marker}| cut -f2 -d':'); do
echo "${bucket}: ${instance}"
radosgw-admin bi purge --bucket=${bucket} --bucket-id=${instance}
radosgw-admin metadata rm bucket.instance:${bucket}:${instance}
done
@wido
wido / radosgw-gc-bucket-indexes.sh
Created November 15, 2018 12:38
Ceph RADOS Gateway bucket index garbage collection
#!/bin/bash
#
# Find orphaned bucket index objects in the RGW bucket index pool
# and clean them up if they do not belong to a bucket
#
# Author: Wido den Hollander <wido@42on.com>
#
INDEX_POOL=$1
@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 / make-ixpe-uefi-iso.sh
Created August 31, 2022 07:48
Make iPXE UEFI Boot ISO
#!/bin/bash
#
# Put this script in the source directory of the ipxe project
#
# The output ipxe-uefi.iso can be used to boot a server with iPXE
#
cd `dirname $0`
cd src
make bin-x86_64-efi/ipxe.efi
cd ..
@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 / mkteslaemmcimg.sh
Last active February 4, 2025 13:28
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 / 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 / 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 / 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! :-)