Update source/src/commands/create-service.cpp
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 22s
Build-Test-Publish / build (linux/arm64) (push) Successful in 56s

This commit is contained in:
j
2026-01-15 10:29:25 +13:00
parent cbae2db05c
commit 58742d7c63

View File

@@ -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 (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();
if (!set_env_variable(
localfile::service_env(server_name, service_name),
"SSH_USER",
sshuser,
""))
{
error << "Failed to set SSH_USER in service.env" << std::endl;
return false;
}
// check docker.