Skip to content

Commit

Permalink
Manual cloud-init install
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmilk committed Jul 19, 2024
1 parent 8fa4fd6 commit aaf723c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/scripts/qemu-1-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@

set -eu

# remove unneeded things
sudo apt-get remove google-chrome-stable snapd

# install needed packages
sudo apt-get update
sudo apt-get install axel cloud-image-utils daemonize guestfs-tools \
virt-manager linux-modules-extra-`uname -r`

sudo fstrim -a
12 changes: 6 additions & 6 deletions .github/workflows/scripts/qemu-2-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ RELEASE="$1"
# need some old image:
case ${1:0:2} in
13)
FILE="/amd64-freebsd-13.3-STABLE.qcow2.zst"
FILE="amd64-freebsd-13.3-STABLE.qcow2.zst"
;;
14)
FILE="/amd64-freebsd-14.1-STABLE.qcow2.zst"
FILE="amd64-freebsd-14.1-STABLE.qcow2.zst"
;;
15)
FILE="/amd64-freebsd-15.0-CURRENT.qcow2.zst"
FILE="amd64-freebsd-15.0-CURRENT.qcow2.zst"
;;
*)
echo "Wrong FreeBSD Version"
exit 111
;;
esac
REL="2024-06-23"
REL="v2024-07-16"
URL="https://github.com/mcmilk/openzfs-freebsd-images/releases/download/$REL/$FILE"

IMG="/mnt/cloudimg.qcow2"
Expand All @@ -44,8 +44,8 @@ qemu-img convert -q -f qcow2 -O qcow2 -c \
-o compression_type=zstd,preallocation=off $IMG $DISK
rm -f $IMG

echo "Resizing image to 40GiB ..."
qemu-img resize -q $DISK 40G
echo "Resizing image to 16GiB ..."
qemu-img resize -q $DISK 16G

# generate ssh keys
rm -f ~/.ssh/id_ed25519
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/scripts/qemu-3-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ function build {

if [[ $NAME == *-RELEASE ]]; then
BASE_URL="https://download.freebsd.org/releases/amd64/$NAME"
CLOUDINIT="cloud-init"
else
BASE_URL="https://download.freebsd.org/snapshots/amd64/$NAME"
CLOUDINIT="py311-cloud-init"
fi

MNT="/mnt/$VERSION"
Expand Down Expand Up @@ -47,27 +45,31 @@ function build {
axel -q ${BASE_URL}/base.txz -o base-$VERSION.txz
axel -q ${BASE_URL}/kernel.txz -o kernel-$VERSION.txz
axel -q ${BASE_URL}/src.txz -o src-$VERSION.txz
axel -q "https://github.com/canonical/cloud-init/archive/main.tar.gz" \
-o cloud-init.tar.gz

echo "Extracting base.txz, kernel.txz and src.txz ..."
cat base-$VERSION.txz | tar xf - -C $MNT
cat kernel-$VERSION.txz | tar xf - -C $MNT
cat src-$VERSION.txz | tar xf - -C $MNT
cat cloud-init.tar.gz | tar xf - -C $MNT/tmp

echo "Installing cloud-init ..."
echo "
export ASSUME_ALWAYS_YES=YES
pkg install bash ca_root_nss git npm qemu-guest-agent
pkg install $CLOUDINIT
pkg install bash ca_root_nss git qemu-guest-agent python3
chsh -s /usr/local/bin/bash root
pw mod user root -w no
touch /etc/rc.conf
cd /tmp/cloud-init-*
./tools/build-on-freebsd
cd /tmp
rm -rf cloud-init-*
" > $MNT/tmp/cloudify.sh

echo "pw mod user root -w no" >> $MNT/tmp/cloudify.sh
chmod +x $MNT/tmp/cloudify.sh

cp /etc/resolv.conf $MNT/etc/resolv.conf
mount -t devfs devfs $MNT/dev
chmod +x $MNT/tmp/cloudify.sh
chroot $MNT /tmp/cloudify.sh
umount $MNT/dev
rm $MNT/tmp/cloudify.sh
Expand Down

0 comments on commit aaf723c

Please sign in to comment.