diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2019-10-31 01:39:05 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2019-10-31 17:48:01 +0100 |
commit | c3d40326ec5c78e41f2bf0bf2ed2c413113e0e84 (patch) | |
tree | 68768de9d8751ed5bca131946836bca91123bd9f /src | |
parent | a9f8a4bdcec084d9ed4593a2e435687a14a128f3 (diff) |
add --db-check option
This allows starting osmo-hlr to merely open the database, do upgrades if
necessary, and quit, without opening any ports.
So that no ports are opened, move the telnet VTY startup to below the database
check.
Needed for upcoming patch that introduces a db_upgrade test, in
I0961bab0e17cfde5b030576c5bc243c2b51d9dc4.
Change-Id: I1a4b3360690acd2cd3cffdadffbb00a28d421316
Diffstat (limited to 'src')
-rw-r--r-- | src/hlr.c | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -706,6 +706,7 @@ static void print_help() printf(" -T --timestamp Prefix every log line with a timestamp.\n"); printf(" -e --log-level number Set a global loglevel.\n"); printf(" -U --db-upgrade Allow HLR database schema upgrades.\n"); + printf(" -C --db-check Quit after opening (and upgrading) the database.\n"); printf(" -V --version Print the version of OsmoHLR.\n"); } @@ -714,6 +715,7 @@ static struct { const char *db_file; bool daemonize; bool db_upgrade; + bool db_check; } cmdline_opts = { .config_file = "osmo-hlr.cfg", .db_file = NULL, @@ -735,6 +737,7 @@ static void handle_options(int argc, char **argv) {"log-level", 1, 0, 'e'}, {"timestamp", 0, 0, 'T'}, {"db-upgrade", 0, 0, 'U' }, + {"db-check", 0, 0, 'C' }, {"version", 0, 0, 'V' }, {0, 0, 0, 0} }; @@ -773,6 +776,9 @@ static void handle_options(int argc, char **argv) case 'U': cmdline_opts.db_upgrade = true; break; + case 'C': + cmdline_opts.db_check = true; + break; case 'V': print_version(1); exit(0); @@ -856,12 +862,6 @@ int main(int argc, char **argv) return rc; } - /* start telnet after reading config for vty_get_bind_addr() */ - rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), - OSMO_VTY_PORT_HLR); - if (rc < 0) - return rc; - LOGP(DMAIN, LOGL_NOTICE, "hlr starting\n"); rc = rand_init(); @@ -879,6 +879,23 @@ int main(int argc, char **argv) exit(1); } + if (cmdline_opts.db_check) { + LOGP(DMAIN, LOGL_NOTICE, "Cmdline option --db-check: Database was opened successfully, quitting.\n"); + db_close(g_hlr->dbc); + log_fini(); + talloc_free(hlr_ctx); + talloc_free(tall_vty_ctx); + talloc_disable_null_tracking(); + exit(0); + } + + /* start telnet after reading config for vty_get_bind_addr() */ + rc = telnet_init_dynif(hlr_ctx, NULL, vty_get_bind_addr(), + OSMO_VTY_PORT_HLR); + if (rc < 0) + return rc; + + g_hlr->gs = osmo_gsup_server_create(hlr_ctx, g_hlr->gsup_bind_addr, OSMO_GSUP_PORT, read_cb, &g_lu_ops, g_hlr); if (!g_hlr->gs) { |