summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-04-28 22:12:21 +0200
committerThomas Haller <thaller@redhat.com>2020-04-30 13:57:54 +0200
commit776c94fda22b06a0d28a9fc08ccdb3c6ecf6137e (patch)
tree4826bd9b1e437e421e64b1a529d1f640d88fc92b
parenta05dbeb31fca7f2f804583112fd432148c3f737e (diff)
downloadNetworkManager-th/nm-online-configure-timeout.tar.gz
nm-online: allow configuring timeout via NM_ONLINE_TIMEOUT environmentth/nm-online-configure-timeout
https://bugzilla.redhat.com/show_bug.cgi?id=1828458
-rw-r--r--Makefile.am7
-rw-r--r--clients/nm-online.c4
-rw-r--r--data/NetworkManager-wait-online.service.in19
-rw-r--r--man/nm-online.xml3
-rw-r--r--po/POTFILES.skip1
5 files changed, 29 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am
index 2f15ddbd81..6cb709b8d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4285,9 +4285,12 @@ clients_nm_online_LDFLAGS = \
-Wl,--version-script="$(srcdir)/linker-script-binary.ver"
clients_nm_online_LDADD = \
- shared/nm-libnm-aux/libnm-libnm-aux.la \
libnm/libnm.la \
- $(GLIB_LIBS)
+ shared/nm-libnm-aux/libnm-libnm-aux.la \
+ shared/nm-glib-aux/libnm-glib-aux.la \
+ shared/nm-std-aux/libnm-std-aux.la \
+ $(GLIB_LIBS) \
+ $(NULL)
$(clients_nm_online_OBJECTS): $(libnm_core_lib_h_pub_mkenums)
$(clients_nm_online_OBJECTS): $(libnm_lib_h_pub_mkenums)
diff --git a/clients/nm-online.c b/clients/nm-online.c
index 5950da568c..8370f96437 100644
--- a/clients/nm-online.c
+++ b/clients/nm-online.c
@@ -233,7 +233,7 @@ main (int argc, char *argv[])
OnlineData data = {
.retval = EXIT_FAILURE_UNSPECIFIED,
};
- int t_secs = 30;
+ int t_secs;
GOptionContext *opt_ctx = NULL;
gboolean success;
GOptionEntry options[] = {
@@ -251,6 +251,8 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
+ t_secs = _nm_utils_ascii_str_to_int64 (g_getenv ("NM_ONLINE_TIMEOUT"), 10, 0, G_MAXINT, 30);
+
data.start_timestamp_ms = _now_ms ();
opt_ctx = g_option_context_new (NULL);
diff --git a/data/NetworkManager-wait-online.service.in b/data/NetworkManager-wait-online.service.in
index 8963246850..6423a1a2e0 100644
--- a/data/NetworkManager-wait-online.service.in
+++ b/data/NetworkManager-wait-online.service.in
@@ -6,9 +6,26 @@ After=NetworkManager.service
Before=network-online.target
[Service]
+# `nm-online -s` waits until the point when NetworkManager logs
+# "startup complete". That means startup actions are settled and
+# devices and profiles reached a conclusive activated or deactivated state.
+# That depends on which profiles are configured to autoconnect. It also depends
+# the profiles settings like ipv4.may-fail/ipv6.may-fail, which affect when
+# a profile is considered fully activated.
+# Check NetworkManager logs to find out why it takes longer than expected.
+
Type=oneshot
-ExecStart=@bindir@/nm-online -s -q --timeout=30
+ExecStart=@bindir@/nm-online -s -q
RemainAfterExit=yes
+# Set $NM_ONLINE_TIMEOUT variable for timeout in seconds.
+# Edit with `systemctl edit NetworkManager-wait-online`.
+#
+# Note, this timeout should commonly not be reached. If your boot
+# gets delayed too long, then the solution is not to decrease the
+# timeout, but to fix your setup so that the connected state
+# gets reached earlier.
+Environment=NM_ONLINE_TIMEOUT=30
+
[Install]
WantedBy=network-online.target
diff --git a/man/nm-online.xml b/man/nm-online.xml
index c36dda8dd8..a0db6b3d88 100644
--- a/man/nm-online.xml
+++ b/man/nm-online.xml
@@ -145,7 +145,8 @@
<listitem>
<para>Time to wait for a connection, in seconds. If the option is not provided,
- the default timeout is 30 seconds.</para>
+ the environment variable <literal>NM_ONLINE_TIMEOUT</literal> is honored.
+ The default timeout is 30 seconds.</para>
</listitem>
</varlistentry>
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index da2247a0a0..425b100e5c 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,5 +1,6 @@
clients/cloud-setup/nm-cloud-setup.service.in
contrib/fedora/rpm/
+data/NetworkManager-wait-online.service.in
data/NetworkManager.service.in
data/org.freedesktop.NetworkManager.policy.in
examples/python/NetworkManager.py