]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: add hotkeys for rebooting/powering off the system from the boot menu
authorLennart Poettering <lennart@poettering.net>
Mon, 21 Aug 2023 20:59:53 +0000 (22:59 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Aug 2023 09:29:36 +0000 (11:29 +0200)
In a an environment with a serial console it's just too useful to
directly reboot/power off the machine without any further tooling.

man/systemd-boot.xml
src/boot/efi/boot.c

index 30908e398a3c5975f8a2c025768a6a8786a06206..56044281d44cae32b743c1377843e8bb26d14862 100644 (file)
         may also be reached with <keycap>F2</keycap>, <keycap>F10</keycap>, <keycap>Del</keycap> and
         <keycap>Esc</keycap>.</para></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><keycombo><keycap>Shift</keycap><keycap>o</keycap></keycombo></term>
+        <listitem><para>Power off the system.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><keycombo><keycap>Shift</keycap><keycap>b</keycap></keycombo></term>
+        <listitem><para>Reboot the system.</para></listitem>
+      </varlistentry>
     </variablelist>
 
     <para>The following keys may be pressed during bootup or in the boot menu to directly boot a specific
index b1c88142864d55755853dc80819be65070fdcf8f..30272ce2dd53f46ffd7d4a17a4354a951bf5817b 100644 (file)
@@ -881,7 +881,7 @@ static bool menu_run(
                 case KEYPRESS(0, 0, 'H'):
                 case KEYPRESS(0, 0, '?'):
                         /* This must stay below 80 characters! Q/v/Ctrl+l/f deliberately not advertised. */
-                        status = xstrdup16(u"(d)efault (t/T)timeout (e)dit (r/R)resolution (p)rint (h)elp");
+                        status = xstrdup16(u"(d)efault (t/T)imeout (e)dit (r/R)esolution (p)rint (O)ff re(B)oot (h)elp");
                         break;
 
                 case KEYPRESS(0, 0, 'Q'):
@@ -1008,6 +1008,14 @@ static bool menu_run(
                                 status = xstrdup16(u"Reboot into firmware interface not supported.");
                         break;
 
+                case KEYPRESS(0, 0, 'O'): /* Only uppercase, so that it can't be hit so easily fat-fingered, but still works safely over serial */
+                        RT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+                        break;
+
+                case KEYPRESS(0, 0, 'B'): /* ditto */
+                        RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+                        break;
+
                 default:
                         /* jump with a hotkey directly to a matching entry */
                         idx = entry_lookup_key(config, idx_highlight+1, KEYCHAR(key));