Skip to content

Commit 17889a8

Browse files
kallisti5pulkomandy
authored andcommitted
3rdparty/google: add script for making Google Compute Engine images
Change-Id: Ia52b8e6a30255ee7903cfb0834d4030b6774b1c8 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5963 Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
1 parent 8040281 commit 17889a8

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

3rdparty/cloud/sysprep-gce.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
31+
if [ $# -ne 1 ]; then
32+
echo "usage: $0 <HAIKU ROOTFS>"
33+
echo " example: $0 /Haiku1"
34+
return 1;
35+
fi
36+
37+
SMOL_RELEASE="0.1.1-1"
38+
TARGET_ROOTFS="$1"
39+
40+
echo "Preparing $TARGET_ROOTFS for Google Compute Engine..."
41+
echo "WARNING: DO NOT DIRECTLY BOOT FROM THIS HAIKU INSTALL!"
42+
echo ""
43+
echo "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
46+
wget 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+
49+
echo "Configuring ssh..."
50+
# Configure SSHD (reminder, sshd sees "user" as root since it is UID 0)
51+
echo "# For Google Compute Engine" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config
52+
echo "AuthorizedKeysCommand /bin/gce_metadata_ssh" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config
53+
echo "AuthorizedKeysCommandUser user" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config
54+
echo "PasswordAuthentication no" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config
55+
echo "PermitRootLogin without-password" >> $TARGET_ROOTFS/system/settings/ssh/sshd_config
56+
57+
unmount $TARGET_ROOTFS
58+
59+
echo "Complete! Please shutdown VM. DO NOT BOOT FROM NEW OS IMAGE!"

0 commit comments

Comments
 (0)