oci-launch-arm64.fish
· 2.2 KiB · Fish
Raw
function oci-launch-zfs-arm64
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 arm64 zfs
set -l IMAGE_OCID 'ocid1.image.oc1..aaaaaaaakcp6qvubkpqzprnfca6hpgencllptvuu5cw7tr6thnublyj6vcla'
set -l SUBNET_OCID 'ocid1.subnet.oc1....'
set -l TENANCY_OCID 'ocid1.tenancy.oc1.....'
set -l COMPARTMENT_OCID $TENANCY_OCID
set -l AVAILABILITY_DOMAIN 'hENZ:EU-FRANKFURT-1-AD-3'
# 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.A1.Flex'
set -l SHAPE_CONFIG '{"memoryInGBs": 6, "ocpus": 2}'
set -l TAGS '{"GIT_REPO":"https://git.sr.ht/~dch/src", "GIT_REF":"13.2-oci", "IMG_ARCH":"arm64", "IMG_NAME": "FreeBSD-13.2-RELEASE-20230411-1455-99eb544-amd64-amd64.img"}'
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
| 1 | function oci-launch-zfs-arm64 |
| 2 | set -l USERDATA (mktemp -t oci) |
| 3 | echo '#!/bin/sh -eux |
| 4 | set -o pipefail |
| 5 | touch /var/run/cloud_script_was_here |
| 6 | sed -i"" -E -e "s/.*ssh-/ssh-/" /root/.ssh/authorized_keys |
| 7 | # https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/gettingmetadata.htm |
| 8 | curl --fail -H Authorization:\ Bearer\ Oracle -s \ |
| 9 | http://169.254.169.254/opc/v2/instance \ |
| 10 | | jq . > /var/run/oci.json |
| 11 | mkdir -p /usr/local/etc/pkg/repos |
| 12 | sed -E -e s/quarterly/latest/ /etc/pkg/FreeBSD.conf \ |
| 13 | | tee /usr/local/etc/pkg/repos/FreeBSD.conf |
| 14 | pkg upgrade -yr FreeBSD |
| 15 | pkg install -Uyr FreeBSD \ |
| 16 | devel/git@tiny \ |
| 17 | devel/ninja \ |
| 18 | devel/oci-cli \ |
| 19 | editors/neovim \ |
| 20 | net/mosh \ |
| 21 | net/ngrep \ |
| 22 | net/rsync \ |
| 23 | security/doas \ |
| 24 | shells/fish \ |
| 25 | sysutils/fd \ |
| 26 | sysutils/htop \ |
| 27 | sysutils/podman-compose \ |
| 28 | sysutils/podman-suite \ |
| 29 | sysutils/tmux |
| 30 | textproc/go-yq \ |
| 31 | textproc/ripgrep \ |
| 32 | ' | tee $USERDATA |
| 33 | set -l OCI_CLI_PROFILE eubsd |
| 34 | # FreeBSD 14.3-RELEASE arm64 zfs |
| 35 | set -l IMAGE_OCID 'ocid1.image.oc1..aaaaaaaakcp6qvubkpqzprnfca6hpgencllptvuu5cw7tr6thnublyj6vcla' |
| 36 | set -l SUBNET_OCID 'ocid1.subnet.oc1....' |
| 37 | set -l TENANCY_OCID 'ocid1.tenancy.oc1.....' |
| 38 | set -l COMPARTMENT_OCID $TENANCY_OCID |
| 39 | set -l AVAILABILITY_DOMAIN 'hENZ:EU-FRANKFURT-1-AD-3' |
| 40 | |
| 41 | # https://docs.cloud.oracle.com/en-us/iaas/tools/oci-cli/latest/oci_cli_docs/cmdref/compute/instance/launch.html#cmdoption-shape |
| 42 | set -l SHAPE 'VM.Standard.A1.Flex' |
| 43 | set -l SHAPE_CONFIG '{"memoryInGBs": 6, "ocpus": 2}' |
| 44 | set -l TAGS '{"GIT_REPO":"https://git.sr.ht/~dch/src", "GIT_REF":"13.2-oci", "IMG_ARCH":"arm64", "IMG_NAME": "FreeBSD-13.2-RELEASE-20230411-1455-99eb544-amd64-amd64.img"}' |
| 45 | oci compute instance launch \ |
| 46 | --availability-domain $AVAILABILITY_DOMAIN \ |
| 47 | --compartment-id $COMPARTMENT_OCID \ |
| 48 | --image-id $IMAGE_OCID \ |
| 49 | --subnet-id $SUBNET_OCID \ |
| 50 | --shape $SHAPE \ |
| 51 | --shape-config $SHAPE_CONFIG \ |
| 52 | --boot-volume-size-in-gbs 50 \ |
| 53 | --ssh-authorized-keys-file ~/.ssh/id_ed25519.pub \ |
| 54 | --wait-for-state RUNNING \ |
| 55 | --display-name $argv[1] \ |
| 56 | --hostname-label $argv[1] \ |
| 57 | --freeform-tags $TAGS \ |
| 58 | --user-data-file $USERDATA |
| 59 | rm -f $USERDATA |
| 60 | end |