Update source/src/commands/install.cpp
This commit is contained in:
@@ -145,24 +145,28 @@ namespace dropshell
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run install-pre.sh if it exists in the local template cache (reduces downtime by e.g. pulling images before uninstall)
|
// Run install-pre.sh if it exists in the local template cache (reduces downtime by e.g. pulling images before uninstall)
|
||||||
|
// Only sync the single script, NOT the full template — the old uninstall.sh must stay matching the installed version.
|
||||||
bool has_install_pre = std::filesystem::exists(tinfo.local_template_path() / "install-pre.sh");
|
bool has_install_pre = std::filesystem::exists(tinfo.local_template_path() / "install-pre.sh");
|
||||||
if (has_install_pre && server_env.check_remote_dir_exists(remote_service_path, user))
|
if (has_install_pre && server_env.check_remote_dir_exists(remote_service_path, user))
|
||||||
{
|
{
|
||||||
info << "Running pre-install script to prepare for update..." << std::endl;
|
info << "Running pre-install script to prepare for update..." << std::endl;
|
||||||
|
|
||||||
// Sync template and config so install-pre.sh is available on remote
|
// Copy only install-pre.sh to the existing remote template directory
|
||||||
if (!shared_commands::rsync_service_config(server_env, service, false))
|
std::string local_script = (tinfo.local_template_path() / "install-pre.sh").string();
|
||||||
|
std::string remote_script = remotepath(server, user).service_template(service) + "/install-pre.sh";
|
||||||
|
if (!shared_commands::rsync_file_to_remote(local_script, remote_script, server_env, false, user))
|
||||||
{
|
{
|
||||||
error << "Failed to sync service configuration to remote for pre-install" << std::endl;
|
warning << "Failed to copy install-pre.sh to remote, skipping pre-install" << std::endl;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
shared_commands::cRemoteTempFolder remote_temp_folder(server_env, user);
|
shared_commands::cRemoteTempFolder remote_temp_folder(server_env, user);
|
||||||
if (!server_env.run_remote_template_command(service, "install-pre", {}, false, {{"TEMP_DIR", remote_temp_folder.path()}}, NULL))
|
if (!server_env.run_remote_template_command(service, "install-pre", {}, false, {{"TEMP_DIR", remote_temp_folder.path()}}, NULL))
|
||||||
{
|
{
|
||||||
warning << "Pre-install script failed, continuing with install..." << std::endl;
|
warning << "Pre-install script failed, continuing with install..." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Uninstall the old service (this removes the remote service directory)
|
// Uninstall the old service (this removes the remote service directory)
|
||||||
if (server_env.check_remote_dir_exists(remote_service_path, user))
|
if (server_env.check_remote_dir_exists(remote_service_path, user))
|
||||||
|
|||||||
Reference in New Issue
Block a user