condition: introduce systemd.condition-first-boot= kernel command line switch
Much like systemd.condition-needs-update= this new switch allows overriding of a unit file condition, but this time its ConditionFirstBoot=. Usecase is also primarily debugging, but could be useful for other schemes too.
This commit is contained in:
parent
5439d8212c
commit
814872e925
|
@ -433,8 +433,11 @@
|
||||||
|
|
||||||
<listitem><para>Takes a boolean argument, defaults to on. If off,
|
<listitem><para>Takes a boolean argument, defaults to on. If off,
|
||||||
<citerefentry><refentrytitle>systemd-firstboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
<citerefentry><refentrytitle>systemd-firstboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||||
will not query the user for basic system settings, even if the system boots up for the first time and the
|
will not query the user for basic system settings, even if the system boots up for the first time and
|
||||||
relevant settings are not initialized yet.</para></listitem>
|
the relevant settings are not initialized yet. Not to be confused with
|
||||||
|
<varname>systemd.condition-first-boot=</varname> (see below), which overrides the result of the
|
||||||
|
<varname>ConditionFirstBoot=</varname> unit file condition, and thus controls more than just
|
||||||
|
<filename>systemd-firstboot.service</filename> behaviour.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -445,6 +448,17 @@
|
||||||
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
|
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
|
||||||
details.</para></listitem>
|
details.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>systemd.condition-first-boot=</varname></term>
|
||||||
|
|
||||||
|
<listitem><para>Takes a boolean argument. If specified, overrides the result of
|
||||||
|
<varname>ConditionFirstBoot=</varname> unit condition checks. See
|
||||||
|
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
|
||||||
|
details. Not to be confused with <varname>systemd.firstboot=</varname> which only controls behaviour
|
||||||
|
of the <filename>systemd-firstboot.service</filename> system service but has no effect on the
|
||||||
|
condition check (see above).</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -1312,6 +1312,10 @@
|
||||||
(specifically: an <filename>/etc</filename> with no <filename>/etc/machine-id</filename>). This may
|
(specifically: an <filename>/etc</filename> with no <filename>/etc/machine-id</filename>). This may
|
||||||
be used to populate <filename>/etc</filename> on the first boot after factory reset, or when a new
|
be used to populate <filename>/etc</filename> on the first boot after factory reset, or when a new
|
||||||
system instance boots up for the first time.</para>
|
system instance boots up for the first time.</para>
|
||||||
|
|
||||||
|
<para>If the <varname>systemd.condition-first-boot=</varname> option is specified on the kernel
|
||||||
|
command line (taking a boolean), it will override the result of this condition check, taking
|
||||||
|
precedence over <filename>/etc/machine-id</filename> existence checks.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
@ -627,11 +627,18 @@ static int condition_test_needs_update(Condition *c, char **env) {
|
||||||
|
|
||||||
static int condition_test_first_boot(Condition *c, char **env) {
|
static int condition_test_first_boot(Condition *c, char **env) {
|
||||||
int r, q;
|
int r, q;
|
||||||
|
bool b;
|
||||||
|
|
||||||
assert(c);
|
assert(c);
|
||||||
assert(c->parameter);
|
assert(c->parameter);
|
||||||
assert(c->type == CONDITION_FIRST_BOOT);
|
assert(c->type == CONDITION_FIRST_BOOT);
|
||||||
|
|
||||||
|
r = proc_cmdline_get_bool("systemd.condition-first-boot", &b);
|
||||||
|
if (r < 0)
|
||||||
|
log_debug_errno(r, "Failed to parse systemd.condition-first-boot= kernel command line argument, ignoring: %m");
|
||||||
|
if (r > 0)
|
||||||
|
return b == !!r;
|
||||||
|
|
||||||
r = parse_boolean(c->parameter);
|
r = parse_boolean(c->parameter);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
Loading…
Reference in a new issue