systemctl: make "systemctl is-system-running" return "offline" if we are not booted with systemd
This sounds like the better place to expose this than in "systemd-notify --booted". Also document the so far undocumented "unknown" state the command might return. And rearrange the table of states documented to be more like the one for "is-running". Also, don't document the precise exit code of this function, just say errors are reported != 0 or > 0...
This commit is contained in:
parent
16f98462a0
commit
94f099d813
|
@ -1120,9 +1120,9 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
<tgroup cols='3'>
|
<tgroup cols='3'>
|
||||||
<thead>
|
<thead>
|
||||||
<row>
|
<row>
|
||||||
<entry>Printed string</entry>
|
<entry>Name</entry>
|
||||||
<entry>Meaning</entry>
|
<entry>Description</entry>
|
||||||
<entry>Return value</entry>
|
<entry>Exit Code</entry>
|
||||||
</row>
|
</row>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -1137,7 +1137,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
<row>
|
<row>
|
||||||
<entry><literal>linked</literal></entry>
|
<entry><literal>linked</literal></entry>
|
||||||
<entry morerows='1'>Made available through a symlink to the unit file (permanently or just in <filename>/run</filename>).</entry>
|
<entry morerows='1'>Made available through a symlink to the unit file (permanently or just in <filename>/run</filename>).</entry>
|
||||||
<entry morerows='1'>1</entry>
|
<entry morerows='1'>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><literal>linked-runtime</literal></entry>
|
<entry><literal>linked-runtime</literal></entry>
|
||||||
|
@ -1145,7 +1145,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
<row>
|
<row>
|
||||||
<entry><literal>masked</literal></entry>
|
<entry><literal>masked</literal></entry>
|
||||||
<entry morerows='1'>Disabled entirely (permanently or just in <filename>/run</filename>).</entry>
|
<entry morerows='1'>Disabled entirely (permanently or just in <filename>/run</filename>).</entry>
|
||||||
<entry morerows='1'>1</entry>
|
<entry morerows='1'>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><literal>masked-runtime</literal></entry>
|
<entry><literal>masked-runtime</literal></entry>
|
||||||
|
@ -1163,7 +1163,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
<row>
|
<row>
|
||||||
<entry><literal>disabled</literal></entry>
|
<entry><literal>disabled</literal></entry>
|
||||||
<entry>Unit file is not enabled.</entry>
|
<entry>Unit file is not enabled.</entry>
|
||||||
<entry>1</entry>
|
<entry>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
|
@ -1474,22 +1474,25 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>Checks whether the system is operational. This
|
<para>Checks whether the system is operational. This
|
||||||
returns success when the system is fully up and running,
|
returns success (exit code 0) when the system is fully up
|
||||||
meaning not in startup, shutdown or maintenance
|
and running, specifically not in startup, shutdown or
|
||||||
mode. Failure is returned otherwise. In addition, the
|
maintenance mode, and with no failed services. Failure is
|
||||||
|
returned otherwise (exit code non-zero). In addition, the
|
||||||
current state is printed in a short string to standard
|
current state is printed in a short string to standard
|
||||||
output, see table below. Use <option>--quiet</option> to
|
output, see table below. Use <option>--quiet</option> to
|
||||||
suppress this output.</para>
|
suppress this output.</para>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<title>Manager Operational States</title>
|
<title><command>is-system-running</command> output</title>
|
||||||
<tgroup cols='2'>
|
<tgroup cols='3'>
|
||||||
<colspec colname='name' />
|
<colspec colname='name'/>
|
||||||
<colspec colname='description' />
|
<colspec colname='description'/>
|
||||||
|
<colspec colname='exit-code'/>
|
||||||
<thead>
|
<thead>
|
||||||
<row>
|
<row>
|
||||||
<entry>Name</entry>
|
<entry>Name</entry>
|
||||||
<entry>Description</entry>
|
<entry>Description</entry>
|
||||||
|
<entry>Exit Code</entry>
|
||||||
</row>
|
</row>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -1499,32 +1502,53 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service
|
||||||
<filename>basic.target</filename> is reached
|
<filename>basic.target</filename> is reached
|
||||||
or the <varname>maintenance</varname> state entered.
|
or the <varname>maintenance</varname> state entered.
|
||||||
</para></entry>
|
</para></entry>
|
||||||
|
<entry>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><varname>starting</varname></entry>
|
<entry><varname>starting</varname></entry>
|
||||||
<entry><para>Late bootup, before the job queue
|
<entry><para>Late bootup, before the job queue
|
||||||
becomes idle for the first time, or one of the
|
becomes idle for the first time, or one of the
|
||||||
rescue targets are reached.</para></entry>
|
rescue targets are reached.</para></entry>
|
||||||
|
<entry>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><varname>running</varname></entry>
|
<entry><varname>running</varname></entry>
|
||||||
<entry><para>The system is fully
|
<entry><para>The system is fully
|
||||||
operational.</para></entry>
|
operational.</para></entry>
|
||||||
|
<entry>0</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><varname>degraded</varname></entry>
|
<entry><varname>degraded</varname></entry>
|
||||||
<entry><para>The system is operational but one or more
|
<entry><para>The system is operational but one or more
|
||||||
units failed.</para></entry>
|
units failed.</para></entry>
|
||||||
|
<entry>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><varname>maintenance</varname></entry>
|
<entry><varname>maintenance</varname></entry>
|
||||||
<entry><para>The rescue or emergency target is
|
<entry><para>The rescue or emergency target is
|
||||||
active.</para></entry>
|
active.</para></entry>
|
||||||
|
<entry>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><varname>stopping</varname></entry>
|
<entry><varname>stopping</varname></entry>
|
||||||
<entry><para>The manager is shutting
|
<entry><para>The manager is shutting
|
||||||
down.</para></entry>
|
down.</para></entry>
|
||||||
|
<entry>> 0</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><varname>offline</varname></entry>
|
||||||
|
<entry><para>The manager is not
|
||||||
|
running. Specifically, this is the operational
|
||||||
|
state if an incompatible program is running as
|
||||||
|
system manager (PID 1).</para></entry>
|
||||||
|
<entry>> 0</entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><varname>unknown</varname></entry>
|
||||||
|
<entry><para>The operational state could not be
|
||||||
|
determined, due to lack of resources or another
|
||||||
|
error cause.</para></entry>
|
||||||
|
<entry>> 0</entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
|
|
|
@ -124,7 +124,12 @@
|
||||||
systemd, non-zero otherwise. If this option is passed, no
|
systemd, non-zero otherwise. If this option is passed, no
|
||||||
message is sent. This option is hence unrelated to the other
|
message is sent. This option is hence unrelated to the other
|
||||||
options. For details about the semantics of this option, see
|
options. For details about the semantics of this option, see
|
||||||
<citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para></listitem>
|
<citerefentry><refentrytitle>sd_booted</refentrytitle><manvolnum>3</manvolnum></citerefentry>. An
|
||||||
|
alternative way to check for this state is to call
|
||||||
|
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||||
|
with the <command>is-system-running</command> command. It will
|
||||||
|
return <literal>offline</literal> if the system was not booted
|
||||||
|
with systemd. </para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<xi:include href="standard-options.xml" xpointer="help" />
|
<xi:include href="standard-options.xml" xpointer="help" />
|
||||||
|
|
|
@ -5753,6 +5753,12 @@ static int is_system_running(sd_bus *bus, char **args) {
|
||||||
_cleanup_free_ char *state = NULL;
|
_cleanup_free_ char *state = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
if (arg_transport == BUS_TRANSPORT_LOCAL && !sd_booted()) {
|
||||||
|
if (!arg_quiet)
|
||||||
|
puts("offline");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
r = sd_bus_get_property_string(
|
r = sd_bus_get_property_string(
|
||||||
bus,
|
bus,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
|
|
Loading…
Reference in a new issue