From f9326cd8782f9739eb62e06a5ac63216f29f14a8 Mon Sep 17 00:00:00 2001
From: Lee Tickett <ltickett@gitlab.com>
Date: Fri, 9 Feb 2024 19:45:14 +0000
Subject: [PATCH] Improve GDK-in-a-box

---
 doc/build_gdk_in_a_box.md          |  1 +
 doc/gdk_in_a_box.md                | 24 +++++++++++++++++++++++-
 support/gdk-in-a-box/setup-ssh-key | 12 +++++++++++-
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/doc/build_gdk_in_a_box.md b/doc/build_gdk_in_a_box.md
index 984f154972ed..5f61cdfcb377 100644
--- a/doc/build_gdk_in_a_box.md
+++ b/doc/build_gdk_in_a_box.md
@@ -71,6 +71,7 @@ Upload the zipped `gdk.vbox` and `gdk.vdi` files to Google Drive.
 
 1. Login with SSH to `debian@gdk.local`. You do not need a password to log in.
    1. Install GDK using the one-line installation method: ```curl "https://gitlab.com/gitlab-org/gitlab-development-kit/-/raw/main/support/install" | bash```.
+   1. When prompted, configure GDK to use the GitLab community fork, and telemetry with anonymous user: `gdk-in-a-box`.
    1. Load asdf into your shell: ```source "/home/debian/.asdf/asdf.sh"```.
    1. Enable Vite: 
   
diff --git a/doc/gdk_in_a_box.md b/doc/gdk_in_a_box.md
index 7cb6495129c5..38b6cd968fe9 100644
--- a/doc/gdk_in_a_box.md
+++ b/doc/gdk_in_a_box.md
@@ -5,7 +5,7 @@ to instantly start developing.
 
 ## Run on macOS
 
-1. Download and [install UTM](https://docs.getutm.app/installation/macos/).
+1. Download and [install UTM](https://mac.getutm.app/).
 1. Download and unzip [GDK-in-a-box](https://go.gitlab.com/cCHpCP).
 1. Double-click `gdk.utm`.
 1. Follow the [standard setup steps](#standard-setup).
@@ -30,6 +30,7 @@ NOTE:
   The docs detail [how to checkout branches from different remotes](https://gitlab.com/gitlab-community/meta#checkout-a-branch-from-a-different-remote),
   but as a last resort you may reconfigure your remote to the canonical project.
 
+1. In a local terminal, import the SSH key by running: `curl "https://gitlab.com/gitlab-org/gitlab-development-kit/-/raw/main/support/gdk-in-a-box/setup-ssh-key" | bash`.
 1. Start the VM (minimise the console because you won't need it).
 1. Connect VSCode to the VM:
    - Select **Remote-SSH: Connect to host** from the command palette
@@ -43,6 +44,27 @@ NOTE:
 1. Open GitLab in your browser: [http://gdk.local:3000](http://gdk.local:3000).
 1. Login to GitLab with `root/5iveL!fe`.
 
+## Update
+
+You can update GDK-in-a-box at any time.
+While connected via Remote-SSH:
+
+- In VSCode, select **Terminal > New terminal**.
+- Run: `gdk update`.
+
+## Troubleshoot
+
+If you have any issues, the simplest and fastest solution is to:
+
+- Delete the virtual machine.
+- Download the latest build.
+- Follow the [standard setup instructions](#standard-setup).
+
+NOTE:
+
+Your GitLab instance will be restored to defaults.
+Be sure to commit and push all changes beforehand, or they will be lost.
+
 ## Building GDK-in-a-box
 
 This isn't neccessary to use GDK-in-box.
diff --git a/support/gdk-in-a-box/setup-ssh-key b/support/gdk-in-a-box/setup-ssh-key
index 36654d2df0bd..2b24ed5aacc3 100644
--- a/support/gdk-in-a-box/setup-ssh-key
+++ b/support/gdk-in-a-box/setup-ssh-key
@@ -1,5 +1,15 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+if [ -f ~/.ssh/gdk.local_rsa ]; then
+    echo "SSH key previously imported."
+    exit 0
+fi
+
 curl "https://gitlab.com/gitlab-org/gitlab-development-kit/-/raw/main/support/gdk-in-a-box/gdk.local_rsa" -o ~/.ssh/gdk.local_rsa
 chmod 600 ~/.ssh/gdk.local_rsa
 echo >> ~/.ssh/config
 echo "Host gdk.local" >> ~/.ssh/config
-echo "IdentityFile ~/.ssh/gdk.local_rsa" >> ~/.ssh/config
\ No newline at end of file
+echo "IdentityFile ~/.ssh/gdk.local_rsa" >> ~/.ssh/config
+echo "SSH key imported."
-- 
GitLab