mirror of https://gerrit.osmocom.org/libosmocore
vty: fix 'write file FILE' breaking 'show startup-config'
Change-Id: I224ae41096c12f544dfe35a2c3f381b3bb3ba75e Related: OS#6440
This commit is contained in:
parent
dafdb1181b
commit
5155535be7
|
@ -3490,6 +3490,7 @@ DEFUN(config_write_file,
|
||||||
"Write to configuration file\n"
|
"Write to configuration file\n"
|
||||||
"Set file path to store the config, or replace if already exists\n")
|
"Set file path to store the config, or replace if already exists\n")
|
||||||
{
|
{
|
||||||
|
const char *config_file;
|
||||||
char *failed_file;
|
char *failed_file;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -3503,15 +3504,16 @@ DEFUN(config_write_file,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
host_config_set(argv[0]);
|
config_file = argv[0];
|
||||||
|
else /* write to the startup config file */
|
||||||
if (host.config == NULL) {
|
config_file = host_config_file();
|
||||||
|
if (config_file == NULL) {
|
||||||
vty_out(vty, "Can't save to configuration file, using vtysh.%s",
|
vty_out(vty, "Can't save to configuration file, using vtysh.%s",
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = write_config_file(host.config, &failed_file);
|
rc = write_config_file(config_file, &failed_file);
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
case -1:
|
case -1:
|
||||||
vty_out(vty, "Can't open configuration file %s.%s",
|
vty_out(vty, "Can't open configuration file %s.%s",
|
||||||
|
@ -3544,7 +3546,7 @@ DEFUN(config_write_file,
|
||||||
rc = CMD_WARNING;
|
rc = CMD_WARNING;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vty_out(vty, "Configuration saved to %s%s", host.config, VTY_NEWLINE);
|
vty_out(vty, "Configuration saved to %s%s", config_file, VTY_NEWLINE);
|
||||||
rc = CMD_SUCCESS;
|
rc = CMD_SUCCESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue