Merge pull request #29626 from bluca/auto_soft_reboot
systemctl: automatically softreboot/kexec if set up on reboot
This commit is contained in:
@@ -7,11 +7,12 @@
|
||||
#define SD_LOGIND_ROOT_CHECK_INHIBITORS (UINT64_C(1) << 0)
|
||||
#define SD_LOGIND_REBOOT_VIA_KEXEC (UINT64_C(1) << 1)
|
||||
#define SD_LOGIND_SOFT_REBOOT (UINT64_C(1) << 2)
|
||||
#define SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP (UINT64_C(1) << 3)
|
||||
|
||||
/* For internal use only */
|
||||
#define SD_LOGIND_INTERACTIVE (UINT64_C(1) << 63)
|
||||
|
||||
#define SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_PUBLIC (SD_LOGIND_ROOT_CHECK_INHIBITORS|SD_LOGIND_REBOOT_VIA_KEXEC|SD_LOGIND_SOFT_REBOOT)
|
||||
#define SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_PUBLIC (SD_LOGIND_ROOT_CHECK_INHIBITORS|SD_LOGIND_REBOOT_VIA_KEXEC|SD_LOGIND_SOFT_REBOOT|SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP)
|
||||
#define SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_ALL (SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_PUBLIC|SD_LOGIND_INTERACTIVE)
|
||||
|
||||
bool session_id_valid(const char *id);
|
||||
|
||||
@@ -1895,7 +1895,7 @@ static int method_do_shutdown_or_sleep(
|
||||
if (flags & SD_LOGIND_REBOOT_VIA_KEXEC)
|
||||
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Reboot via kexec option is only applicable with reboot operations");
|
||||
if (flags & SD_LOGIND_SOFT_REBOOT)
|
||||
if ((flags & SD_LOGIND_SOFT_REBOOT) || (flags & SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP))
|
||||
return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS,
|
||||
"Soft reboot option is only applicable with reboot operations");
|
||||
}
|
||||
@@ -1912,10 +1912,11 @@ static int method_do_shutdown_or_sleep(
|
||||
flags = interactive ? SD_LOGIND_INTERACTIVE : 0;
|
||||
}
|
||||
|
||||
if ((flags & SD_LOGIND_REBOOT_VIA_KEXEC) && kexec_loaded())
|
||||
a = handle_action_lookup(HANDLE_KEXEC);
|
||||
else if ((flags & SD_LOGIND_SOFT_REBOOT))
|
||||
if ((flags & SD_LOGIND_SOFT_REBOOT) ||
|
||||
((flags & SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP) && path_is_os_tree("/run/nextroot") > 0))
|
||||
a = handle_action_lookup(HANDLE_SOFT_REBOOT);
|
||||
else if ((flags & SD_LOGIND_REBOOT_VIA_KEXEC) && kexec_loaded())
|
||||
a = handle_action_lookup(HANDLE_KEXEC);
|
||||
|
||||
/* Don't allow multiple jobs being executed at the same time */
|
||||
if (m->delayed_action)
|
||||
|
||||
@@ -80,7 +80,12 @@ int logind_reboot(enum action a) {
|
||||
return 0;
|
||||
|
||||
SET_FLAG(flags, SD_LOGIND_ROOT_CHECK_INHIBITORS, arg_check_inhibitors > 0);
|
||||
SET_FLAG(flags, SD_LOGIND_REBOOT_VIA_KEXEC, a == ACTION_KEXEC);
|
||||
SET_FLAG(flags,
|
||||
SD_LOGIND_REBOOT_VIA_KEXEC,
|
||||
a == ACTION_KEXEC || (a == ACTION_REBOOT && getenv_bool("SYSTEMCTL_SKIP_AUTO_KEXEC") <= 0));
|
||||
SET_FLAG(flags,
|
||||
SD_LOGIND_SOFT_REBOOT_IF_NEXTROOT_SET_UP,
|
||||
a == ACTION_REBOOT && getenv_bool("SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT") <= 0);
|
||||
SET_FLAG(flags, SD_LOGIND_SOFT_REBOOT, a == ACTION_SOFT_REBOOT);
|
||||
|
||||
r = bus_call_method(bus, bus_login_mgr, method_with_flags, &error, NULL, "t", flags);
|
||||
|
||||
@@ -1090,10 +1090,7 @@ int systemctl_dispatch_parse_argv(int argc, char *argv[]) {
|
||||
return halt_parse_argv(argc, argv);
|
||||
|
||||
} else if (invoked_as(argv, "reboot")) {
|
||||
if (kexec_loaded())
|
||||
arg_action = ACTION_KEXEC;
|
||||
else
|
||||
arg_action = ACTION_REBOOT;
|
||||
arg_action = ACTION_REBOOT;
|
||||
return halt_parse_argv(argc, argv);
|
||||
|
||||
} else if (invoked_as(argv, "shutdown")) {
|
||||
|
||||
Reference in New Issue
Block a user