add service_validator support
[project/procd.git] / state.c
diff --git a/state.c b/state.c
index 1abcbca..f83032c 100644 (file)
--- a/state.c
+++ b/state.c
@@ -20,6 +20,7 @@
 #include "syslog.h"
 #include "hotplug.h"
 #include "watchdog.h"
+#include "service.h"
 
 enum {
        STATE_NONE = 0,
@@ -40,16 +41,20 @@ static void state_enter(void)
        switch (state) {
        case STATE_EARLY:
                LOG("- early -\n");
-               watchdog_init();
+               watchdog_init(0);
                hotplug("/etc/hotplug.json");
                procd_coldplug();
                break;
 
        case STATE_INIT:
+               // try to reopen incase the wdt was not available before coldplug
+               watchdog_init(0);
                LOG("- init -\n");
                log_init();
                procd_connect_ubus();
+               service_init();
                procd_inittab();
+               procd_inittab_run("respawn");
                procd_inittab_run("askconsole");
                procd_inittab_run("askfirst");
                procd_inittab_run("sysinit");
@@ -62,12 +67,11 @@ static void state_enter(void)
        case STATE_SHUTDOWN:
                LOG("- shutdown -\n");
                procd_inittab_run("shutdown");
+               sync();
                break;
 
        case STATE_HALT:
-               LOG("- reboot -\nprocd says good bye !\n");
-               sync();
-               sleep(1);
+               LOG("- reboot -\n");
                reboot(reboot_event);
                break;
 
@@ -86,7 +90,7 @@ void procd_state_next(void)
 
 void procd_shutdown(int event)
 {
-       DEBUG(1, "Shutting down system with event %x\n", reboot_event);
+       DEBUG(1, "Shutting down system with event %x\n", event);
        reboot_event = event;
        state = STATE_SHUTDOWN;
        state_enter();