summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-04-27 21:56:20 +0200
committerLennart Poettering <lennart@poettering.net>2023-06-02 16:49:38 +0200
commit34f21ff610a3a77bf6e5064f1d0eb567f9a90fb2 (patch)
tree0968348afaea946f3d9ddc9c252d91a3ca548d5c /src
parentlogind: add support for 'soft-reboot' reboots (diff)
downloadsystemd-34f21ff610a3a77bf6e5064f1d0eb567f9a90fb2.tar.xz
systemd-34f21ff610a3a77bf6e5064f1d0eb567f9a90fb2.zip
systemctl: add "systemctl soft-reboot" command
Diffstat (limited to 'src')
-rw-r--r--src/systemctl/systemctl-logind.c2
-rw-r--r--src/systemctl/systemctl-start-special.c1
-rw-r--r--src/systemctl/systemctl-start-unit.c1
-rw-r--r--src/systemctl/systemctl-trivial-method.c1
-rw-r--r--src/systemctl/systemctl.c7
-rw-r--r--src/systemctl/systemctl.h1
6 files changed, 11 insertions, 2 deletions
diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c
index fd8ca09de8..a4486dcce9 100644
--- a/src/systemctl/systemctl-logind.c
+++ b/src/systemctl/systemctl-logind.c
@@ -45,6 +45,7 @@ int logind_reboot(enum action a) {
[ACTION_POWEROFF] = "PowerOff",
[ACTION_REBOOT] = "Reboot",
[ACTION_KEXEC] = "Reboot",
+ [ACTION_SOFT_REBOOT] = "Reboot",
[ACTION_HALT] = "Halt",
[ACTION_SUSPEND] = "Suspend",
[ACTION_HIBERNATE] = "Hibernate",
@@ -80,6 +81,7 @@ int logind_reboot(enum action a) {
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_SOFT_REBOOT, a == ACTION_SOFT_REBOOT);
r = bus_call_method(bus, bus_login_mgr, method_with_flags, &error, NULL, "t", flags);
if (r >= 0)
diff --git a/src/systemctl/systemctl-start-special.c b/src/systemctl/systemctl-start-special.c
index c6084f373e..6e2238f2a5 100644
--- a/src/systemctl/systemctl-start-special.c
+++ b/src/systemctl/systemctl-start-special.c
@@ -199,6 +199,7 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
case ACTION_REBOOT:
case ACTION_KEXEC:
case ACTION_HALT:
+ case ACTION_SOFT_REBOOT:
if (arg_when == 0)
r = logind_reboot(a);
else if (arg_when != USEC_INFINITY)
diff --git a/src/systemctl/systemctl-start-unit.c b/src/systemctl/systemctl-start-unit.c
index 3dac7da460..8268217967 100644
--- a/src/systemctl/systemctl-start-unit.c
+++ b/src/systemctl/systemctl-start-unit.c
@@ -222,6 +222,7 @@ const struct action_metadata action_table[_ACTION_MAX] = {
[ACTION_POWEROFF] = { SPECIAL_POWEROFF_TARGET, "poweroff", "replace-irreversibly" },
[ACTION_REBOOT] = { SPECIAL_REBOOT_TARGET, "reboot", "replace-irreversibly" },
[ACTION_KEXEC] = { SPECIAL_KEXEC_TARGET, "kexec", "replace-irreversibly" },
+ [ACTION_SOFT_REBOOT] = { SPECIAL_SOFT_REBOOT_TARGET, "soft-reboot", "replace-irreversibly" },
[ACTION_RUNLEVEL2] = { SPECIAL_MULTI_USER_TARGET, NULL, "isolate" },
[ACTION_RUNLEVEL3] = { SPECIAL_MULTI_USER_TARGET, NULL, "isolate" },
[ACTION_RUNLEVEL4] = { SPECIAL_MULTI_USER_TARGET, NULL, "isolate" },
diff --git a/src/systemctl/systemctl-trivial-method.c b/src/systemctl/systemctl-trivial-method.c
index 5e530f3a14..02a29123e7 100644
--- a/src/systemctl/systemctl-trivial-method.c
+++ b/src/systemctl/systemctl-trivial-method.c
@@ -30,6 +30,7 @@ int verb_trivial_method(int argc, char *argv[], void *userdata) {
streq(argv[0], "halt") ? "Halt" :
streq(argv[0], "reboot") ? "Reboot" :
streq(argv[0], "kexec") ? "KExec" :
+ streq(argv[0], "soft-reboot") ? "SoftReboot" :
streq(argv[0], "exit") ? "Exit" :
/* poweroff */ "PowerOff";
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index b31a59785b..143c8b41b2 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -242,6 +242,7 @@ static int systemctl_help(void) {
" poweroff Shut down and power-off the system\n"
" reboot Shut down and reboot the system\n"
" kexec Shut down and reboot the system with kexec\n"
+ " soft-reboot Shut down and reboot userspace\n"
" exit [EXIT_CODE] Request user instance or container exit\n"
" switch-root [ROOT [INIT]] Change to a different root file system\n"
" suspend Suspend the system\n"
@@ -285,8 +286,9 @@ static int systemctl_help(void) {
" --now Start or stop unit after enabling or disabling it\n"
" --dry-run Only print what would be done\n"
" Currently supported by verbs: halt, poweroff, reboot,\n"
- " kexec, suspend, hibernate, suspend-then-hibernate,\n"
- " hybrid-sleep, default, rescue, emergency, and exit.\n"
+ " kexec, soft-reboot, suspend, hibernate, \n"
+ " suspend-then-hibernate, hybrid-sleep, default,\n"
+ " rescue, emergency, and exit.\n"
" -q --quiet Suppress output\n"
" --no-warn Suppress several warnings shown by default\n"
" --wait For (re)start, wait until service stopped again\n"
@@ -1180,6 +1182,7 @@ static int systemctl_main(int argc, char *argv[]) {
{ "poweroff", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "reboot", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "kexec", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
+ { "soft-reboot", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "suspend", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "hibernate", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "hybrid-sleep", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h
index 03645624ee..e8ba8f76a0 100644
--- a/src/systemctl/systemctl.h
+++ b/src/systemctl/systemctl.h
@@ -16,6 +16,7 @@ enum action {
ACTION_POWEROFF,
ACTION_REBOOT,
ACTION_KEXEC,
+ ACTION_SOFT_REBOOT,
ACTION_EXIT,
ACTION_SUSPEND,
ACTION_HIBERNATE,