diff --git a/NEWS b/NEWS index b32df56f90..3c446b2017 100644 --- 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 diff --git a/man/systemctl.xml b/man/systemctl.xml index 6dc7cd66f3..53342c4b9d 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -1295,7 +1295,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err - reboot arg + reboot Shut down and reboot the system. This is mostly equivalent to systemctl start reboot.target @@ -1311,11 +1311,9 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err systemctl itself, and the system manager is not contacted. This means the command should succeed even when the system manager has crashed. - If the optional argument arg is given, it will be passed as the optional + If the switch is given, it will be passed as the optional argument to the reboot2 - system call. The value is architecture and firmware specific. As an example, recovery - might be used to trigger system recovery, and fota might be used to trigger a - firmware over the air update. + system call. @@ -2117,6 +2115,16 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err + + + + + This switch is used with reboot. The value is architecture and firmware specific. As an example, recovery + might be used to trigger system recovery, and fota might be used to trigger a + firmware over the air update. + + + diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 460e7f69b9..ae5c691057 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -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);