forked from Mirror/frr
vtysh: infer integrated config usage from existence of Quagga.conf
Only write to integrated config if integrated config is configured explicitly or it is already in use. Signed-off-by: Christian Franke <chris@opensourcerouting.org>
This commit is contained in:
parent
b6bf1505df
commit
039eaca367
|
@ -75,8 +75,7 @@ struct vtysh_client vtysh_client[] =
|
||||||
{ .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .path = PIM_VTYSH_PATH, .next = NULL},
|
{ .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .path = PIM_VTYSH_PATH, .next = NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Using integrated config from Quagga.conf. Default is no. */
|
enum vtysh_write_integrated vtysh_write_integrated = WRITE_INTEGRATED_UNSPECIFIED;
|
||||||
int vtysh_writeconfig_integrated = 1;
|
|
||||||
|
|
||||||
extern char config_default[];
|
extern char config_default[];
|
||||||
|
|
||||||
|
@ -2482,7 +2481,7 @@ DEFUN (vtysh_integrated_config,
|
||||||
"Set up miscellaneous service\n"
|
"Set up miscellaneous service\n"
|
||||||
"Write configuration into integrated file\n")
|
"Write configuration into integrated file\n")
|
||||||
{
|
{
|
||||||
vtysh_writeconfig_integrated = 1;
|
vtysh_write_integrated = WRITE_INTEGRATED_YES;
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2493,7 +2492,7 @@ DEFUN (no_vtysh_integrated_config,
|
||||||
"Set up miscellaneous service\n"
|
"Set up miscellaneous service\n"
|
||||||
"Write configuration into integrated file\n")
|
"Write configuration into integrated file\n")
|
||||||
{
|
{
|
||||||
vtysh_writeconfig_integrated = 0;
|
vtysh_write_integrated = WRITE_INTEGRATED_NO;
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2573,6 +2572,23 @@ write_config_integrated(void)
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool vtysh_writeconfig_integrated(void)
|
||||||
|
{
|
||||||
|
struct stat s;
|
||||||
|
|
||||||
|
switch (vtysh_write_integrated)
|
||||||
|
{
|
||||||
|
case WRITE_INTEGRATED_UNSPECIFIED:
|
||||||
|
if (stat(integrate_default, &s) && errno == ENOENT)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
case WRITE_INTEGRATED_NO:
|
||||||
|
return false;
|
||||||
|
case WRITE_INTEGRATED_YES:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEFUN (vtysh_write_memory,
|
DEFUN (vtysh_write_memory,
|
||||||
vtysh_write_memory_cmd,
|
vtysh_write_memory_cmd,
|
||||||
"write memory",
|
"write memory",
|
||||||
|
@ -2585,7 +2601,7 @@ DEFUN (vtysh_write_memory,
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
/* If integrated Quagga.conf explicitely set. */
|
/* If integrated Quagga.conf explicitely set. */
|
||||||
if (vtysh_writeconfig_integrated)
|
if (vtysh_writeconfig_integrated())
|
||||||
return write_config_integrated();
|
return write_config_integrated();
|
||||||
else
|
else
|
||||||
backup_config_file(integrate_default);
|
backup_config_file(integrate_default);
|
||||||
|
|
|
@ -45,6 +45,14 @@ DECLARE_MGROUP(MVTYSH)
|
||||||
#define VTYSH_DEFAULT_CONFIG "vtysh.conf"
|
#define VTYSH_DEFAULT_CONFIG "vtysh.conf"
|
||||||
#define QUAGGA_DEFAULT_CONFIG "Quagga.conf"
|
#define QUAGGA_DEFAULT_CONFIG "Quagga.conf"
|
||||||
|
|
||||||
|
enum vtysh_write_integrated {
|
||||||
|
WRITE_INTEGRATED_UNSPECIFIED,
|
||||||
|
WRITE_INTEGRATED_NO,
|
||||||
|
WRITE_INTEGRATED_YES
|
||||||
|
};
|
||||||
|
|
||||||
|
extern enum vtysh_write_integrated vtysh_write_integrated;
|
||||||
|
|
||||||
void vtysh_init_vty (void);
|
void vtysh_init_vty (void);
|
||||||
void vtysh_init_cmd (void);
|
void vtysh_init_cmd (void);
|
||||||
extern int vtysh_connect_all (const char *optional_daemon_name);
|
extern int vtysh_connect_all (const char *optional_daemon_name);
|
||||||
|
|
|
@ -33,8 +33,6 @@ DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CONFIG_LINE, "Vtysh configuration line")
|
||||||
|
|
||||||
vector configvec;
|
vector configvec;
|
||||||
|
|
||||||
extern int vtysh_writeconfig_integrated;
|
|
||||||
|
|
||||||
struct config
|
struct config
|
||||||
{
|
{
|
||||||
/* Configuration node name. */
|
/* Configuration node name. */
|
||||||
|
@ -458,8 +456,10 @@ vtysh_config_write ()
|
||||||
sprintf (line, "hostname %s", host.name);
|
sprintf (line, "hostname %s", host.name);
|
||||||
vtysh_config_parse_line(line);
|
vtysh_config_parse_line(line);
|
||||||
}
|
}
|
||||||
if (!vtysh_writeconfig_integrated)
|
if (vtysh_write_integrated == WRITE_INTEGRATED_NO)
|
||||||
vtysh_config_parse_line ("no service integrated-vtysh-config");
|
vtysh_config_parse_line ("no service integrated-vtysh-config");
|
||||||
|
if (vtysh_write_integrated == WRITE_INTEGRATED_YES)
|
||||||
|
vtysh_config_parse_line ("service integrated-vtysh-config");
|
||||||
|
|
||||||
user_config_write ();
|
user_config_write ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue