]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: configure boot loader options only when going through firmware
authorMike Yuan <me@yhndnzj.com>
Wed, 20 Dec 2023 13:25:27 +0000 (21:25 +0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 20 Dec 2023 16:35:55 +0000 (01:35 +0900)
Fixes #30497

man/systemctl.xml
src/systemctl/systemctl-start-special.c

index 4651e89510453c8221853d9007be0b3ec074dbd9..1882cd756cadcefc09a6c492792f3f5113096c56 100644 (file)
@@ -2607,9 +2607,10 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
         <term><option>--firmware-setup</option></term>
 
         <listitem>
-          <para>When used with the <command>reboot</command> command, indicate to the system's firmware to
-          reboot into the firmware setup interface. Note that this functionality is not available on all
-          systems.</para>
+          <para>When used with the <command>reboot</command>, <command>poweroff</command>, or
+          <command>halt</command> command, indicate to the system's firmware to reboot into the firmware
+          setup interface for the next boot. Note that this functionality is not available on all systems.
+          </para>
 
           <xi:include href="version-info.xml" xpointer="v220"/>
         </listitem>
@@ -2619,10 +2620,11 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
         <term><option>--boot-loader-menu=<replaceable>timeout</replaceable></option></term>
 
         <listitem>
-          <para>When used with the <command>reboot</command> command, indicate to the system's boot loader to
-          show the boot loader menu on the following boot. Takes a time value as parameter — indicating the
-          menu timeout. Pass zero in order to disable the menu timeout. Note that not all boot loaders
-          support this functionality.</para>
+          <para>When used with the <command>reboot</command>, <command>poweroff</command>, or
+          <command>halt</command> command, indicate to the system's boot loader to show the boot loader menu
+          on the following boot. Takes a time value as parameter — indicating the menu timeout. Pass zero
+          in order to disable the menu timeout. Note that not all boot loaders support this functionality.
+          </para>
 
           <xi:include href="version-info.xml" xpointer="v242"/>
         </listitem>
@@ -2632,10 +2634,11 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
         <term><option>--boot-loader-entry=<replaceable>ID</replaceable></option></term>
 
         <listitem>
-          <para>When used with the <command>reboot</command> command, indicate to the system's boot loader to
-          boot into a specific boot loader entry on the following boot. Takes a boot loader entry identifier
-          as argument, or <literal>help</literal> in order to list available entries. Note that not all boot
-          loaders support this functionality.</para>
+          <para>When used with the <command>reboot</command>, <command>poweroff</command>, or
+          <command>halt</command> command, indicate to the system's boot loader to boot into a specific
+          boot loader entry on the following boot. Takes a boot loader entry identifier as argument,
+          or <literal>help</literal> in order to list available entries. Note that not all boot loaders
+          support this functionality.</para>
 
           <xi:include href="version-info.xml" xpointer="v242"/>
         </listitem>
index 2cf746c5a6057d7b5e424b9fa67e3013c1b0f453..d486b406da556cd8e9bd156dd994f454082645d7 100644 (file)
@@ -121,8 +121,7 @@ static int set_exit_code(uint8_t code) {
 }
 
 int verb_start_special(int argc, char *argv[], void *userdata) {
-        bool termination_action; /* An action that terminates the manager, can be performed also by
-                                  * signal. */
+        bool termination_action; /* An action that terminates the system, can be performed also by signal. */
         enum action a;
         int r;
 
@@ -140,17 +139,21 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
                         return r;
         }
 
-        r = prepare_firmware_setup();
-        if (r < 0)
-                return r;
+        termination_action = IN_SET(a, ACTION_HALT, ACTION_POWEROFF, ACTION_REBOOT);
 
-        r = prepare_boot_loader_menu();
-        if (r < 0)
-                return r;
+        if (termination_action) {
+                r = prepare_firmware_setup();
+                if (r < 0)
+                        return r;
 
-        r = prepare_boot_loader_entry();
-        if (r < 0)
-                return r;
+                r = prepare_boot_loader_menu();
+                if (r < 0)
+                        return r;
+
+                r = prepare_boot_loader_entry();
+                if (r < 0)
+                        return r;
+        }
 
         if (a == ACTION_REBOOT) {
                 if (arg_reboot_argument) {
@@ -181,10 +184,6 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
                         return r;
         }
 
-        termination_action = IN_SET(a,
-                                    ACTION_HALT,
-                                    ACTION_POWEROFF,
-                                    ACTION_REBOOT);
         if (termination_action && arg_force >= 2)
                 return halt_now(a);