mirror of
https://github.com/troglobit/finit.git
synced 2026-11-24 20:21:44 +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 */
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user