blob: 85b164516a1b08202357e2e1463f02be0f95fd62 [file] [log] [blame]
--- a/rcS.c
+++ b/rcS.c
@@ -33,6 +33,12 @@
#include "procd.h"
#include "rcS.h"
+/*These are the scripts that are loaded both in normal and production mode.
+ However, product mode only executes the scripts in BASE_SCRIPTS with
+ lower START index than prod_init and prod_init itself.
+ */
+#define BASE_SCRIPTS "sysfixtime boot system sysctl log firewall network odhcpd fstab"
+
static struct runqueue q, r;
extern int production_mode;
@@ -154,11 +160,26 @@ static void add_initd(struct runqueue *q
runqueue_task_add(q, &s->proc.task, false);
}
+static void remove_str_from_list(char *str, char *list)
+{
+ char *pnt1, *pnt2;
+ if (!str || !list)
+ return;
+ pnt1 = strstr(list, str);
+ if (pnt1 == NULL)
+ return;
+ pnt2 = pnt1 + strlen(str) + 1;
+ memmove(pnt1, pnt2, strlen(pnt2) + 1);
+}
+
static int _rc(struct runqueue *q, char *path, const char *file, char *pattern, char *param)
{
char *dir = alloca(2 + strlen(path) + strlen(file) + strlen(pattern));
glob_t gl;
int j;
+ char available_strings[] = BASE_SCRIPTS;
+ char str[] = BASE_SCRIPTS;
+ char *token;
if (!dir) {
ERROR("Out of memory in %s.\n", file);
@@ -174,17 +195,31 @@ static int _rc(struct runqueue *q, char
for (j = 0; j < gl.gl_pathc; j++)
{
- if (strstr(gl.gl_pathv[j], "prod_init")) {
- if (production_mode) {
+ if (production_mode) {
+ strcpy(str, available_strings);
+ token = strtok(str, " ");
+ do
+ {
+ if (strstr(gl.gl_pathv[j], token)) {
+ add_initd(q, gl.gl_pathv[j], param);
+ remove_str_from_list(token, available_strings);
+ break;
+ }
+ token = strtok(NULL, " ");
+ } while (token != NULL);
+ if (token == NULL && strstr(gl.gl_pathv[j], "prod_init"))
+ {
add_initd(q, gl.gl_pathv[j], param);
break;
} else {
continue;
}
+ } else {
+ if (strstr(gl.gl_pathv[j], "prod_init"))
+ continue;
}
add_initd(q, gl.gl_pathv[j], param);
}
-
globfree(&gl);
return 0;