From c55afaadb3feffa4f65d834b7184fddc5ff48515 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Mon, 5 May 2008 13:41:01 -0300 Subject: [PATCH] User, modules and checkfs configurable from /etc/finit.conf Signed-off-by: Claudio Matsuoka --- README | 7 ------ README.mandriva | 3 ++- finit-alt.c | 57 +++++++++++++++++++++++++++++++++++-------------- finit.conf | 4 ++++ 4 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 finit.conf diff --git a/README b/README index 2b4d669a..e81d2053 100644 --- a/README +++ b/README @@ -66,10 +66,3 @@ automounting may not work correctly. That happens because the session is started before the system message bus, so add a "dcop kded mediamanager reloadBackends" call in the user AutoStart to restart the client. - -finit-alt parameters --------------------- - -CHECKFS= run fsck on the specified device -DEBUG enable runtime debug (drops to shell after X session) - diff --git a/README.mandriva b/README.mandriva index a336d086..4cbc0b10 100644 --- a/README.mandriva +++ b/README.mandriva @@ -21,7 +21,8 @@ Mandriva 2008 4 - Set the pointer device in the X server configuration to /dev/input/mice -5 - Have a user named "user", or change the default in Makefile +5 - Have a user named "user", change the default in Makefile or configure + in /etc/finit.conf diff --git a/finit-alt.c b/finit-alt.c index ea20e043..05e6887a 100644 --- a/finit-alt.c +++ b/finit-alt.c @@ -137,38 +137,63 @@ int main() mount("proc", "/proc", "proc", 0, NULL); + /* * Parse kernel parameters */ if ((f = fopen("/proc/cmdline", "r")) != NULL) { - char *x; fgets(line, LINE_SIZE, f); if (strstr(line, "quiet")) { close(0); close(1); close(2); } - if ((x = strstr(line, "CHECKFS="))) { - x += 8; - strcpy(cmd, "e2fsck -C -p "); - c = cmd + strlen(cmd); - while (x && *x != ' ') *c++ = *x++; - system(cmd); - sync(); - sync(); - reboot(RB_AUTOBOOT); - } - if ((x = strstr(line, "USERNAME="))) { - x += 9; - c = cmd + strlen(cmd); - while (x && *x != ' ') *c++ = *x++; - } if ((strstr(line, "DEBUG"))) { debug = 1; } fclose(f); } + /* + * Parse configuration file + */ + if ((f = fopen("/etc/finit.conf", "r")) != NULL) { + char *x; + while (!feof(f)) { + fgets(line, LINE_SIZE, f); + + if (debug) { + printf("conf: %s", line); + } + + if ((x = strstr(line, "check ")) == line) { + x += 6; + strcpy(cmd, "/sbin/e2fsck -C -p "); + c = cmd + strlen(cmd); + while (x && *x != ' ') *c++ = *x++; + system(cmd); + sync(); + sync(); + reboot(RB_AUTOBOOT); + } + if ((x = strstr(line, "user ")) == line) { + x += 5; + c = username; + while (x && *x != ' ') *c++ = *x++; + continue; + } + if ((x = strstr(line, "module ")) == line) { + x += 7; + strcpy(cmd, "/sbin/insmod "); + c = cmd + strlen(cmd); + while (x && *x != ' ') *c++ = *x++; + system(cmd); + continue; + } + } + fclose(f); + } + setsid(); /* diff --git a/finit.conf b/finit.conf new file mode 100644 index 00000000..25c625a1 --- /dev/null +++ b/finit.conf @@ -0,0 +1,4 @@ +user fred +module agp-intel +module p4-clockmod +check /dev/sda3