Skip to content

Instantly share code, notes, and snippets.

@dch
Last active July 22, 2025 13:11
Show Gist options
  • Save dch/500099910dda1cf3c8d0fb2a94ec7e37 to your computer and use it in GitHub Desktop.
Save dch/500099910dda1cf3c8d0fb2a94ec7e37 to your computer and use it in GitHub Desktop.
oci-launch-zfs-amd64
# Defined in /home/dch/.config/fish/functions/oci-launch-zfs-amd64.fish @ line 1
function oci-launch-zfs-amd64
set -l USERDATA (mktemp -t oci)
echo '#!/bin/sh -eux
set -o pipefail
touch /var/run/cloud_script_was_here
sed -i"" -E -e "s/.*ssh-/ssh-/" /root/.ssh/authorized_keys
# https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm
curl --fail -H Authorization:\ Bearer\ Oracle -s \
http://169.254.169.254/opc/v2/instance \
| jq . > /var/run/oci.json
mkdir -p /usr/local/etc/pkg/repos
sed -E -e s/quarterly/latest/ /etc/pkg/FreeBSD.conf \
| tee /usr/local/etc/pkg/repos/FreeBSD.conf
pkg upgrade -yr FreeBSD
pkg install -Uyr FreeBSD \
devel/git@tiny \
devel/ninja \
devel/oci-cli \
editors/neovim \
net/mosh \
net/ngrep \
net/rsync \
security/doas \
shells/fish \
sysutils/fd \
sysutils/htop \
sysutils/podman-compose \
sysutils/podman-suite \
sysutils/tmux
textproc/go-yq \
textproc/ripgrep \
' | tee $USERDATA
set -l OCI_CLI_PROFILE eubsd
# FreeBSD 14.3-RELEASE amd64 zfs
set -l IMAGE_OCID 'ocid1.image.oc1..aaaaaaaagbh2t2f5fclk2aabardiahjw344fkps3tru3u2qv64cbipxfckpq'
set -l SUBNET_OCID 'ocid1.subnet.oc1.eu-frankfurt-1.aaaaaaaayaljxmqnp5gqko3kw3iugqfbnerkkp44lz4pbm5rrto4hl75vpza'
set -l TENANCY_OCID 'ocid1.tenancy.oc1..aaaaaaaaerdopn6fhzk47m34bmjhtlpip4uqdw6sgczk2cktam3nbsk4dwla'
set -l COMPARTMENT_OCID $TENANCY_OCID
set -l AVAILABILITY_DOMAIN 'hENZ:EU-FRANKFURT-1-AD-2'
# https://docs.cloud.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/compute/instance/launch.html#cmdoption-shape
set -l SHAPE 'VM.Standard.E5.Flex'
set -l SHAPE_CONFIG '{"ocpus": 4, "memoryInGBs": 24, "baselineOcpuUtilization": "BASELINE_1_8"}'
oci compute instance launch \
--availability-domain $AVAILABILITY_DOMAIN \
--compartment-id $COMPARTMENT_OCID \
--image-id $IMAGE_OCID \
--subnet-id $SUBNET_OCID \
--shape $SHAPE \
--shape-config $SHAPE_CONFIG \
--boot-volume-size-in-gbs 50 \
--ssh-authorized-keys-file ~/.ssh/id_ed25519.pub \
--wait-for-state RUNNING \
--display-name $argv[1] \
--hostname-label $argv[1] \
--freeform-tags $TAGS \
--user-data-file $USERDATA
rm -f $USERDATA
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment