forked from huawei/openGauss-server
gs_probackup远程备份且环境变量分离下,加载不到lib库。增加 --remote-libpath配置项导入
This commit is contained in:
parent
3bfba81357
commit
80e06757ad
|
|
@ -215,6 +215,11 @@ ConfigOption instance_options[] =
|
|||
&instance_config.remote.ssh_config, SOURCE_CMD, (OptionSource)0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
's', 231, "remote-libpath",
|
||||
&instance_config.remote.libpath, SOURCE_CMD, (OptionSource)0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
|
@ -506,6 +511,10 @@ readInstanceConfigFile(const char *instance_name)
|
|||
's', 230, "ssh-config", &instance->remote.ssh_config, SOURCE_CMD, (OptionSource)0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
's', 231, "remote-libpath", &instance->remote.libpath, SOURCE_CMD, (OptionSource)0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ do_add_instance(InstanceConfig *instance)
|
|||
SOURCE_DEFAULT);
|
||||
config_set_opt(instance_options, &instance_config.remote.path,
|
||||
SOURCE_DEFAULT);
|
||||
config_set_opt(instance_options, &instance_config.remote.libpath,
|
||||
SOURCE_DEFAULT);
|
||||
config_set_opt(instance_options, &instance_config.remote.user,
|
||||
SOURCE_DEFAULT);
|
||||
config_set_opt(instance_options, &instance_config.remote.ssh_options,
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ bool launch_agent(void)
|
|||
{
|
||||
char cmd[MAX_CMDLINE_LENGTH];
|
||||
char* ssh_argv[MAX_CMDLINE_OPTIONS];
|
||||
char libenv[MAX_CMDLINE_LENGTH] = {0};
|
||||
int ssh_argc;
|
||||
int outfd[2];
|
||||
int infd[2];
|
||||
|
|
@ -156,6 +157,19 @@ bool launch_agent(void)
|
|||
ssh_argv[ssh_argc++] = (char *)cmd;
|
||||
ssh_argv[ssh_argc] = NULL;
|
||||
|
||||
if (instance_config.remote.libpath)
|
||||
{
|
||||
#ifdef WIN32
|
||||
rc = snprintf_s(libenv, sizeof(libenv), sizeof(libenv) - 1, "set LD_LIBRARY_PATH=%s &&",
|
||||
instance_config.remote.libpath);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
#else
|
||||
rc = snprintf_s(libenv, sizeof(libenv), sizeof(libenv) - 1, "export LD_LIBRARY_PATH=%s &&",
|
||||
instance_config.remote.libpath);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (instance_config.remote.path)
|
||||
{
|
||||
char const* probackup = PROGRAM_NAME_FULL;
|
||||
|
|
@ -172,27 +186,27 @@ bool launch_agent(void)
|
|||
}
|
||||
if (needs_quotes(instance_config.remote.path) || needs_quotes(PROGRAM_NAME_FULL))
|
||||
{
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s\\%s\" agent",
|
||||
instance_config.remote.path, probackup);
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s %s\\%s\" agent",
|
||||
libenv, instance_config.remote.path, probackup);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s\\%s agent",
|
||||
instance_config.remote.path, probackup);
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s %s\\%s agent",
|
||||
libenv, instance_config.remote.path, probackup);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
}
|
||||
#else
|
||||
if (needs_quotes(instance_config.remote.path) || needs_quotes(PROGRAM_NAME_FULL))
|
||||
{
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s/%s\" agent",
|
||||
instance_config.remote.path, probackup);
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s %s/%s\" agent",
|
||||
libenv, instance_config.remote.path, probackup);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s/%s agent",
|
||||
instance_config.remote.path, probackup);
|
||||
rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s %s/%s agent",
|
||||
libenv, instance_config.remote.path, probackup);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ typedef struct RemoteConfig
|
|||
char* host;
|
||||
char* port;
|
||||
char* path;
|
||||
char* libpath;
|
||||
char* user;
|
||||
char *ssh_config;
|
||||
char *ssh_options;
|
||||
|
|
|
|||
Loading…
Reference in New Issue