mobile: Use config file in ~/.osmocom/bb/mobile.cfg
We don't need root permission and a system-wide config file in /etc/osmocom Based on a patch by Pierre Pronchery <khorben@defora.org>
This commit is contained in:
parent
b7a4d8d912
commit
4be57b9afd
|
@ -349,7 +349,7 @@ int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
|
|||
const char *config_file, uint16_t vty_port)
|
||||
{
|
||||
struct telnet_connection dummy_conn;
|
||||
int rc;
|
||||
int rc = 0;
|
||||
|
||||
mncc_recv_app = mncc_recv;
|
||||
|
||||
|
@ -359,13 +359,15 @@ int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
|
|||
ms_vty_init();
|
||||
dummy_conn.priv = NULL;
|
||||
vty_reading = 1;
|
||||
rc = vty_read_config_file(config_file, &dummy_conn);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to parse the config file: '%s'\n",
|
||||
config_file);
|
||||
fprintf(stderr, "Please check or create config file using: "
|
||||
"'touch %s'\n", config_file);
|
||||
return rc;
|
||||
if (config_file != NULL) {
|
||||
rc = vty_read_config_file(config_file, &dummy_conn);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to parse the config file:"
|
||||
" '%s'\n", config_file);
|
||||
fprintf(stderr, "Please check or create config file"
|
||||
" using: 'touch %s'\n", config_file);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
vty_reading = 0;
|
||||
telnet_init(l23_ctx, NULL, vty_port);
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
#define _GNU_SOURCE
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
@ -44,7 +46,6 @@
|
|||
struct log_target *stderr_target;
|
||||
|
||||
void *l23_ctx = NULL;
|
||||
static const char *config_file = "/etc/osmocom/osmocom.cfg";
|
||||
struct llist_head ms_list;
|
||||
static uint32_t gsmtap_ip = 0;
|
||||
unsigned short vty_port = 4247;
|
||||
|
@ -129,7 +130,7 @@ void sighandler(int sigset)
|
|||
if (sigset == SIGHUP || sigset == SIGPIPE)
|
||||
return;
|
||||
|
||||
fprintf(stderr, "Signal %d recevied.\n", sigset);
|
||||
fprintf(stderr, "Signal %d received.\n", sigset);
|
||||
|
||||
/* in case there is a lockup during exit */
|
||||
signal(SIGINT, SIG_DFL);
|
||||
|
@ -144,6 +145,10 @@ int main(int argc, char **argv)
|
|||
{
|
||||
int quit = 0;
|
||||
int rc;
|
||||
char const * home;
|
||||
size_t len;
|
||||
const char osmocomcfg[] = ".osmocom/bb/mobile.cfg";
|
||||
char *config_file = NULL;
|
||||
|
||||
printf("%s\n", openbsc_copyright);
|
||||
|
||||
|
@ -171,7 +176,15 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
home = getenv("HOME");
|
||||
if (home != NULL) {
|
||||
len = strlen(home) + 1 + sizeof(osmocomcfg);
|
||||
config_file = talloc_size(l23_ctx, len);
|
||||
if (config_file != NULL)
|
||||
snprintf(config_file, len, "%s/%s", home, osmocomcfg);
|
||||
}
|
||||
rc = l23_app_init(NULL, config_file, vty_port);
|
||||
talloc_free(config_file);
|
||||
if (rc)
|
||||
exit(rc);
|
||||
|
||||
|
|
Loading…
Reference in New Issue