11 #include "interface.h"
13 const char *main_path = ".";
14 static char **global_argv;
16 static void netifd_do_restart(struct uloop_timeout *timeout)
18 execvp(global_argv[0], global_argv);
21 static void netifd_do_reload(struct uloop_timeout *timeout)
23 config_init_interfaces(NULL);
26 static struct uloop_timeout main_timer;
28 void netifd_reload(void)
30 main_timer.cb = netifd_do_reload;
31 uloop_timeout_set(&main_timer, 100);
34 void netifd_restart(void)
36 main_timer.cb = netifd_do_restart;
37 interface_set_down(NULL);
38 uloop_timeout_set(&main_timer, 1000);
41 static int usage(const char *progname)
43 fprintf(stderr, "Usage: %s [options]\n"
45 " -s <path>: Path to the ubus socket\n"
46 " -p <path>: Path to netifd addons (default: %s)\n"
47 "\n", progname, main_path);
52 int main(int argc, char **argv)
54 const char *socket = NULL;
59 while ((ch = getopt(argc, argv, "s:")) != -1) {
68 return usage(argv[0]);
72 if (netifd_ubus_init(socket) < 0) {
73 fprintf(stderr, "Failed to connect to ubus\n");
78 fprintf(stderr, "Failed to initialize system control\n");
82 config_init_interfaces(NULL);