summaryrefslogtreecommitdiff
path: root/src/user/init/init.c
blob: fb231e0c4125b4e800a533eea0c184ade5d66453 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <knob/user.h>
#include <knob/file.h>
#include <knob/task.h>

#define STARTUP_FILE_PATH "sys/startup.rc"

void main() {
  struct file *f = open_file(STARTUP_FILE_PATH);
  if (!f) {
    tell_user_sz("Could not open " STARTUP_FILE_PATH ".\n");
    return;
  }

  tell_user_sz("[init] Reading from " STARTUP_FILE_PATH ".\n");

  char cmdbuf[128];
  while (read_line_from_file(f, cmdbuf, 127)) {
    tell_user_sz("[init] Starting ");
    tell_user_sz(cmdbuf);
    tell_user_sz(": ");
    if (run_command(cmdbuf)) {
      tell_user_sz("Succeded.\n");
      yield_task();
    }
    else
      tell_user_sz("Failed.\n");
  }

  close_file(f);

  tell_user_sz("[init] Done starting programs.\n");
}