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
|
// copy the template config files to the service directory
|
||||||
recursive_copy(tinfo.local_template_path() / "config", service_dir);
|
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(
|
if (!set_env_variable(
|
||||||
localfile::service_env(server_name, service_name),
|
localfile::service_env(server_name, service_name),
|
||||||
"TEMPLATE",
|
"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;
|
info << "Setting SSH_USER to " << sshuser << " in the " << filenames::service_env << " file" << std::endl;
|
||||||
{ // edit the service.env file to set the SSH_USER.
|
if (!set_env_variable(
|
||||||
std::string source_service_env = tinfo.local_template_path() / "config" / filenames::service_env;
|
localfile::service_env(server_name, service_name),
|
||||||
ASSERT(std::filesystem::exists(source_service_env), "Template service env file not found: " + source_service_env);
|
"SSH_USER",
|
||||||
std::ifstream template_service_env_file_in(source_service_env);
|
sshuser,
|
||||||
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 (line.find("SSH_USER") != std::string::npos)
|
error << "Failed to set SSH_USER in service.env" << std::endl;
|
||||||
line = "SSH_USER=" + sshuser;
|
return false;
|
||||||
service_env_file_out << line << std::endl;
|
|
||||||
}
|
|
||||||
template_service_env_file_in.close();
|
|
||||||
service_env_file_out.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check docker.
|
// check docker.
|
||||||
|
|||||||
Reference in New Issue
Block a user