diff --git a/src/main.c b/src/main.c index 51e54a223fe3aa161b94bee1af8c1692d62ebcca..0d22ba1670c150dea81f76af185ac3ba4c25b372 100644 --- a/src/main.c +++ b/src/main.c @@ -253,6 +253,7 @@ static void usage(const char *prog) fprintf(stderr, "\n"); fprintf(stderr, "options:\n"); fprintf(stderr, " -l <0-7> Set the loglevel\n"); + fprintf(stderr, " -d <schema dm> Display the schema data model supported by micro-service\n"); fprintf(stderr, " -h Displays this help\n"); fprintf(stderr, "\n"); } @@ -260,9 +261,9 @@ static void usage(const char *prog) int main(int argc, char **argv) { int log_level = 7; - int c = 0; + int c = 0, dm_type = 0; - while ((c = getopt(argc, argv, "hl:")) != -1) { + while ((c = getopt(argc, argv, "hdl:")) != -1) { switch (c) { case 'l': log_level = (int)strtod(optarg, NULL); @@ -270,6 +271,9 @@ int main(int argc, char **argv) log_level = 7; } break; + case 'd': + dm_type++; + break; case 'h': usage(argv[0]); exit(0); @@ -278,18 +282,24 @@ int main(int argc, char **argv) exit(0); } } - load_system_users(); - load_system_groups(); memset(&bbfdm_ctx, 0, sizeof(struct bbfdm_context)); - create_groups(); - create_users(); - bbfdm_ubus_set_service_name(&bbfdm_ctx, "usermngr"); bbfdm_ubus_set_log_level(log_level); bbfdm_ubus_load_data_model(tDynamicObj); + if (dm_type > 0) { + int res = bbfdm_print_data_model_schema(&bbfdm_ctx, dm_type); + exit(res); + } + + load_system_users(); + load_system_groups(); + + create_groups(); + create_users(); + if (bbfdm_ubus_regiter_init(&bbfdm_ctx)) goto out;