mirror of
https://github.com/troglobit/finit.git
synced 2026-10-14 10:19:36 +00:00
Follow-up to 885056a, collapse and simplify code
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
b2ac81540f
commit
82661346b7
1 file changed
+25
-26
+25
-26
@@ -152,44 +152,43 @@ static void networking(void)
|
||||
/* Run user network start script if enabled */
|
||||
if (network) {
|
||||
run_interactive(network, "Starting networking: %s", network);
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Debian/Ubuntu/Busybox/RH/Suse */
|
||||
if (fexist("/sbin/ifup")) {
|
||||
/* interfaces file */
|
||||
fp = fopen("/etc/network/interfaces", "r");
|
||||
if (fp) {
|
||||
int i = 0;
|
||||
char buf[160];
|
||||
if (!fexist("/sbin/ifup"))
|
||||
goto done;
|
||||
|
||||
/* Bring up all 'auto' interfaces */
|
||||
while (fgets(buf, sizeof(buf), fp)) {
|
||||
char cmd[80];
|
||||
char *line, *ifname = NULL;
|
||||
fp = fopen("/etc/network/interfaces", "r");
|
||||
if (fp) {
|
||||
int i = 0;
|
||||
char buf[160];
|
||||
|
||||
chomp(buf);
|
||||
line = strip_line(buf);
|
||||
/* Bring up all 'auto' interfaces */
|
||||
while (fgets(buf, sizeof(buf), fp)) {
|
||||
char cmd[80];
|
||||
char *line, *ifname = NULL;
|
||||
|
||||
if (!strncmp(line, "auto", 4))
|
||||
ifname = &line[5];
|
||||
if (!strncmp(line, "allow-hotplug", 13))
|
||||
ifname = &line[14];
|
||||
chomp(buf);
|
||||
line = strip_line(buf);
|
||||
|
||||
if (!ifname)
|
||||
continue;
|
||||
if (!strncmp(line, "auto", 4))
|
||||
ifname = &line[5];
|
||||
if (!strncmp(line, "allow-hotplug", 13))
|
||||
ifname = &line[14];
|
||||
|
||||
snprintf(cmd, 80, "/sbin/ifup %s", ifname);
|
||||
run_interactive(cmd, "Bringing up interface %s", ifname);
|
||||
i++;
|
||||
}
|
||||
if (!ifname)
|
||||
continue;
|
||||
|
||||
fclose(fp);
|
||||
if (i)
|
||||
return;
|
||||
snprintf(cmd, 80, "/sbin/ifup %s", ifname);
|
||||
run_interactive(cmd, "Bringing up interface %s", ifname);
|
||||
i++;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
done:
|
||||
/* Fall back to bring up at least loopback */
|
||||
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user