Update source/src/commands/install.cpp
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 26s
Build-Test-Publish / build (linux/arm64) (push) Successful in 1m8s

This commit is contained in:
j
2026-02-27 12:07:18 +13:00
parent 50f2a7029a
commit c165895ab4

View File

@@ -145,22 +145,26 @@ namespace dropshell
}
// 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");
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;
// Sync template and config so install-pre.sh is available on remote
if (!shared_commands::rsync_service_config(server_env, service, false))
// Copy only install-pre.sh to the existing remote template directory
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;
return false;
warning << "Failed to copy install-pre.sh to remote, skipping pre-install" << std::endl;
}
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))
else
{
warning << "Pre-install script failed, continuing with install..." << std::endl;
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))
{
warning << "Pre-install script failed, continuing with install..." << std::endl;
}
}
}