3 This file is part of systemd.
5 Copyright 2013 Tom Gundersen <teg@jklm.no>
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include "sd-daemon.h"
25 #include "networkd-wait-online.h"
30 static bool arg_quiet
= false;
31 static char **arg_interfaces
= NULL
;
33 static void help(void) {
34 printf("%s [OPTIONS...]\n\n"
35 "Block until network is configured.\n\n"
36 " -h --help Show this help\n"
37 " --version Print version string\n"
38 " -q --quiet Do not show status information\n"
39 " -i --interface=INTERFACE Block until at least these interfaces have appeared\n"
40 , program_invocation_short_name
);
43 static int parse_argv(int argc
, char *argv
[]) {
49 static const struct option options
[] = {
50 { "help", no_argument
, NULL
, 'h' },
51 { "version", no_argument
, NULL
, ARG_VERSION
},
52 { "quiet", no_argument
, NULL
, 'q' },
53 { "interface", required_argument
, NULL
, 'i' },
62 while ((c
= getopt_long(argc
, argv
, "+hiq", options
, NULL
)) >= 0)
76 puts(SYSTEMD_FEATURES
);
80 if (strv_extend(&arg_interfaces
, optarg
) < 0)
89 assert_not_reached("Unhandled option");
95 int main(int argc
, char *argv
[]) {
96 _cleanup_(manager_freep
) Manager
*m
= NULL
;
99 log_set_target(LOG_TARGET_AUTO
);
100 log_parse_environment();
105 r
= parse_argv(argc
, argv
);
110 log_set_max_level(LOG_WARNING
);
112 assert_se(sigprocmask_many(SIG_BLOCK
, SIGTERM
, SIGINT
, -1) == 0);
114 r
= manager_new(&m
, arg_interfaces
);
116 log_error("Could not create manager: %s", strerror(-r
));
120 if (manager_all_configured(m
)) {
127 "STATUS=Waiting for network connections...");
129 r
= sd_event_loop(m
->event
);
131 log_error("Event loop failed: %s", strerror(-r
));
136 sd_notify(false, "STATUS=All interfaces configured...");
138 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;