dropshell release 2025.0524.1149
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 17s
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 17s
This commit is contained in:
@ -152,7 +152,7 @@ namespace dropshell
|
||||
recursive_copy(tinfo.local_template_path() / "config", service_dir);
|
||||
|
||||
// append TEMPLATE_HASH to the .template_info.env file
|
||||
std::string template_info_env_file = service_dir + "/.template_info.env";
|
||||
std::string template_info_env_file = service_dir + "/" + filenames::template_info_env;
|
||||
std::ofstream template_info_env_file_out(template_info_env_file);
|
||||
template_info_env_file_out << "TEMPLATE_HASH=" << tinfo.hash() << std::endl;
|
||||
template_info_env_file_out.close();
|
||||
@ -191,12 +191,12 @@ namespace dropshell
|
||||
}
|
||||
|
||||
|
||||
info << "Setting SSH_USER to " << sshuser << " in 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.
|
||||
std::string template_service_env_file = tinfo.local_template_path() / "config" / "service.env";
|
||||
std::string template_service_env_file = tinfo.local_template_path() / "config" / filenames::service_env;
|
||||
ASSERT(std::filesystem::exists(template_service_env_file), "Template service env file not found: " + template_service_env_file);
|
||||
std::ifstream template_service_env_file_in(template_service_env_file);
|
||||
std::ofstream service_env_file_out(service_dir + "/service.env");
|
||||
std::ofstream service_env_file_out(localfile::template_info_env(server_name, service_name));
|
||||
std::string line;
|
||||
while (std::getline(template_service_env_file_in, line))
|
||||
{
|
||||
@ -239,6 +239,23 @@ namespace dropshell
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool merge_updated_service_template(const std::string &server_name, const std::string &service_name)
|
||||
{
|
||||
LocalServiceInfo service_info = get_service_info(server_name, service_name);
|
||||
ASSERT(SIvalid(service_info), "Service info is not valid for " + service_name + " on " + server_name);
|
||||
|
||||
template_info tinfo = gTemplateManager().get_template_info(service_info.template_name);
|
||||
ASSERT(tinfo.is_set(), "Failed to load template " + service_info.template_name);
|
||||
|
||||
// copy across .template_info.env file
|
||||
std::string template_service_env_file = "";
|
||||
std::string target_service_env_file = localfile::template_info_env(server_name, service_name);
|
||||
ASSERT(std::filesystem::exists(template_service_env_file), "Template service env file not found: " + template_service_env_file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace shared_commands
|
||||
|
||||
} // namespace dropshell
|
@ -70,6 +70,15 @@ namespace dropshell
|
||||
if (!SIvalid(service_info))
|
||||
return false;
|
||||
|
||||
if (!service_info.service_template_hash_match)
|
||||
{
|
||||
warning << "Service " << service << " is using an old template. Updating. " << std::endl;
|
||||
if (!merge_updated_service_template(server_env.get_server_name(), service))
|
||||
{
|
||||
error << "Failed to merge updated service template. " << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
maketitle("Installing " + service + " (" + service_info.template_name + ") on " + server);
|
||||
|
||||
|
@ -98,6 +98,7 @@ namespace dropshell
|
||||
|
||||
// defined in create-service.cpp
|
||||
bool create_service(const std::string &server_name, const std::string &template_name, const std::string &service_name, std::string user_override="");
|
||||
bool merge_updated_service_template(const std::string &server_name, const std::string &service_name);
|
||||
|
||||
} // namespace shared_commands
|
||||
} // namespace dropshell
|
||||
|
Reference in New Issue
Block a user