Update source/src/commands/create-service.cpp
This commit is contained in:
@@ -171,7 +171,7 @@ namespace dropshell
|
||||
// copy the template config files to the service directory
|
||||
recursive_copy(tinfo.local_template_path() / "config", service_dir);
|
||||
|
||||
// set TEMPLATE in service.env first (required before get_service_info)
|
||||
// set TEMPLATE in service.env (required before get_service_info)
|
||||
if (!set_env_variable(
|
||||
localfile::service_env(server_name, service_name),
|
||||
"TEMPLATE",
|
||||
@@ -215,21 +215,16 @@ namespace dropshell
|
||||
}
|
||||
|
||||
|
||||
// set SSH_USER in service.env
|
||||
info << "Setting SSH_USER to " << sshuser << " in the " << filenames::service_env << " file" << std::endl;
|
||||
{ // edit the service.env file to set the SSH_USER.
|
||||
std::string source_service_env = tinfo.local_template_path() / "config" / filenames::service_env;
|
||||
ASSERT(std::filesystem::exists(source_service_env), "Template service env file not found: " + source_service_env);
|
||||
std::ifstream template_service_env_file_in(source_service_env);
|
||||
std::ofstream service_env_file_out(localfile::service_env(server_name, service_name));
|
||||
std::string line;
|
||||
while (std::getline(template_service_env_file_in, line))
|
||||
if (!set_env_variable(
|
||||
localfile::service_env(server_name, service_name),
|
||||
"SSH_USER",
|
||||
sshuser,
|
||||
""))
|
||||
{
|
||||
if (line.find("SSH_USER") != std::string::npos)
|
||||
line = "SSH_USER=" + sshuser;
|
||||
service_env_file_out << line << std::endl;
|
||||
}
|
||||
template_service_env_file_in.close();
|
||||
service_env_file_out.close();
|
||||
error << "Failed to set SSH_USER in service.env" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// check docker.
|
||||
|
||||
Reference in New Issue
Block a user