]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Plugson/src/main_linux.c
11 #include <sys/types.h>
12 #include <linux/limits.h>
13 #include <ventoy_define.h>
14 #include <ventoy_util.h>
15 #include <ventoy_json.h>
16 #include <ventoy_disk.h>
17 #include <ventoy_http.h>
19 char g_log_file
[MAX_PATH
];
20 char g_cur_dir
[MAX_PATH
];
21 char g_ventoy_dir
[MAX_PATH
];
23 int ventoy_log_init(void);
24 void ventoy_log_exit(void);
26 void ventoy_signal_stop(int sig
)
28 vlog("ventoy server exit due to signal ...\n");
29 printf("ventoy server exit ...\n");
41 int main(int argc
, char **argv
)
44 const char *ip
= "127.0.0.1";
45 const char *port
= "24681";
49 printf("Invalid argc %d\n", argc
);
53 if (isdigit(argv
[1][0]))
58 if (isdigit(argv
[2][0]))
63 strlcpy(g_ventoy_dir
, argv
[3]);
64 scnprintf(g_log_file
, sizeof(g_log_file
), "%s/%s", g_ventoy_dir
, LOG_FILE
);
67 getcwd(g_cur_dir
, MAX_PATH
);
69 if (!ventoy_is_directory_exist("./ventoy"))
71 printf("%s/ventoy directory does not exist\n", g_cur_dir
);
75 ventoy_get_disk_info(argv
);
77 vlog("===============================================\n");
78 vlog("===== Ventoy Plugson %s:%s =====\n", ip
, port
);
79 vlog("===============================================\n");
83 rc
= ventoy_www_init();
86 printf("Failed to init web data, check log for details.\n");
94 rc
= ventoy_http_start(ip
, port
);
97 printf("Ventoy failed to start http server, check ./ventoy/plugson.log for detail\n");
101 signal(SIGINT
, ventoy_signal_stop
);
102 signal(SIGTSTP
, ventoy_signal_stop
);
103 signal(SIGQUIT
, ventoy_signal_stop
);