Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔
Trying to figure out how to look up comments I've left

Pat Maddox patmaddox

🤔
Trying to figure out how to look up comments I've left
View GitHub Profile
View port_wrapper.sh
# Start the program in the background
exec "$@" &
pid1=$!
# Silence warnings from here on
exec >/dev/null 2>&1
# Read from stdin in the background and
# kill running program when stdin closes
exec 0<&0 $(
@patmaddox
patmaddox / snap_and_sync.sh
Created Nov 28, 2022
sanoid syncoid script
View snap_and_sync.sh
#!/bin/sh
set -e
sudo sanoid --cron --quiet
sudo syncoid --quiet -r --no-privilege-elevation --no-sync-snap --sendoptions="w" --recvoptions="u" --sshkey=/usr/home/patmaddox/.ssh/nas-rsyncnet zdata/crypt/istudo nas-user@myhost.rsync.net:zsync/snaps/istudo
@patmaddox
patmaddox / .cirrus.yml
Last active Oct 31, 2022
Cirrus CI build/test/deploy config for Elixir on FreeBSD using ex_freebsd
View .cirrus.yml
gcp_credentials: ENCRYPTED[!...!]
# custom-built instance with some packages pre-installed to save time
# otherwise use:
# freebsd_instance:
# image_family: freebsd-13-0
# and install your packages
gce_instance:
image_project: ratio-ops
image_family: ratio-freebsd-13-1-ci
@patmaddox
patmaddox / make_freebsd.sh
Last active Oct 20, 2022
script to build FreeBSD disk for cloud
View make_freebsd.sh
#!/bin/sh
set -e
# Adapted from https://www.daemonology.net/blog/2019-02-16-FreeBSD-ZFS-AMIs-now-available.html
if [ ! $# -eq 2 ]; then
echo "Usage: configure.sh <cloud> <disk>"
echo " cloud: aws|gcp"
echo " disk: e.g. da1, nda1"
exit 1
@patmaddox
patmaddox / make_freebsd.sh
Created Aug 25, 2022
FreeBSD zfs-on-root cloud disk config
View make_freebsd.sh
#!/bin/sh
# Adapted from https://www.daemonology.net/blog/2019-02-16-FreeBSD-ZFS-AMIs-now-available.html
if [ ! $# -eq 2 ]; then
echo "Usage: configure.sh <cloud> <disk>"
echo " cloud: aws|gcp"
echo " disk: e.g. da1, nda1"
exit 1
fi
@patmaddox
patmaddox / pf.conf
Last active Nov 30, 2022
generic pf.conf w/ nat
View pf.conf
ext_if="ena0"
ts_if="tailscale0"
set skip on lo
scrub in
# permissive NAT allows jail bridge and wireguard tunnels
nat on $ext_if inet from !($ext_if) -> ($ext_if:0)
block in
@patmaddox
patmaddox / mk_image.sh
Last active Sep 25, 2022
FreeBSD ZFS-on-Root (GCP)
View mk_image.sh
#!/bin/sh
set -e
set -x
# Adapted from https://www.daemonology.net/blog/2019-02-16-FreeBSD-ZFS-AMIs-now-available.html
# Note: You need to run this on an instance with read/write access to Google Compute
# Alternatively, you can run the gcloud commands from somewhere with privileges
disk=da1
@patmaddox
patmaddox / gist:52f7b185d4b4a57449bd56779aac3c86
Created Jul 30, 2022
fetch dependencies for a local package file
View gist:52f7b185d4b4a57449bd56779aac3c86
pkg fetch -U -d -o ~/my_new_packages \
$(pkg info -R --raw-format json -F release_test-0.1.0.pkg | jq -r '.["deps"] | keys | join(" ")')
View .cirrus.yml
gce_instance:
image_project: ratio-ops
image_name: ratio-freebsd-13-1-ci-1657673300
platform: freebsd
zone: us-west1-a
type: n1-standard-8
@patmaddox
patmaddox / zfs_ami.sh
Last active Jun 15, 2022
Configure FreeBSD AWS ZFS ZMI
View zfs_ami.sh
#!/bin/sh
# adapted from https://www.daemonology.net/blog/2019-02-16-FreeBSD-ZFS-AMIs-now-available.html
mdconfig -a -t swap -s 3G -u 2
newfs /dev/md2
mkdir /mdisk
mount /dev/md2 /mdisk
tar -czf /mdisk/base.txz --exclude .snap -C /mnt .
umount /mnt