diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2021-06-21 14:47:21 +0200 |
---|---|---|
committer | Philipp Maier <pmaier@sysmocom.de> | 2021-06-24 10:15:49 +0200 |
commit | b9930bdf09c69e13a0efc9bc0b40ab8fc8088bd3 (patch) | |
tree | c35df37cc26fc9d7c592a31c812e75703de58d8b | |
parent | 2644cd2d950679a537fc3a1cf37bceed63507e8f (diff) |
bsc_ctrl_commands: add command to write vty config
we recently added control commands to apply vty config files during
runtime using the control interface. However, there is no command that
allows us to store the config file modifications.
Change-Id: If17095bb86f82dd8feb86eb72c4133ea3aa1c3b3
Related: SYS#5369
-rw-r--r-- | doc/manuals/chapters/control.adoc | 1 | ||||
-rw-r--r-- | src/osmo-bsc/bsc_ctrl_commands.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/doc/manuals/chapters/control.adoc b/doc/manuals/chapters/control.adoc index 6b1609ae5..bd491002e 100644 --- a/doc/manuals/chapters/control.adoc +++ b/doc/manuals/chapters/control.adoc @@ -27,6 +27,7 @@ TRX-specific commands are additionally prefixed with TRX number e. g. |inform-msc-v1|WO|Yes|Arbitrary value| See <<infomsc>> for details. |rf_locked|RW|No|"0","1"|See <<rfl>> for details. |number-of-bts|RO|No|"<num>"|Get number of configured BTS. +|write-config-file|WO|No|"overwrite", "<filename>"|Write running configuration to file. |bts.N.location-area-code|RW|No|"<lac>"|Set/Get LAC (value between (0, 65535)). |bts.N.cell-identity|RW|No|"<id>"|Set/Get Cell Identity (value between (0, 65535)). |bts.N.apply-configuration|WO|No|Ignored|Restart BTS via OML. diff --git a/src/osmo-bsc/bsc_ctrl_commands.c b/src/osmo-bsc/bsc_ctrl_commands.c index 2d37b5dbb..15f553645 100644 --- a/src/osmo-bsc/bsc_ctrl_commands.c +++ b/src/osmo-bsc/bsc_ctrl_commands.c @@ -24,6 +24,7 @@ #include <osmocom/ctrl/control_cmd.h> #include <osmocom/vty/command.h> +#include <osmocom/vty/misc.h> #include <osmocom/gsm/gsm48.h> #include <osmocom/bsc/ipaccess.h> @@ -82,6 +83,31 @@ close_ret: } CTRL_CMD_DEFINE_WO(net_apply_config_file, "apply-config-file"); +static int verify_net_write_config_file(struct ctrl_cmd *cmd, const char *value, void *_data) +{ + return 0; +} +static int set_net_write_config_file(struct ctrl_cmd *cmd, void *_data) +{ + const char *cfile_name; + unsigned cmd_ret = CTRL_CMD_ERROR; + + if (strcmp(cmd->value, "overwrite")) + host_config_set(cmd->value); + + cfile_name = host_config_file(); + + LOGP(DCTRL, LOGL_NOTICE, "Writing VTY config to file %s...\n", cfile_name); + if (osmo_vty_write_config_file(cfile_name) < 0) + goto ret; + + cmd->reply = "OK"; + cmd_ret = CTRL_CMD_REPLY; +ret: + return cmd_ret; +} +CTRL_CMD_DEFINE_WO(net_write_config_file, "write-config-file"); + CTRL_CMD_DEFINE(net_mcc, "mcc"); static int get_net_mcc(struct ctrl_cmd *cmd, void *_data) { @@ -528,6 +554,7 @@ int bsc_base_ctrl_cmds_install(void) { int rc = 0; rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config_file); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_write_config_file); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mnc); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config); |