diff --git a/examples/app.sh b/examples/app.sh old mode 100644 new mode 100755 index f70f8bb..930318d --- a/examples/app.sh +++ b/examples/app.sh @@ -1,2 +1,2 @@ -db.sh network.sh +# db.sh network.sh echo "Application service started" diff --git a/examples/db.sh b/examples/db.sh old mode 100644 new mode 100755 index e92e8b4..5fd70b0 --- a/examples/db.sh +++ b/examples/db.sh @@ -1,2 +1,2 @@ -network.sh -echo "Database service started" +# network.sh +echo "Database service started" \ No newline at end of file diff --git a/examples/logging.sh b/examples/logging.sh old mode 100644 new mode 100755 diff --git a/examples/network.sh b/examples/network.sh old mode 100644 new mode 100755 index 2d58303..1517f43 --- a/examples/network.sh +++ b/examples/network.sh @@ -1,2 +1,2 @@ -logging.sh +# logging.sh echo "Network service started" diff --git a/src/config.h b/src/config.h index 85f165e..859c962 100644 --- a/src/config.h +++ b/src/config.h @@ -1,2 +1,3 @@ #define INIT_DIRECTORY "/home/lily/init/examples" -#define SHELL "/bin/sh" \ No newline at end of file +#define SHELL "/bin/sh" +#define DEPENDENCY_PREFIX "#" \ No newline at end of file diff --git a/src/main.c b/src/main.c index 451b324..afe2cc1 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ void check_init() { void run(int runlevel) { char command[1024]; - snprintf(command, sizeof(command), "%s %s/%d", SHELL, INIT_DIRECTORY, runlevel); + snprintf(command, sizeof(command), "cd %s && PATH=\"$PATH:%s\" %s %d", INIT_DIRECTORY, INIT_DIRECTORY, SHELL, runlevel); system(command); } @@ -30,9 +30,9 @@ int main(int argc, char* argv[]) { printf("Usage: %s \n", argv[0]); return 1; } - char runlevel = argv[1][0]; + int runlevel = atoi(argv[1]); check_init(); - run; + run(runlevel); return 0; } diff --git a/src/solver.c b/src/solver.c index 2922041..e4b5ff2 100644 --- a/src/solver.c +++ b/src/solver.c @@ -94,7 +94,11 @@ void solve_dependencies(char runlevel) { if (f) { char line[1024]; if (fgets(line, sizeof(line), f)) { - char *token = strtok(line, " \t\n\r"); + char *start = line; + if (strncmp(line, DEPENDENCY_PREFIX, strlen(DEPENDENCY_PREFIX)) == 0) { + start += strlen(DEPENDENCY_PREFIX); + } + char *token = strtok(start, " \t\n\r"); while (token && s->num_dependencies < MAX_DEPS) { strncpy(s->dependencies[s->num_dependencies++], token, MAX_NAME); token = strtok(NULL, " \t\n\r");