Follow-up to 885056a, collapse and simplify code

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-07-01 20:34:26 +02:00
1 parent b2ac81540f
commit 82661346b7
1 file changed
+25 -26
+25 -26
View File
@@ -152,44 +152,43 @@ static void networking(void)
/* Run user network start script if enabled */ /* Run user network start script if enabled */
if (network) { if (network) {
run_interactive(network, "Starting networking: %s", network); run_interactive(network, "Starting networking: %s", network);
return; goto done;
} }
/* Debian/Ubuntu/Busybox/RH/Suse */ /* Debian/Ubuntu/Busybox/RH/Suse */
if (fexist("/sbin/ifup")) { if (!fexist("/sbin/ifup"))
/* interfaces file */ goto done;
fp = fopen("/etc/network/interfaces", "r");
if (fp) {
int i = 0;
char buf[160];
/* Bring up all 'auto' interfaces */ fp = fopen("/etc/network/interfaces", "r");
while (fgets(buf, sizeof(buf), fp)) { if (fp) {
char cmd[80]; int i = 0;
char *line, *ifname = NULL; char buf[160];
chomp(buf); /* Bring up all 'auto' interfaces */
line = strip_line(buf); while (fgets(buf, sizeof(buf), fp)) {
char cmd[80];
char *line, *ifname = NULL;
if (!strncmp(line, "auto", 4)) chomp(buf);
ifname = &line[5]; line = strip_line(buf);
if (!strncmp(line, "allow-hotplug", 13))
ifname = &line[14];
if (!ifname) if (!strncmp(line, "auto", 4))
continue; ifname = &line[5];
if (!strncmp(line, "allow-hotplug", 13))
ifname = &line[14];
snprintf(cmd, 80, "/sbin/ifup %s", ifname); if (!ifname)
run_interactive(cmd, "Bringing up interface %s", ifname); continue;
i++;
}
fclose(fp); snprintf(cmd, 80, "/sbin/ifup %s", ifname);
if (i) run_interactive(cmd, "Bringing up interface %s", ifname);
return; i++;
} }
fclose(fp);
} }
done:
/* Fall back to bring up at least loopback */ /* Fall back to bring up at least loopback */
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1); ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
} }