]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homectl: mute console while running firstboot prompts
authorLennart Poettering <lennart@poettering.net>
Fri, 19 Sep 2025 08:22:49 +0000 (10:22 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 26 Sep 2025 14:19:43 +0000 (16:19 +0200)
man/homectl.xml
src/home/homectl.c
units/systemd-homed-firstboot.service

index 961266aea3d32ac673a30495ef1e38b2a07f7465..82ea2e3943d70be575dd3c8d5ea66cc5d0477b7a 100644 (file)
         <xi:include href="version-info.xml" xpointer="v259"/></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--mute-console=</option></term>
+
+        <listitem><para>Takes a boolean argument. If true kernel log output and service manager status output
+        to the system console is temporarily disabled while <command>firstboot --prompt-new-user</command> is
+        running, so that its own output is not interrupted. Defaults to false.</para>
+
+        <xi:include href="version-info.xml" xpointer="v259"/></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--match=</option></term>
         <term><option>-A</option></term>
index 22665eae45fc8d8f07bd217085490483811cf786..199cb3953793c5e9ceb4d8a54900163b0bca9abd 100644 (file)
@@ -4,6 +4,7 @@
 #include <unistd.h>
 
 #include "sd-bus.h"
+#include "sd-varlink.h"
 
 #include "ask-password-api.h"
 #include "bitfield.h"
@@ -112,6 +113,7 @@ static bool arg_prompt_new_user = false;
 static bool arg_prompt_shell = true;
 static bool arg_prompt_groups = true;
 static bool arg_chrome = true;
+static bool arg_mute_console = false;
 
 STATIC_DESTRUCTOR_REGISTER(arg_identity_extra, sd_json_variant_unrefp);
 STATIC_DESTRUCTOR_REGISTER(arg_identity_extra_this_machine, sd_json_variant_unrefp);
@@ -2839,6 +2841,9 @@ static int create_interactively(void) {
                 return 0;
         }
 
+        _cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *mute_console_link = NULL;
+        (void) mute_console(&mute_console_link);
+
         (void) terminal_reset_defensive_locked(STDOUT_FILENO, /* flags= */ 0);
 
         if (arg_chrome)
@@ -3077,6 +3082,8 @@ static int help(int argc, char *argv[], void *userdata) {
                "     --prompt-shell=no         In first-boot mode, don't prompt for shells\n"
                "     --chrome=no               In first-boot mode, don't show colour bar at top\n"
                "                               and bottom of terminal\n"
+               "     --mute-console=yes        In first-boot mode, tell kernel/PID 1 to not\n"
+               "                               write to the console while running\n"
                "\n%4$sGeneral User Record Properties:%5$s\n"
                "  -c --real-name=REALNAME      Real name for user\n"
                "     --realm=REALM             Realm to create user in\n"
@@ -3316,6 +3323,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_PROMPT_SHELL,
                 ARG_PROMPT_GROUPS,
                 ARG_CHROME,
+                ARG_MUTE_CONSOLE,
         };
 
         static const struct option options[] = {
@@ -3425,6 +3433,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "prompt-shell",                 required_argument, NULL, ARG_PROMPT_SHELL                },
                 { "prompt-groups",                required_argument, NULL, ARG_PROMPT_GROUPS               },
                 { "chrome",                       required_argument, NULL, ARG_CHROME                      },
+                { "mute-console",                 required_argument, NULL, ARG_MUTE_CONSOLE                },
                 {}
         };
 
@@ -5005,6 +5014,13 @@ static int parse_argv(int argc, char *argv[]) {
 
                         break;
 
+                case ARG_MUTE_CONSOLE:
+                        r = parse_boolean_argument("--mute-console=", optarg, &arg_mute_console);
+                        if (r < 0)
+                                return r;
+
+                        break;
+
                 case '?':
                         return -EINVAL;
 
index bc9259241545f55cdfcff48ec823ae1e5a7d503f..531c50f02d53fb1a0fa27d92db00aabfbbb359f9 100644 (file)
@@ -17,7 +17,7 @@ Before=systemd-user-sessions.service first-boot-complete.target
 [Service]
 Type=oneshot
 RemainAfterExit=yes
-ExecStart=homectl firstboot --prompt-new-user --prompt-shell=no --prompt-groups=no
+ExecStart=homectl firstboot --prompt-new-user --prompt-shell=no --prompt-groups=no --mute-console=yes
 StandardOutput=tty
 StandardInput=tty
 StandardError=tty