]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
#15773 add --reboot-argument to systemctl reboot 15958/head
authorlaydervus <laydervus@gmail.com>
Fri, 29 May 2020 17:15:34 +0000 (13:15 -0400)
committerlayderv <laydervus@gmail.com>
Fri, 29 May 2020 20:22:29 +0000 (21:22 +0100)
NEWS
man/systemctl.xml
src/systemctl/systemctl.c

diff --git a/NEWS b/NEWS
index b32df56f90b4dfdcb14870ec2406c7ab1c8c0678..3c446b20176457ed6d9f55a5361e40b2443bcf04 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -349,6 +349,10 @@ CHANGES WITH 246 in spe:
           the default) an address from any acquire delegated prefix is
           automatically chosen and assigned to the interface.
 
+        * "systemctl reboot" takes the option "--reboot-argument=".
+          The optional positional argument to "systemctl reboot" is now
+          being deprecated in favor of this option.
+
 CHANGES WITH 245:
 
         * A new tool "systemd-repart" has been added, that operates as an
index 6dc7cd66f3528403cbb6258f283601ac1b60e20f..53342c4b9d4405af46f66d58eaca8558d0356635 100644 (file)
@@ -1295,7 +1295,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><command>reboot</command> <optional><replaceable>arg</replaceable></optional></term>
+          <term><command>reboot</command></term>
 
           <listitem>
             <para>Shut down and reboot the system. This is mostly equivalent to <command>systemctl start reboot.target
@@ -1311,11 +1311,9 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
             <command>systemctl</command> itself, and the system manager is not contacted. This means the command should
             succeed even when the system manager has crashed.</para>
 
-            <para>If the optional argument <replaceable>arg</replaceable> is given, it will be passed as the optional
+            <para>If the switch <option>--reboot-argument=</option> is given, it will be passed as the optional
             argument to the <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
-            system call. The value is architecture and firmware specific. As an example, <literal>recovery</literal>
-            might be used to trigger system recovery, and <literal>fota</literal> might be used to trigger a
-            <quote>firmware over the air</quote> update.</para>
+            system call.</para>
           </listitem>
         </varlistentry>
 
@@ -2117,6 +2115,16 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--reboot-argument=</option></term>
+
+        <listitem>
+          <para>This switch is used with <command>reboot</command>. The value is architecture and firmware specific. As an example, <literal>recovery</literal>
+            might be used to trigger system recovery, and <literal>fota</literal> might be used to trigger a
+            <quote>firmware over the air</quote> update.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--plain</option></term>
 
index 460e7f69b9ae3e34a26f1500e314bd1cf219151e..ae5c6910572b068f30a370e138577e3ad4e973a1 100644 (file)
@@ -130,6 +130,7 @@ static const char *arg_kill_who = NULL;
 static int arg_signal = SIGTERM;
 static char *arg_root = NULL;
 static usec_t arg_when = 0;
+static const char *arg_reboot_argument = NULL;
 static enum action {
         ACTION_SYSTEMCTL,
         ACTION_HALT,
@@ -3556,10 +3557,23 @@ static int start_special(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return r;
 
-        if (a == ACTION_REBOOT && argc > 1) {
-                r = update_reboot_parameter_and_warn(argv[1], false);
-                if (r < 0)
-                        return r;
+        if (a == ACTION_REBOOT) {
+                const char *arg = NULL;
+
+                if (argc > 1) {
+                        if (arg_reboot_argument)
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Both --reboot-argument= and positional argument passed to reboot command, refusing.");
+
+                        log_notice("Positional argument to reboot command is deprecated, please use --reboot-argument= instead. Accepting anyway.");
+                        arg = argv[1];
+                } else
+                        arg = arg_reboot_argument;
+
+                if (arg) {
+                        r = update_reboot_parameter_and_warn(arg, false);
+                        if (r < 0)
+                                return r;
+                }
 
         } else if (a == ACTION_KEXEC) {
                 r = load_kexec_kernel();
@@ -7708,7 +7722,7 @@ static int systemctl_help(void) {
                "  emergency                           Enter system emergency mode\n"
                "  halt                                Shut down and halt the system\n"
                "  poweroff                            Shut down and power-off the system\n"
-               "  reboot [ARG]                        Shut down and reboot the system\n"
+               "  reboot                              Shut down and reboot the system\n"
                "  kexec                               Shut down and reboot the system with kexec\n"
                "  exit [EXIT_CODE]                    Request user instance or container exit\n"
                "  switch-root ROOT [INIT]             Change to a different root file system\n"
@@ -8026,6 +8040,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 ARG_WITH_DEPENDENCIES,
                 ARG_WAIT,
                 ARG_WHAT,
+                ARG_REBOOT_ARG,
         };
 
         static const struct option options[] = {
@@ -8079,6 +8094,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                 { "message",             required_argument, NULL, ARG_MESSAGE             },
                 { "show-transaction",    no_argument,       NULL, 'T'                     },
                 { "what",                required_argument, NULL, ARG_WHAT                },
+                { "reboot-argument",     required_argument, NULL, ARG_REBOOT_ARG          },
                 {}
         };
 
@@ -8474,6 +8490,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
                         break;
                 }
 
+                case ARG_REBOOT_ARG:
+                        arg_reboot_argument = optarg;
+                        break;
+
                 case '.':
                         /* Output an error mimicking getopt, and print a hint afterwards */
                         log_error("%s: invalid option -- '.'", program_invocation_name);