]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn,vmspawn: let's add some terminal magic to the welcome text 31023/head
authorLennart Poettering <lennart@poettering.net>
Fri, 19 Jan 2024 22:23:48 +0000 (23:23 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 22 Jan 2024 15:24:00 +0000 (16:24 +0100)
Let's grey the text out, and prefix it with a vertical grey bar, to make
clear this is output from the host, not the payload, and make it clearly
distinguishable from what follows.

Let's also make the image name clickable (with new enough
shared-mime-info this should allow you to look into the image with
gnome-disk-utility or a similar tool.

src/nspawn/nspawn.c
src/vmspawn/vmspawn.c

index 445d85da6f071d682a0188a9c1b664ca57952438..c48b51323b7ff98e4225e21235aa9f5d4e49b9f3 100644 (file)
@@ -5943,9 +5943,16 @@ static int run(int argc, char *argv[]) {
         if (arg_console_mode == CONSOLE_PIPE) /* if we pass STDERR on to the container, don't add our own logs into it too */
                 arg_quiet = true;
 
-        if (!arg_quiet)
-                log_info("Spawning container %s on %s.\nPress Ctrl-] three times within 1s to kill container.",
-                         arg_machine, arg_image ?: arg_directory);
+        if (!arg_quiet) {
+                const char *t = arg_image ?: arg_directory;
+                _cleanup_free_ char *u = NULL;
+                (void) terminal_urlify_path(t, t, &u);
+
+                log_info("%s %sSpawning container %s on %s.%s\n"
+                         "%s %sPress %sCtrl-]%s three times within 1s to kill container.%s",
+                         special_glyph(SPECIAL_GLYPH_LIGHT_SHADE), ansi_grey(), arg_machine, u ?: t, ansi_normal(),
+                         special_glyph(SPECIAL_GLYPH_LIGHT_SHADE), ansi_grey(), ansi_highlight(), ansi_grey(), ansi_normal());
+        }
 
         assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGWINCH, SIGTERM, SIGINT, SIGRTMIN+18, -1) >= 0);
 
index d93b6b29c923a62208c57fe5ad5c0b1c98f76169..a08bc4c6794c8a289ad9d5f267349f7ac416c3a6 100644 (file)
@@ -811,10 +811,15 @@ static int run(int argc, char *argv[]) {
         if (r < 0)
                 return r;
 
-        if (!arg_quiet)
-                log_info("Spawning VM %s on %s.\n"
-                         "Press Ctrl-a x to kill VM.",
-                         arg_machine, arg_image);
+        if (!arg_quiet) {
+                _cleanup_free_ char *u = NULL;
+                (void) terminal_urlify_path(arg_image, arg_image, &u);
+
+                log_info("%s %sSpawning VM %s on %s.%s\n"
+                         "%s %sPress %sCtrl-a x%s to kill VM.%s",
+                         special_glyph(SPECIAL_GLYPH_LIGHT_SHADE), ansi_grey(), arg_machine, u ?: arg_image, ansi_normal(),
+                         special_glyph(SPECIAL_GLYPH_LIGHT_SHADE), ansi_grey(), ansi_highlight(), ansi_grey(), ansi_normal());
+        }
 
         assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);