From 8c4f2a9f2d16af9decce1211767fbb0c21acc884 Mon Sep 17 00:00:00 2001
From: Pierre HUBERT <pierre.git@communiquons.org>
Date: Mon, 16 Jun 2025 21:31:33 +0200
Subject: [PATCH] Fix issue with Ubuntu cloud images

---
 .../src/widgets/forms/CloudInitEditor.tsx     | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx b/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx
index 1b68694..ef54e3a 100644
--- a/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx
+++ b/virtweb_frontend/src/widgets/forms/CloudInitEditor.tsx
@@ -204,6 +204,8 @@ function CloudInitUserDataAssistant(p: CloudInitProps): React.ReactElement {
     p.onChange?.();
   };
 
+  const SYSTEMD_NOT_SERIAL = `/bin/sh -c "rm -f /etc/default/grub.d/50-cloudimg-settings.cfg && update-grub"`;
+
   return (
     <EditSection title="User data assistant">
       <CloudInitTextInput
@@ -255,6 +257,31 @@ function CloudInitUserDataAssistant(p: CloudInitProps): React.ReactElement {
         onChange={onChange}
         yaml={user_data}
       />
+      {/* /bin/sh -c "rm -f /etc/default/grub.d/50-cloudimg-settings.cfg && update-grub" */}
+      <CheckboxInput
+        editable={p.editable}
+        label="Show all startup messages on tty1, not serial"
+        checked={
+          !!(user_data.get("runcmd") as any | undefined)?.items.find(
+            (a: any) => a.value === SYSTEMD_NOT_SERIAL
+          )
+        }
+        onValueChange={(c) => {
+          if (!user_data.getIn(["runcmd"])) user_data.addIn(["runcmd"], []);
+
+          const runcmd = user_data.getIn(["runcmd"]) as any;
+
+          if (c) {
+            runcmd.addIn([], SYSTEMD_NOT_SERIAL);
+          } else {
+            const idx = runcmd.items.findIndex(
+              (o: any) => o.value === SYSTEMD_NOT_SERIAL
+            );
+            runcmd.items.splice(idx, 1);
+          }
+          onChange();
+        }}
+      />
     </EditSection>
   );
 }