systemctl: add new "is-system-running" command to check whether system is fully up
https://bugs.freedesktop.org/show_bug.cgi?id=66926
This commit is contained in:
parent
e8a152c62d
commit
99813a1912
|
@ -288,6 +288,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
<command>snapshot</command>,
|
<command>snapshot</command>,
|
||||||
<command>is-active</command>,
|
<command>is-active</command>,
|
||||||
<command>is-failed</command>,
|
<command>is-failed</command>,
|
||||||
|
<command>is-enabled</command>,
|
||||||
|
<command>is-system-running</command>,
|
||||||
<command>enable</command> and
|
<command>enable</command> and
|
||||||
<command>disable</command>.</para>
|
<command>disable</command>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@ -1299,6 +1301,20 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
<title>System Commands</title>
|
<title>System Commands</title>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><command>is-system-running</command></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Checks whether the system is running. This returns
|
||||||
|
success when the system is fully up and running, meaning
|
||||||
|
not in startup, shutdown or maintainance mode. Failure is
|
||||||
|
returned otherwise. In addition, the current state is
|
||||||
|
printed in a short string to standard output. Use
|
||||||
|
<option>--quiet</option> to suppress output of this state
|
||||||
|
string.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command>default</command></term>
|
<term><command>default</command></term>
|
||||||
|
|
||||||
|
@ -1307,6 +1323,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
<command>isolate default.target</command>.</para>
|
<command>isolate default.target</command>.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command>rescue</command></term>
|
<term><command>rescue</command></term>
|
||||||
|
|
||||||
|
|
|
@ -5462,6 +5462,30 @@ static int unit_is_enabled(sd_bus *bus, char **args) {
|
||||||
return !enabled;
|
return !enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int is_system_running(sd_bus *bus, char **args) {
|
||||||
|
_cleanup_free_ char *state = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
r = sd_bus_get_property_string(
|
||||||
|
bus,
|
||||||
|
"org.freedesktop.systemd1",
|
||||||
|
"/org/freedesktop/systemd1",
|
||||||
|
"org.freedesktop.systemd1.Manager",
|
||||||
|
"SystemState",
|
||||||
|
NULL,
|
||||||
|
&state);
|
||||||
|
if (r < 0) {
|
||||||
|
if (!arg_quiet)
|
||||||
|
puts("unknown");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!arg_quiet)
|
||||||
|
puts(state);
|
||||||
|
|
||||||
|
return streq(state, "running") ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
static int systemctl_help(void) {
|
static int systemctl_help(void) {
|
||||||
|
|
||||||
pager_open_if_enabled();
|
pager_open_if_enabled();
|
||||||
|
@ -5573,6 +5597,7 @@ static int systemctl_help(void) {
|
||||||
" daemon-reload Reload systemd manager configuration\n"
|
" daemon-reload Reload systemd manager configuration\n"
|
||||||
" daemon-reexec Reexecute systemd manager\n\n"
|
" daemon-reexec Reexecute systemd manager\n\n"
|
||||||
"System Commands:\n"
|
"System Commands:\n"
|
||||||
|
" is-system-running Check whether system is fully running\n"
|
||||||
" default Enter system default mode\n"
|
" default Enter system default mode\n"
|
||||||
" rescue Enter system rescue mode\n"
|
" rescue Enter system rescue mode\n"
|
||||||
" emergency Enter system emergency mode\n"
|
" emergency Enter system emergency mode\n"
|
||||||
|
@ -6576,6 +6601,7 @@ static int systemctl_main(sd_bus *bus, int argc, char *argv[], int bus_error) {
|
||||||
{ "set-default", EQUAL, 2, set_default, NOBUS },
|
{ "set-default", EQUAL, 2, set_default, NOBUS },
|
||||||
{ "get-default", EQUAL, 1, get_default, NOBUS },
|
{ "get-default", EQUAL, 1, get_default, NOBUS },
|
||||||
{ "set-property", MORE, 3, set_property },
|
{ "set-property", MORE, 3, set_property },
|
||||||
|
{ "is-system-running", EQUAL, 1, is_system_running },
|
||||||
{}
|
{}
|
||||||
}, *verb = verbs;
|
}, *verb = verbs;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue