020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen This file is part of systemd.
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen Copyright 2013 Tom Gundersen <teg@jklm.no>
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen systemd is free software; you can redistribute it and/or modify it
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen under the terms of the GNU Lesser General Public License as published by
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen (at your option) any later version.
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen systemd is distributed in the hope that it will be useful, but
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen Lesser General Public License for more details.
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen You should have received a copy of the GNU Lesser General Public License
020d59000f86b3d98be763eaee6a2671f0427e46Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
e56cdb7ae2657d62c9a8b6d3427382b209dff8e7Tom Gundersenstatic usec_t arg_timeout = 120 * USEC_PER_SEC;
cef8b0735831b2bfeaf21d8a245d8024c3de816aTom Gundersen "Block until network is configured.\n\n"
cef8b0735831b2bfeaf21d8a245d8024c3de816aTom Gundersen " -h --help Show this help\n"
cef8b0735831b2bfeaf21d8a245d8024c3de816aTom Gundersen " --version Print version string\n"
cef8b0735831b2bfeaf21d8a245d8024c3de816aTom Gundersen " -q --quiet Do not show status information\n"
601185b43da638b1c74153deae01dbd518680889Zbigniew Jędrzejewski-Szmek " -i --interface=INTERFACE Block until at least these interfaces have appeared\n"
79b1f37d95f08fe7620b071eec51d2810ed077c9Tom Gundersen " --ignore=INTERFACE Don't take these interfaces into account\n"
e56cdb7ae2657d62c9a8b6d3427382b209dff8e7Tom Gundersen " --timeout=SECS Maximum time to wait for network connectivity\n"
601185b43da638b1c74153deae01dbd518680889Zbigniew Jędrzejewski-Szmek , program_invocation_short_name);
cef8b0735831b2bfeaf21d8a245d8024c3de816aTom Gundersenstatic int parse_argv(int argc, char *argv[]) {
cef8b0735831b2bfeaf21d8a245d8024c3de816aTom Gundersen { "version", no_argument, NULL, ARG_VERSION },
cef8b0735831b2bfeaf21d8a245d8024c3de816aTom Gundersen { "interface", required_argument, NULL, 'i' },
79b1f37d95f08fe7620b071eec51d2810ed077c9Tom Gundersen { "ignore", required_argument, NULL, ARG_IGNORE },
e56cdb7ae2657d62c9a8b6d3427382b209dff8e7Tom Gundersen { "timeout", required_argument, NULL, ARG_TIMEOUT },
baee30afce50b611724e6c6a4ca61a4469b11d9dMartin Pitt while ((c = getopt_long(argc, argv, "+hi:q", options, NULL)) >= 0)
72c0a2c255b172ebbb2a2b7dab7c9aec4c9582d9Lennart Poettering assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
e56cdb7ae2657d62c9a8b6d3427382b209dff8e7Tom Gundersen r = manager_new(&m, arg_interfaces, arg_ignore, arg_timeout);
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt log_error_errno(r, "Could not create manager: %m");
b6b8adbff4b1a67a2fffc2c225f1b083d9e4a69eTom Gundersen "STATUS=Waiting for network connections...");
e56cdb7ae2657d62c9a8b6d3427382b209dff8e7Tom Gundersen if (r >= 0) {
e56cdb7ae2657d62c9a8b6d3427382b209dff8e7Tom Gundersen sd_notify(false, "STATUS=All interfaces configured...");
e56cdb7ae2657d62c9a8b6d3427382b209dff8e7Tom Gundersen sd_notify(false, "STATUS=Failed waiting for network connectivity...");