mirror of
https://github.com/troglobit/finit.git
synced 2026-11-19 19:40:50 +00:00
Add OpenRC-like support for sysctl.d/*.conf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
77b32ebff0
commit
42181a3031
1 file changed
+33
-10
@@ -24,10 +24,11 @@
|
|||||||
|
|
||||||
#include "config.h" /* Generated by configure script */
|
#include "config.h" /* Generated by configure script */
|
||||||
|
|
||||||
#include <sys/mount.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <glob.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <sys/stat.h> /* umask(), mkdir() */
|
#include <sys/stat.h> /* umask(), mkdir() */
|
||||||
#include <lite/lite.h>
|
#include <lite/lite.h>
|
||||||
|
|
||||||
@@ -70,6 +71,36 @@ static int banner(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void networking(void)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
glob_t gl;
|
||||||
|
|
||||||
|
/* Setup kernel specific settings, e.g. allow broadcast ping, etc. */
|
||||||
|
glob("/run/sysctl.d/*.conf", 0, NULL, &gl);
|
||||||
|
glob("/etc/sysctl.d/*.conf", GLOB_APPEND, NULL, &gl);
|
||||||
|
glob("/usr/local/lib/sysctl.d/*.conf", GLOB_APPEND, NULL, &gl);
|
||||||
|
glob("/usr/lib/sysctl.d/*.conf", GLOB_APPEND, NULL, &gl);
|
||||||
|
glob("/lib/sysctl.d/*.conf", GLOB_APPEND, NULL, &gl);
|
||||||
|
glob("/mnt/sysctl.d/*.conf", GLOB_APPEND, NULL, &gl);
|
||||||
|
glob("/etc/sysctl.conf", GLOB_APPEND, NULL, &gl);
|
||||||
|
if (gl.gl_pathc > 0) {
|
||||||
|
for (i = 0; i < gl.gl_pathc; i++) {
|
||||||
|
char cmd[160];
|
||||||
|
|
||||||
|
snprintf(cmd, sizeof(cmd), "/sbin/sysctl -e -p %s >/dev/null", gl.gl_pathv[i]);
|
||||||
|
run(cmd);
|
||||||
|
}
|
||||||
|
globfree(&gl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Run user network start script, or fall back to at least loopback */
|
||||||
|
if (network)
|
||||||
|
run_interactive(network, "Starting networking: %s", network);
|
||||||
|
else
|
||||||
|
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Requires /proc to be mounted */
|
/* Requires /proc to be mounted */
|
||||||
static int fismnt(char *dir)
|
static int fismnt(char *dir)
|
||||||
{
|
{
|
||||||
@@ -220,15 +251,7 @@ int main(int argc, char* argv[])
|
|||||||
/*
|
/*
|
||||||
* Network stuff
|
* Network stuff
|
||||||
*/
|
*/
|
||||||
|
networking();
|
||||||
/* Setup kernel specific settings, e.g. allow broadcast ping, etc. */
|
|
||||||
run("/sbin/sysctl -e -p /etc/sysctl.conf >/dev/null");
|
|
||||||
|
|
||||||
/* Run user network start script, or fall back to at least loopback */
|
|
||||||
if (network)
|
|
||||||
run_interactive(network, "Starting networking: %s", network);
|
|
||||||
else
|
|
||||||
ifconfig("lo", "127.0.0.1", "255.0.0.0", 1);
|
|
||||||
umask(022);
|
umask(022);
|
||||||
|
|
||||||
/* Hooks that rely on loopback, or basic networking being up. */
|
/* Hooks that rely on loopback, or basic networking being up. */
|
||||||
|
|||||||
Reference in new issue
Block a user