Skip to content

Instantly share code, notes, and snippets.

View dougvj's full-sized avatar

Doug Johnson dougvj

View GitHub Profile
@dougvj
dougvj / 0001-overlayfs-disable-in-use-check.patch
Last active November 9, 2022 22:17
Patch to disable overlay in-use check
From e3f1af9e14f8311fb40f09057e5578e7121b346f Mon Sep 17 00:00:00 2001
From: Doug Johnson <[email protected]>
Date: Tue, 2 Jul 2019 03:29:31 -0600
Subject: [PATCH] overlayfs: disable in-use check
---
fs/overlayfs/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
@dougvj
dougvj / get_addr_string.c
Created April 25, 2022 08:06
Getting IPv4 or IPv6 address string from IPv6 sockaddr
// This function returns the string representation of an IP address in an IPv6
// stack. Connections from IPv4 addresses are mapped to IPv6 addresses under
// the ::FFFF prefix. This checks for that mapping and if it exists returns the
// conversion as though the addresss were a native IPv4 Address.
//
// addr is a pointer to a valid sockaddr_in6 struct.
//
// dest must be a buffer of at least size INET6_ADDRSTRLEN
//
// The return is a pointer to dest, otherwise if NULL then errno is set, see
@dougvj
dougvj / mysql-to-postgres.sh
Last active February 6, 2024 14:19
Mysql to Postgres SQL file conversion
# Adapted from github comment:
# https://github.com/dimitri/pgloader/issues/782#issuecomment-1136067634
if [ -z "$3" ]; then
echo "Usage: $0 <db name> <mysql dump> <psql dump output>"
echo "Requirements: docker"
exit 1
fi
if ! command -v docker &> /dev/null
@dougvj
dougvj / firewall.sh
Last active February 9, 2024 05:13
Firewall example for a host that acts as a router and hosts both public and private services on docker
set -e
WAN_IF=br0.2
LAN_IF=br0
WAN_IP=$(ip -4 -o addr show dev $WAN_IF | awk '{print $4}' | cut -d/ -f1)
echo "WAN IP: $WAN_IP"
# Block incoming connection on WAN except port 22
iptables -F INPUT
iptables -A INPUT -i $WAN_IF -p tcp --dport 22 -j ACCEPT
# Allow 80 and 443 (currently via docker)
#iptables -A INPUT -i $WAN_IF -p tcp --dport 80 -j ACCEPT