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