Update source/src/commands/install.cpp
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user