1#!/bin/bash 2# 3# For "official" images on https://www.haiku-os.org/guides/virtualizing/google 4# 5# Making a new Google Compute Engine image 6# * Create a raw disk 4GiB image dd if=/dev/zero of=disk.raw bs=1M count=4096 7# * Boot VM (qemu-system-x86_64 -cdrom (haiku-release.iso) -hda disk.raw -boot d --enable-kvm -m 4G 8# * Partition new disk 9# * 32 MiB EFI System Data. FAT32 named "ESP" 10# * Rest of disk, Haiku, BFS, named "Haiku" 11# * Install Haiku to it new disk 12# * Allow installer to Reboot, *boot again from CD* 13# * Setup EFI bootloader 14# * mount "haiku esp", mount "ESP" 15# * Copy all contents of "haiku esp" to "ESP" 16# * unmount "haiku esp", unmount "ESP" 17# * Mount new Haiku install. (should mount to /Haiku1) 18# * Run this script (sysprep-gce.sh /Haiku1) 19# * If r1beta4 20# * Manually copy over latest r1beta4 haiku, haiku_devel, haiku_data_translations, haiku_loader 21# * Needed on r1b4 due to / permissions fix needed by sshd 22# * Shutdown VM. DO NOT BOOT FROM NEW DISK! 23# * Booting from new disk will cause SSH host keys to generate! (#18186) 24# * Compress tar cvzf haiku-r1beta4-v20221222.tar.gz disk.raw 25# * Upload to google cloud storage bucket for haiku.inc (ex: haiku-images/r1beta4/xxx) 26# ex: gcloud storage cp ./haiku-master-x64-v20231024.tar.gz gs://haiku-images/master/haiku-master-x64-v20231024.tar.gz 27# * Import image (be sure to update version information below) 28# * compute engine -> images 29# * create image 30# * source: Cloud storage file -> haiku-images/r1beta4/xxx 31# * name: haiku-r1beta4-x64-v20221222 32# * family: haiku-r1beta4-x64 33# * description: Haiku R1/Beta4 x86_64 34 35if [ $# -ne 1 ]; then 36 echo "usage: $0 <HAIKU ROOTFS>" 37 echo " example: $0 /Haiku1" 38 exit 1; 39fi 40 41SMOL_RELEASE="0.1.1-1" 42TARGET_ROOTFS="$1" 43 44echo "Preparing $TARGET_ROOTFS for Google Compute Engine..." 45echo "WARNING: DO NOT DIRECTLY BOOT FROM THIS HAIKU INSTALL!" 46echo "" 47echo "Installing basic authentication stuff..." 48# Installs gce_metadata_ssh tool for sshd. This lets you control the keys 49# of the "user" user from GKE. ONLY "user" WORKS! We have no PAM for gce's os-login stuff 50wget https://eu.hpkg.haiku-os.org/haikuports/r1beta4/x86_64/current/packages/smolcloudtools-$SMOL_RELEASE-x86_64.hpkg \ 51 -O $TARGET_ROOTFS/system/packages/smolcloudtools-$SMOL_RELEASE-x86_64.hpkg 52 53echo "Configuring ssh..." 54# Configure SSHD (reminder, sshd sees "user" as root since it is UID 0) 55echo "# For Google Compute Engine" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config 56echo "AuthorizedKeysCommand /bin/gce_metadata_ssh" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config 57echo "AuthorizedKeysCommandUser user" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config 58echo "PasswordAuthentication no" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config 59echo "PermitRootLogin without-password" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config 60 61unmount $TARGET_ROOTFS 62 63echo "Complete! Please shutdown VM. DO NOT BOOT FROM NEW OS IMAGE!" 64