Skip to content

Instantly share code, notes, and snippets.

View robvanoostenrijk's full-sized avatar

Rob van Oostenrijk robvanoostenrijk

  • United Arab Emirates
View GitHub Profile
@robvanoostenrijk
robvanoostenrijk / README.md
Created August 5, 2024 16:36
Freshtomato Wireguard in AP mode

Firewall Script

modprobe wireguard
ip link add dev wg0 type wireguard
ip address add dev wg0 192.168.14.1/24
wg setconf wg0 /jffs/wg0.conf
ip link set up dev wg0
iptables -A INPUT -i wg0 -j ACCEPT

iptables -t nat -A POSTROUTING -j MASQUERADE

@robvanoostenrijk
robvanoostenrijk / home-assistant-install.sh
Last active February 14, 2024 16:13
Prepare FreeBSD Jail for Home Assistant
#!/bin/sh
# Based on: https://github.com/tprelog/iocage-homeassistant/issues/64
install_packages() {
echo "[i] Installing required packages for Home Assistant"
pkg install -y \
autoconf \
bash \
@robvanoostenrijk
robvanoostenrijk / README.md
Last active February 3, 2024 17:42
Caddy File Browser on nginx
@robvanoostenrijk
robvanoostenrijk / README.md
Last active December 27, 2023 03:33
Email validation git pre-commit hook

Githook pre-commit script to prevent accidental commits using the wrong email address, for example from git global configuration.

@robvanoostenrijk
robvanoostenrijk / 10-efi-kernel.sh
Created December 19, 2023 15:02
Alpine EFI Kernel
#!/bin/ash
set -euo pipefail
readonly HOOK_NAME='efi-kernel'
# Defaults
output_dir='/boot/efi/Alpine'
output_name='linux-{flavor}.efi'
backup_old=yes
skip_flavors=
@robvanoostenrijk
robvanoostenrijk / cloud-init.yaml
Last active April 9, 2023 15:21
docker compose on Google CoS (Container optimized OS)
## template: jinja
#cloud-config
users:
- name: compose
uid: '2000'
groups: docker
write_files:
- path: /home/compose/env
permissions: '0644'
@robvanoostenrijk
robvanoostenrijk / fastest-mirror.sh
Created December 29, 2022 04:51
Determine fastest Alpine mirror
#!/bin/sh
echo "Top 5 Alpine Mirrors:"
for MIRROR in $(curl -s http://dl-cdn.alpinelinux.org/alpine/MIRRORS.txt)
do
MEASUREMENT=$(curl -s --connect-timeout 2 --max-time 5 -w '%{time_total}' -o /dev/null "$MIRROR")
TIME=$(echo "scale=0;(${MEASUREMENT} * 1000)/1" | bc)
echo "${TIME} ${MIRROR}"
done | sort -n | head -n5 | cut -d " " -f2
@robvanoostenrijk
robvanoostenrijk / gen.sh
Created January 27, 2021 12:29
Re-compress Ubuntu Live /casper/initrd
#!/bin/bash
touch initrd.new
cd early
find . -print0 | cpio --null --create --format=newc > ../initrd.new
cd ../early
find . -print0 | cpio --null --create --format=newc >> ../initrd.new
@robvanoostenrijk
robvanoostenrijk / s3_cleanup.sh
Created September 25, 2019 03:41
Remove 0 byte placeholders from AWS S3
#!/bin/bash
BUCKET_NAME="<bucket>"
BUCKET_PATH="<path>/"
PROFILE="<profile>"
### S3 Bulk Delete by File Size ###
aws s3 ls "s3://${BUCKET_NAME}/${BUCKET_PATH}" --profile "${PROFILE}" --recursive | awk -F ' ' '{print $3,$4}' | awk -F ' ' '$1 < 1 {print $2}' | xargs -IP echo '{"Key": "P"}' > delete.txt
# Because bulk delete limit is 1000 per api call.
@robvanoostenrijk
robvanoostenrijk / single_line.sh
Created July 18, 2017 03:31
Java - Generate Self-Signed SSL Certificate
# Generate a self-signed certificate in a Java keystore as a single line command
# Note this generates a SAN certificate for machine.domain, localhost & 127.0.0.1
keytool -genkeypair \
-keyalg RSA \
-keysize 2048 \
-alias "machine.domain" \
-keystore /discovery-service/config/keystore.jks \
-keypass "key-password" \
-storepass "store-password" \
-validity 1095 \