utils: fix existing node check when keep_old/no_delete is enabled
[project/netifd.git] / main.c
diff --git a/main.c b/main.c
index da5ae09..e008f64 100644 (file)
--- a/main.c
+++ b/main.c
@@ -2,10 +2,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
+#include <unistd.h>
 
 #include "netifd.h"
 #include "ubus.h"
 #include "config.h"
+#include "system.h"
+#include "interface.h"
 
 const char *main_path = ".";
 static char **global_argv;
@@ -21,6 +24,7 @@ static struct uloop_timeout restart_timer = {
 
 void netifd_restart(void)
 {
+       interface_set_down(NULL);
        uloop_timeout_set(&restart_timer, 1000);
 }
 
@@ -55,11 +59,16 @@ int main(int argc, char **argv)
                }
        }
 
-       if (netifd_ubus_init(NULL) < 0) {
+       if (netifd_ubus_init(socket) < 0) {
                fprintf(stderr, "Failed to connect to ubus\n");
                return 1;
        }
 
+       if (system_init()) {
+               fprintf(stderr, "Failed to initialize system control\n");
+               return 1;
+       }
+
        config_init_interfaces(NULL);
 
        uloop_run();